The Guido Engine a Toolbox for Music Scores Rendering
Total Page:16
File Type:pdf, Size:1020Kb
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 fdaudin, fober, letz, [email protected] Abstract music notation. Since MusiXTEX is powerful but hard to learn, preprocessors such as PMX The Guido Music Notation format (GMN) is a gen- eral purpose formal language for representing score and M-Tx have been designed to facilitate mu- level music in a platform independent plain text and sic input and layout. A more recent initiative is human readable way. Based on this music repre- Lilypond [10], an open source software partially implemented in the language Scheme, its input sentation format, the GuidoLib provides a generic, portable library and API for the graphical render- music representation format is simple and intu- ing of musical scores. This paper gives an intro- itive, it includes automatic layout capabilities. duction to the music notation format and to the Both systems produce PostScript, EPS or PDF files. Guido graphic score rendering engine. An exam- ple of application, the GuidoSceneComposer, is next Based the Guido Music Notation format, presented. the GuidoLib project is a open source, cross- platform C/C++ library that provides score Keywords layout and rendering capabilities to its client ap- plications. The music notation format is very Guido, Music notation, score layout. close to the Lylipond format. The GuidoLib 1 Introduction mainly differs from the compilers approach in 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 along with a concrete example of Guido-Qt ap- 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] has been designed by H. Hoos and K. Hamel [7]. However, very few systems have reached more than ten years ago. It is a general pur- maturity: the Common Music Notation system pose formal language for representing score level [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] introduced another promising ap- 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 { Basic Guido notation covers the representation [\staff<1> \stemsUp \meter<"2/4"> \beam(g2/32 e/16 c*3/32) c/8 of notes, rests, accidentals, single and multi- \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, stem directions, 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 same semantic than the music notation. When Û Û Û Û Û Û Û Û Û Û Ûj Û Û Û Û Û Û Ûj Û Û Û enum or denom is omitted, it is assumed to be 2 X! X!Û Û Û Û Û X!Û X! X!Û Û X!Û Û X!Û X! 4 X" X!. X!X" X!Û X! ÚX" ÚX" X!Û. ÚX" X!Û X" ÚX" 1. The duration represents a whole note frac- & Ú ÚX" Ú ÚX" ÚX" Ú ‹ Ú ÚX" Ú ÚX" Ú Ú \ tional. Ú Ú Ú Ú Ú Ú Ú Ú Ú Ú Ú Ú When omitted, optional note description Û Û Û X!Û Û X!Û _X"!Û parts are assumed to be equal to the previous 2 ÚX" ÚX"!Û ÚX" Ú specification before in the current sequence. ? 4 Ú Ú ‹ Ú \ Chords are described using comma separated notes enclosed in brackets e.g fc, e, gg Figure 2: A multi-voices example 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 \tagname<param-list> 3 The Guido Engine 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) \tagname<param-list>(note-series) shaped under the form of a portable library and The following GMN code illustrates the con- became an open source project in 2002, cov- 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 4 x x x x Abstract Representation (GAR). This represen- 4 x x x XÛx XÛx tation is transformed step by step to produce & _XÛx XÛx XÛ \ 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 • GAR to GAR transformations which repre- A note sequence is of the form [tagged-notes] sents a logical layout transformation: part where tagged-notes is a series of notes, tags, of the layout (such as beaming for example) and tagged ranges separated by spaces. Note may be computed from the GAR as well as sequences represent single-voiced scores. Note segments represent multi-voiced scores; they are expressed in GAR, denoted by {seq-list} where seq-list is a list of note sequences separated by commas as • the GAR is converted into a Guido Seman- shown by the example below: tic Normal Form (GSNF). The GSNF is a 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 4.1 Score layout The Guido Engine may be feeded with com- 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.