SourceForge.net Logo

1.2. A very simple introductory score

Let's see how a very simple score is encoded. The score will be just one measure, in G clef, time signature will be C major (no accidentals) and time signature will be 4 by 4. The measure will have a whole c note. Here is how it would look:

In LDP this score is described as follows:

  (score
     (vers 1.5)
     (instrument
        (musicData
            (clef G)
            (key C)
            (time 4 4)
            (n c4 w)
            (barline)
        )
     )
  )

Let's analyse this code. First note that in LDP all the information is structured as elements. An element is a list of keywords and data values enclosed in parenthesis. An element always starts with a keyword (i.e. vers) and it is followed by data items. These data items can be just simple data (single word values, such as '1.5' or 'G') or complex data: other elements -- those of you with an information science background will note that this is a LISP like syntax --

In the example, we can note that all the score is a list starting with the keyword 'score'. The first data item of this element is also a list, '(vers 1.5)': it starts with the keyword 'Vers' and has only a simple data item, the number 1.5.

Blank space, indentation, tabs and line breaks have no meaning: they are just a visual help for humans to improve readability, and you can use them at your desire or not use them at all. For example, the previous score can be written in a single line as:

(score (vers 1.5)(instrument (musicData ( ... ))

Or in two lines, for example as:

(score (vers 1.5)(instrument
(musicData ( ... ))

The only rule is that you can not break keywords or simple data values. So you can not write, for example,

( s c o r e ( ...))

LDP language is case sensitive, so for example, "score", "Score" and "SCORE" will not be taken as the same token.

To reduce the work for typing a score or to improve legibility in some cases an abbreviated syntax is allowed. This abbreviation consists on either:

  • For elements with just one parameter, the syntax "(name param)" can be also written as "name:param". For example, the following element
        (title right "Franz Schubert" (x 40mm)(y 30mm))
        
    can also be written as:
        (title right "Franz Schubert" x:40mm y:30mm)
        
  • For elements with more than one parameter or often used, in certain cases it is allowed an abbreviated syntax, consisting, usually, in suppressing the parenthesis and reducing the element to a string. For example, in case of element g, beamed group, writing (g +) is equivalent to writing just g+, or in case of element t, tuplet, writing (t + 5 6) is equivalent to writing just t5/6.