ebook img

LAC 2009 - Paper: The Guido Engine: A toolbox for music scores rendering PDF

2009·0.32 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview LAC 2009 - Paper: The Guido Engine: A toolbox for music scores rendering

The Guido Engine A toolbox for music scores rendering C. Daudin, D. Fober, S. Letz and Y. Orlarey Grame Centre national de cration musicale Lyon, France {daudin, fober, letz, orlarey}@grame.fr Abstract music notation. Since MusiXTEX is powerful but hard to learn, preprocessors such as PMX TheGuidoMusicNotationformat(GMN)isagen- and M-Tx have been designed to facilitate mu- eral purpose formal language for representing score sic input and layout. A more recent initiative is levelmusicinaplatformindependentplaintextand Lilypond [10], an open source software partially human readable way. Based on this music repre- implemented in the language Scheme, its input sentation format, the GuidoLib provides a generic, music representation format is simple and intu- portable library and API for the graphical render- itive, it includes automatic layout capabilities. ing of musical scores. This paper gives an intro- Both systems produce PostScript, EPS or PDF duction to the music notation format and to the files. Guido graphic score rendering engine. An exam- pleofapplication,theGuidoSceneComposer,isnext Based the Guido Music Notation format, presented. the GuidoLib project is a open source, cross- platform C/C++ library that provides score Keywords layoutandrenderingcapabilitiestoitsclientap- plications. The music notation format is very Guido, Music notation, score layout. close to the Lylipond format. The GuidoLib mainly differs from the compilers approach in 1 Introduction that it allows to embed music score rendering Computer music has started to investigate mu- capabilities into standalone applications and to sic score rendering very early [1][2][3]. Music create scores dynamically. notation codes such as DARMS [4], SCORE [5] This paper introduces first the Guido Mu- or MuseData [6] have been designed to address sic Notation format, next the Guido Engine representational issues and gave birth to asso- and the Guido library API are presented. The ciated programs (such as the SCORE Notation last section presents the Qt support for Guido, Program, widely used in engraving during the alongwithaconcreteexampleof Guido-Qtap- 1980s and 1990s) and a long history of derived plication, the GuidoSceneComposer. or alternate formats. Now, commercial music publishing software exist for more a decade and actually provide so- 2 The Guido Music Notation format phisticated but complex solutions for music en- graving. Along these closed solutions, the tool- The Guido Music Notation format (GMN) [11] box approach has been investigated very early [12]hasbeendesignedbyH.HoosandK.Hamel [7]. However, very few systems have reached more than ten years ago. It is a general pur- maturity: the Common Music Notation system poseformallanguageforrepresentingscorelevel [8] could be considered as the best achievement. music in a platform independent plain text and More recently, the Expressive Notation Pack- human readable way. It is based on a concep- age (ENP)[9]introducedanotherpromisingap- tually simple but powerful formalism: its de- proach; both systems are Lisp based environ- sign concentrates on general musical concepts ments. (as opposed to graphical features). A key fea- Another solution consists in designing com- ture of the Guido design is adequacy which pilers for producing music sheets from a tex- means that simple musical concepts should be tual music description. MusiXTEX is among represented in a simple way and only complex these tools: it is a set of TEX macros to typeset notions should require complex representations. 2.1 Basic concepts { BasicGuidonotationcoverstherepresentation [\staff<1> \stemsUp \meter<"2/4"> of notes, rests, accidentals, single and multi- \beam(g2/32 e/16 c*3/32) c/8 \beam(a1/16 c2 f) voiced music and the most common concepts \beam(g/32 d/16 h1*3/32) d2/8 from conventional music notation such as clefs, \beam(h1/16 d2 g)], meter,key,slurs,ties,beaming,stemdirections, etc. Notes are specified by their name (a b c [\staff<1>\stemsDown g1/8 e d e f g h), optional accidentals (’#’ and ’&’ \beam(g/16 d f a) a/8 e \beam(a/16 e g h)], for sharp and flat), an optional octave number [\staff<2> \stemsUp \meter<"2/4"> a0 f h c1], and an optional duration. [\staff<2>\stemsDown f0 d g a] Duration is specified in one of the forms: } ’*’enum’/’denom dotting ’*’enum dotting The corresponding Guido engine output is ’/’denom dotting given by figure 2. where enum and denom are positive integers and dotting is either empty, ’.’, or ’..’, with the se1tian.omunTmaehl.seoermdduaenrnattiocimotnhiasrenopmtrheisteetemndtus,siaitciwnsohatosalsetuimonnoe.tdeWtforhabecne- & 24 X!ÛÛÛÛÛÛÛX"ÚÚÚÚÚÚ X!ÛÛÛÛÛÛÛÛ X!ÛÛÛÛÛÛÛÛÛÛX"ÚÚÚÚÚÚ. X!ÛÛÛÛÛÛjX"ÚÚÚÚÚÚÚÚÚ X!ÛÛÛÛÛÛÛÛÛÛX"ÚÚÚÚÚÚ X!ÛÛÛÛÛÛÛÛX"ÚÚÚÚÚÚÚ X!ÛÛÛÛÛÛX"ÚÚÚÚÚÚÚÚÚ ‹ X!ÛÛÛÛÛÛÛX"ÚÚÚÚÚÚÚ X!ÛÛÛÛÛÛÛÛÛ X!ÛÛÛÛÛÛÛÛÛÛÛX"ÚÚÚÚÚÚ. X!ÛÛÛÛÛÛjX"ÚÚÚÚÚÚÚÚÚ X!ÛÛÛÛÛÛÛÛÛÛX"ÚÚÚÚÚÚ X!ÛÛÛÛÛÛÛÛX"ÚÚÚÚÚÚÚ X!ÛÛÛÛÛÛX"ÚÚÚÚÚÚÚÚÚ \\ pspaeWrctsihfieacnraetiooanmssuibtmetfeoeddr,etioonpbtthieoenecqaulurarnleonttotestehdqeeuspecnrrecipve.itoiouns ? 24 X!ÛÛÛÛÛÛX"ÚÚÚÚÚÚ X!ÛÛÛÛÛÛX"ÚÚÚÚÚÚ ‹ X!ÛÛÛÛÛÛX"ÚÚÚÚÚÚ _X!ÛÛÛÛÛÛX"ÚÚÚÚÚÚ \\ Chords are described using comma separated Figure 2: A multi-voices example notes enclosed in brackets e.g {c, e, g} 2.2 Guido tags Additionally, the advanced Guido specifica- Tags are used to represent additional musical tion (not covered by this paper) provides exact information, such as slurs, clefs, keys, etc. A formatting of the score. basic tag has one of the forms: \tagname 3 The Guido Engine \tagname<param-list> where param-list is a list of string or numer- Based on the Guido Music Notation format ical arguments, separated by commas (’,’). In and initially designed by Kai Renz, the Guido addition, a tag may have a time range and be Engine provides graphical rendering of musical applied to a series of notes (like slurs, ties etc.); scores, including automatic layout capabilities. the corresponding form is: At Grame’s initiative, the engine has been re- \tagname(note-series) shapedundertheformofaportablelibraryand \tagname<param-list>(note-series) became an open source project in 2002, cov- The following GMN code illustrates the con- cision of the notation; figure 1 represents the ered by the GNU LGPL license and hosted on corresponding Guido engine output. SourceForge. Since 2002, the Guido engine has [ \meter<"4/4"> \key<-2> c d e& f/8 g ] been maintained and extended by Grame. The Guido Engine operates on a memory representation of the GMN format: the Guido & bb 44 _XÛxxxxxx XÛxxxxxx XÛxxxxxx XÛxxxxxx XÛxxxxxx \ AtabtisotnracistRtreapnrsefsoernmtaedtiosnte(pGAbyR)s.teTphitsorepprroedsuence- graphical score pages. Two kinds of processing Figure 1: A simple GMN example are first applied to the GAR: 2.3 Notes sequences and segments • GARtoGARtransformationswhichrepre- A note sequence is of the form [tagged-notes] sents a logical layout transformation: part where tagged-notes is a series of notes, tags, ofthelayout(suchasbeamingforexample) and tagged ranges separated by spaces. Note may be computed from the GAR as well as sequences represent single-voiced scores. Note expressed in GAR, segmentsrepresentmulti-voicedscores;theyare denoted by {seq-list} where seq-list is a • theGARisconvertedintoaGuidoSeman- list of note sequences separated by commas as tic Normal Form (GSNF). The GSNF is a shown by the example below: canonical form such that different semanti- 4.2 Score pages access cally equivalent expressions have the same The result of the score layout is a set of pages GSNF. which size may be dynamically changed accord- ing to an application or a user needs. The This GSNF is finally converted into a Guido library provides the necessary to change the Graphic Representation (GGR) that contains page size, to query a score pages count, or the the necessary layout information and is directly page number corresponding to a given music used to draw the music score. This final step date. Note that only one page is drawn by the notably includes spacing and page breaking al- GuidoOnDraw function. gorithms [13]. Note that although the GMN format allows 4.3 Engine settings for acurate music formatting using advanced Score layout algorithms are controlled by a set Guido (see figure 3), the Guido Engine pro- of parameters which are global to the Guido vides powerful automatic layout capabilities. engine. The library provides an API to query and modify these parameters. It includes op- 4 The Guido Library timal page fill control, springs and space force control, systems distance and systems distribu- The Guido Library is implemented is in C++ tion. but the services of Guido Engine are available using a C API. 4.4 The Guido Factory The Guido Engine may be feeded with com- 4.1 Score layout puter generated music using the Guido Fac- The library provides functions to parse a GMN tory. The Guido Factory API provides a set of file and to create the corresponding GAR and functions to create a GAR from scratch and to GGR. GAR and GGR are referenced by opaque convert it into a GGR. The Guido Factory is a handles which are used as arguments of any state machine that operates on implicit current function that operates on a score. For exam- elements: for example, once you open a voice ple: GuidoParse (const char * filename) pro- (GuidoFactoryOpenVoice()), it becomes the cur- videsconversionofaGMNfileintoaGGRhan- rent voice and all subsequent created events are dle returned as the function result. This handle implicitly added to this current voice. may be next used to draw the score using the TheGuidoFactorystateincludesthecurrent GuidoOnDraw function. score,voice,chord,note(orrest)andtag. Some A typical code to draw a score from its GMN elements of the factory state reflects the Guido description is given below (see section 4.6 for formal specification; unless otherwise specified, VGDevice information): new notes will implicitly carry the current du- void DrawGMNFile (char* filename, VGDevice* device) ration and octave. { A music score dynamic construction is very // data structure for engine initialization close to the textual Guido description: the // uses fonts "guido2" and "times" GuidoInitDesc gd = { device, 0, "guido2", "times" }; Factory API handles GAR objects that have a // Initialise the Guido Engine first one to one relationship with the notation for- GuidoInit (&gd); mat. Oncethescorehasbeendynamicallybuilt, // declare a data structure for drawing a call to GuidoFactoryCloseMusic() returns a GuidoOnDrawDesc desc; Guido handle to a GAR, directly usable with // and parse the GMN file to get a GGR handle GuidoFactoryMakeGR(), which returns a Guido // directly stored in the drawing struct desc.handle = GuidoParse (filename); handle to a GGR, directly usable with the main services of the library. Logical layout is per- // next setup the drawing parameters formed before returning the GAR handle and // (see the documentation for more details) desc.hdc = device; // the output device graphical layout is performed before returning desc.page = 1; // the page to draw the GGR handle. desc.updateRegion.erase = true; desc.scrollx = desc.scrolly = 0; 4.5 Graphic Mappings desc.zoom = 1; // no zoom desc.sizex = desc.sizey = 0; Along with the GGR, the Guido Engine main- tains a tree of graphical elements for each page // and finally draws the score of the score, as illustrated by figure 4. Each ele- GuidoOnDraw (&desc); } ment has a bounding box and a date. Positions FUGA I J.S.Bach BWV 846 & c a _XÚhhhhhh XÚhhhhhh XÚhhhhhh XÚhhhhhh . XÚhhhhhhh XÚhhhhhhh XÚhhhhhh XÚhhhhhhhh eeeeee XÚhhhhhh XÚhhhhhhhh XÚhhhhhh XÚhhhhhhh XÚhhhhhh XÚhhhhhh XÚhhhhhha XÚhhhhhhh XÛxxxxxxXÚhhhhhh XÚhhhhhh _XÛxxxxxxXÚhhhhhh XÚhhhhhhh _XÛxxxxxxXÚhhhhhh _XÚhhhhhh eeeeee __XÛxxxxxxXÚhhhhhh .#XÚhhhhhhhhhh XÛxxxxxxXÛxxxxxxxXÛxxxxxxxxXÚhhhhhh XÛxxxxxx XÛxxxxxxxxXÚhhhhhhh XÛxxxxxxXÚhhhhhh XÚhhhhhh XÛxxxxxxxXÚhhhhhhh XÛxxxxxx XÛxxxxxxXÚhhhhhh XÛxxxxxxx eeeeee ee ee ee c ? eeeeeee eeeeeee eeeeeee & XÛxxxxxxXÚhhhhhh XÛxxxxxxxx XÛxxxxxxxXÚhhhhhh XÛxxxxxx XÛxxxxxxXÚhhhhhh XÛxxxxxxx XÛxxxxxxXÚhhhhhh XÛxxxxxx _XÛxxxxxxXÚhhhhhh XÛxxxxxxx XÛxxxxxxa #XÛxxxxxx XÛxxxxxxa XÛxxxxxxxxxxXÚhhhhhhJ eeeeee XÛxxxxxxXÚhhhhhh XÛxxxxxxxXÚhhhhhh XÚhhhhhh XÛxxxxxxXÚhhhhhh XÛxxxxxx XÛxxxxxx XÛxxxxxxx XÛxxxxxxXÚhhhhhh. XÚhhhhhh XÚhhhhhh XÛxxxxxx XÛxxxxxxXÚhhhhhh XÛxxxxxxx XÛxxxxxx XÛxxxxxx eeeeee J XÛxxxxxx XÛxxxxxx XÛxxxxxx _XÛxxxxxx. _XÛxxxxxx _XÛxxxxxxx XÛxxxxxxxx __XÛxxxxxx eeee XÛxxxxxxxx _XÛxxxxxx _XÛxxxxxxx __XÛxxxxxx _XÛxxxxxx _XÛxxxxxxx XÛxxxxxxx _XÛxxxxxx _XÛxxxxxx bXÛxxxxxxx eeee ? a eeeeeee a XÚhhhhhh XÚhhhhhh XÚhhhhhh eeeeeee Figure 3: A complex layout example of the elements are stored as pixel coordinates. (Windows), Quartz (Mac OS X), GTK (GNU Top left corner of the score is at position (0, 0). Linux), OpenGL and more recently for Qt. = 120 5 Guido Qt support X!ÛÛÛÛÛ = 120 = 120 & 44 _X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ E!ÛÛÛÛÛÛ ‹_X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ E!ÛÛÛÛÛÛ ‹ X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ XX!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ ‹ X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ E!ÛÛÛÛÛÛ ‹ Qt is a cross-platform application development framework[14],widelyusedforthedevelopment of GUI programs1. & _X!ÛÛÛÛÛÛ _X!ÛÛÛÛÛÛ E!ÛÛÛÛÛÛ ‹_X!ÛÛÛÛÛÛ _X!ÛÛÛÛÛÛ E!ÛÛÛÛÛÛ ‹ X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ ‹ X!ÛÛÛÛÛÛ X!ÛÛÛÛÛÛ _E!ÛÛÛÛÛÛ \ 5.1 GuidoQt classes A set of classes has been developed to use the Guido library with Qt; they are organized in 3 Figure 4: Bounding rects of a score elements layers (figure 5): The Guido library provides a specific API to • low level: GDeviceQt, GFontQt & GSys- querythescoremapandtoretrieveelementsby temQt: Qt implementation of the Virtual type, position and date. Graphic System 4.6 The Virtual Graphic System • middle level: QGuidoPainter: a class that The virtual graphic system is intended as an uses GDeviceQt, GFontQt & GSystemQt, abstract layer covering platform dependencies and offers a higher-level interface at graphic level. It represents a set of abstract classes adressing the basic needs of an applica- • high level: ready-to-use Qt classes that tion: printing text, drawing on the screen or uses the QGuidoPainter to parse and draw offscreen, etc. The set of abstract classes in- Guido scores: cludes: – QGuidoWidget, a QWidget • a VGDevice class: specialized on drawing – QGuidoSPageItem & QGuidoM- onscreen or offscreen PageItem, two QGraphicsItem • a VGFont class: to cover fonts management displaying, respectively, one score’s page at a time, and all the pages • a VGSystem class: to cover allocation of specific VGDevice and VGFont objects. – Guido2Image, to export Guido scores to various image formats This set of classes is implemented for different target platforms: support is provided for GDI 1see: http://www.qtsoftware.com (c) Kai Renz, musical data taken from MuseData database and automatically converted to GUIDO Qt Library QGraphicsItem QWidget High level QGuidoMPageItem QGuidoSPageItem QGuidoWidget Guido2Image QGuidoItem Mid level QGuidoPainter Low level GSystemQt GDeviceQt GFontQt Figure 5: GuidoQt class diagram Here is a short example using the #include <QApplication> QGuidoPainter that shows how to export #include "QGuidoWidget.h" a Guido score to an image: #include "QGuidoPainter.h" int main(int argc, char *argv[]) #include <QApplication> { #include <QPainter> QApplication app(argc, argv); #include <QImage> #include "QGuidoPainter.h" // Guido Engine initialization int main(int argc , char* argv[]) QGuidoPainter::startGuidoEngine(); { QApplication app( argc , argv ); // Create a QGuidoWidget... QGuidoWidget w; //Guido Engine initialization //...and give it some Guido Music Notation QGuidoPainter::startGuidoEngine(); w.setGMNCode( "[e d c]" ); w.show(); //Create a QGuidoPainter... QGuidoPainter* p = QGuidoPainter::create(); // That’s it ! //...and give it some Guido Music Notation int result = app.exec(); p->setGMNCode( "[c/8 d e g e d c]" ); // Destroy the Guido Engine resources //Get the size of the score’s first and only page QGuidoPainter::stopGuidoEngine(); int pageIndex = 1; return result; QSizeF s = p->pageSizeMM( pageIndex ); } 5.2 The Guido Scene Composer //Create a blank image, using the size of the score QImage image(s.toSize()*10 , QImage::Format_ARGB32); The GuidoSceneComposer is a graphic IDE for image.fill( QColor(Qt::white).rgb() ); Guido,allowingtomanipulateGuidoscoresin //Draw the score with the QGuidoPainter, via QPainter.a graphic scene. QPainter painter( &image ); 5.2.1 A Guido Music Notation learning p->draw( &painter , pageIndex , image.rect() ); tool QGuidoPainter::destroyGuidoPainter( p ); The GuidoSceneComposer is an effective envi- //Destroy the Guido Engine resources ronment to learn the GMN: QGuidoPainter::stopGuidoEngine(); • whentypingGMN,thecorrespondingscore image.save( "myScore.png" ); is instantly updated, making it very simple return 0; to try different notations; } And here is another example showing how to • a help palette (figure 6) lists a large as- display a Guido Score using a QGuidoWidget: sortment of Guido expressions and tags, so that no external documentation is nec- 6 Conclusions essary; Based on the Guido Music Notation for- • the GMN text editor uses a synthax high- mat, the GuidoLib is a unique open source, lighter, for a clearer GMN reading; platform-independant library, for embedding score rendering into a standalone application. • import MusicXML and MuseData (limited The recent support of the widely-used cross- support) scores; platform Qt library makes it even more accessi- • export the Guido scores to a pdf or an im- ble to software developers. Inthefuture, weplantoextendthegraphical age. possibilities of the GuidoSceneComposer giv- ing to users more drawing tools; it would then become an interesting application to create ex- tended modern music scores. Support of im- port/export in other common music score for- mats is also among our concerns. Finally,weplantoaddscorecompositionfea- tures, like putting scores in sequence or in par- allel, cutting the head, the tail, the top or the bottom voices of a score, transposition, or du- ration change, using an homogeneous approach, where scores are both the target and the argu- ment of the operations. Figure 6: The Guido Help palette TheGuidolibraryisavailableonSourceforge at http://guidolib.sourceforge.net 5.2.2 A score graphic composer The GuidoSceneComposer allows to you to References compose graphic scenes with different scores: [1] David A. Gomberg. A Computer-Oriented System for Music Printing. In Computers • move, resize, copy & paste the scores, to and the Humanities, volume 11, pages 63– createagraphicallycomplexmusicalscene, 80. Pergamon Press, 1977. • importvariousformatsofpicturestoenrich [2] Donald Alvin Bird. Music Notation by the scene, Computer. PhD thesis, Indiana University, • add textual annotations, 1984. • export the scene to an image or a pdf. [3] John S. Gourlay, A. Parrish, D. Roush, F. Sola, and Y. Tien. Computer For- matting of Music. Technical report OSU- CISRC-2/87-TR3, Department of Com- puter and Information Science, The Ohio State University, 1987. [4] E. Selfridge-Field. DARMS, Its Dialiects, and Its Uses. In Beyond MIDI, The hand- book of Musical Codes., pages 163–174. MIT Press, 1997. [5] Smith Leland. SCORE. In Beyond MIDI, The handbook of Musical Codes., pages 252–280. MIT Press, 1997. [6] Walter B. Hewlett. MuseData: Multipur- pose Representation. In Selfridge-Field E., editor,BeyondMIDI,ThehandbookofMu- Figure 7: The Guido Scene Composer sical Codes., pages 402–447. MIT Press, 1997. [7] Assayag G. and D. Timis. A ToolBox for Music Notation. In Proceedings of the In- ternational Computer Music Conference, pages 173–178, 1986. [8] Bill Schottstaedt. Common Music Nota- tion. In Selfridge-Field E., editor, Beyond MIDI, The handbook of Musical Codes., pages 217–222. MIT Press, 1997. [9] Mika Kuuskankare and Michael Laurson. ENP - Music Notation Library based on Common Lisp and CLOS. In Proceedings of the International Computer Music Con- ference, pages 131–134. ICMA, 2001. [10] Han-Wen Nienhuys and Jan Nieuwen- huizen. LilyPond, a system for automated musicengraving. InProceedings of the XIV Colloquium on Musical Informatics (XIV CIM 2003), May 2003. [11] HoosH., HamelK.A., RenzK., andKilian J. The GUIDO Music Notation Format - a Novel Approach for Adequately Represent- ingScore-levelMusic. InProceedings of the International Computer Music Conference, pages 451–454. ICMA, 1998. [12] H. H. Hoos and K. A. Hamel. The GUIDO Music Notation Format Specification - ver- sion 1.0, part 1: Basic GUIDO. Techni- calreportTI20/97,TechnischeUniversitat Darmstadt, 1997. [13] Kai Renz. Algorithms and Data Struc- tures for a Music Notation System based on GUIDO Music Notation. PhD thesis, Technischen Universit¨at Darmstadt, 2002. [14] Jasmin Blanchette and Mark Summerfield. C++ GUI Programming with Qt 4 (2nd Edition). Prentice Hall, 2008.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.