]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/language.pod
release: 0.0.39-1
[lilypond.git] / Documentation / language.pod
1 =head1 NAME
2
3 language.pod -- state of the art mudela-vapourware.
4
5 =head1 SYNOPSIS
6
7 (damn pod)
8
9 =head1 DESCRIPTION
10
11 here are some thoughts on the language. Most of the examples are in
12 pseudo current mudela.  Some stuff gratuitously taken from your mails.
13
14 =head1 NOTE
15
16 I dislike vapourware. That's why I oppose to concrete plans on how to
17 do input for features we don't know how to produce on paper 
18
19 =head1 AIM
20
21 A musical notation that is relatively easy to comprehend to both
22 programmers and non programmers. The final aim is to be able to
23 express what can be expressed in sheet music.
24
25 =over 5
26
27 =item *
28 play pieces
29
30 =item *
31 typeset the pieces
32
33 =back
34
35 further requirements:
36
37 =over 5
38
39 =item *
40 Possible to edit the layout without danger of changing the
41 original music. (fingerings, interpretation)
42
43 =item *
44 Simple music manipulations, such as transposing, creating a
45 score for individual instruments as well as for the conductor,
46 extracting short pieces from a longer one, glueing several shorter
47 pieces into a single score.
48
49 =back
50
51 Pieces could be:
52
53
54 =over 5
55
56 =item *
57 Mahlerian orchestral score
58
59 =item *
60 piano pieces
61
62 =item *
63 pop songs (lyrics + chords)
64
65 =item *
66 gregorian chant (?)
67
68 =item *
69 bach multivoice organ music.
70
71 =item *
72 short excerpts to be used in musicological publications.
73
74 =back
75
76 =head1 REQUIREMENTS
77
78 =head2 Parser output 
79
80 When I say LilyPond input, I mean the final output of the parsing
81 step, which should be roughly the same as it is now: hierarchically,
82 using pseudo syntax
83
84         Score {
85                 Midi_def
86                 Paper_def
87                 Staff [multiple] {
88                         Voices
89                         Stafftype
90                         (instrument)
91                 }
92         }
93
94
95 Voice should stay the same:
96
97         Voice {
98                 Voice_elements 
99         }
100
101 and
102
103         Voice_elements {
104                 requests
105         }
106
107
108 =head2 Staffs
109
110 We definitely need the concept of staff in the parser output, because
111 it is fundamental to LilyPond.  I think the input language should
112 allow the user to do something like:
113
114         melody = { c d e f g }
115
116         %At this time I can't think of more than these stafftypes
117         staff { gregorian music { melody } }
118         staff { pianostaff music { melody } }
119         staff { melodic music { melody } }
120         staff { rhythmic music { melody } }
121         staff { lyric music { melody } }        % silly, i admit.
122
123 The staff could also define what the instrument would be (both in
124 print and in MIDI)
125
126 Moreover, if music {} in score equals staff, then how do we do multiple
127 voices on one staff?
128
129 We might be able to do without the staff{} construct, but I doubt if
130 it will make things easier.
131
132 =head1 THOUGHTS
133
134 =head2 Typing
135
136 It is difficult to make mistakes with typing now because you have to
137 tell LilyPond what it is dealing with
138
139         staff { identifier }
140
141 versus
142
143         staff { music { identifier } }
144
145 I'm not sure on dropping this, I'm afraid it will make the language
146 less legible. Technically, dropping it is not very difficult (it will
147 introduce slight parser-source bloat)
148
149 What if the staff is extended to have some more blocks, all of which
150 can be declared? Like the score now:
151
152         score {
153                 a_staff_id
154                 a_midi_id
155                 a_paper_id
156                 a_command_id
157         }
158
159 This will only be readable if the Mudela-user rigidly uses hungarian,
160 which he/she won't.
161
162 =head2 Backslash
163
164 I like it. Let's keep it in the language if we need it, it's a
165 universally accepted escape sequence.
166
167 =head2 Braces
168
169 I like the idea of <> vs. {}. Not because I think it is more clear,
170 but I dislike the word "music", I can't seem to find the proper word
171 for what "music" currently does, so I'd like to flush it.
172
173 I would like to point that both <> and {} are indicating a
174 hierarchy. I think, we should continue to allow them to nest. I still
175 have no preference what to use for what.
176
177 =head2 Command syntax
178
179 Braces on commands are here now, because the {} are the only nesting
180 braces.  We need to avoid that, since the brace is overused as it
181 is. We don't like lisp that much. (the key is the only commands which
182 really needs {} now)
183
184 How about
185
186         \bar "some args", "some more";
187
188 (note the ; ), which is a mix of perl and TeX.
189
190 Of course \key should take a \notename. In fact, I think we should
191 program the note intervals (which are now hardcoded for midi purposes)
192 To allow adaptation to other scales.
193
194 As simple fix, we might do key declarations:
195
196         \keybes= \key { bes es }
197
198         \key{\keybes}
199
200
201
202 [LOOSE THOUGHT]
203
204 We might drop this {} argument altogether, by merely enforcing
205 that each "statement" (music,score,staff,chord) takes a LIST as
206 argument, and use the {} to group lists. This is admittedly perl. This
207 is very sketchy.
208
209
210 =head2 Requests
211
212 I want to give the user some access to the internals. Technically,
213 walkers/registers will happily typeset voices which mix lyrics and
214 notes, which combine stem requests and lyricreqs. I want to have a
215
216         \request { melodic name = 5, acc = -10
217                 rhythmic ball=4 dots 2, lyric = "foobar" }
218
219 type of syntax. This is the most flexible input format possible, since
220 any valid LilyPond input can be made. This strongly implies tying
221 mudela to LilyPond. That I don't mind, but it hampers
222 portability. Suppose some commercial systems want to read mudela
223 too.
224
225 =head2 Lexer modes
226
227 the $ and @ were quick hacks, which suck badly. Replacing it by a
228 mechanism that switches the lexer automatically would be better, but
229 it is still error prone, and it hurts uniformity. What I would like
230 best is unified syntax, but this seems impossible since lyrics could
231 clash with notenames. If possible it would simplify the parser, the
232 scanner, and the explanation of the language.
233
234 What about:
235
236         bes c d e f     % notes
237         'bes- sen sap   % some lyric syllables
238
239 We can make one of the ' ` " a lyric-indication, but then we would
240 have to change the octave indication, eg.
241
242         _bes % lower
243         ^bes % higher
244
245 or
246
247         +bes % higher
248         -bes % lower
249
250 And I am still not sure if it would be possible now, but I think this
251 is worthwile to investigate. Or we could replace @ by a
252 quote (take your pick) sign, which is a lot more intuitive. 
253
254 The big question remaining is: do we want to add any more modes than
255 lyric and note?
256
257
258 [LOOSE THOUGHT]
259
260 Even looser ideas: we can take a look at the perl wagon. It has numerous
261 inputmodes. What about:
262
263         lyric << ENDLYRIC
264
265         bes- sen- sap
266
267         ENDLYRIC
268
269         music << ENDMUSIC
270
271         c d e f g
272
273         ENDMUSIC
274
275
276 [LOOSE THOUGHT]
277
278 If we free up $ @ from their current meaning, $ and @ could be used to
279 signify other things.
280
281 =head2 Concrete solution to lyric vs. note
282
283 I think
284
285         "lyric"
286
287 is a valid lyric too. This implies that any bare string is checked if
288 it is a note. Now it prints an error if not, but I could change it to
289 assume it is a STRING (and can be reduced to lyric). Heck! I could
290 implement this tonight. We'd lose one mode!  (after checking lexer
291 source) the only problem is preventing puctuation and the - and _ from
292 clashing with script symbols.
293
294
295 =head2 Command placement:
296
297 Mats is an arduous fan of having the commands inside music. I am
298 not. I see the Mudela music as something which can be plugged into
299 different staffs, transposed, translated in time, copied, quoted,
300 etc. Encouraging "inline" commands would be bad since they hinder this
301 reuse of typed music.
302
303 The way I figure it, the bad part is essentially counting
304 bars/wholes. Maybe we can get rid of it, by reinstalling the "mark"
305 commands.
306
307 I definitely want  to avoid complicated logic  ("Hey there is  another
308 bar request, should we merge this bar with another staff's", this kind
309 of "smartness" makes a  lot M$ software inconsistent) inside LilyPond,
310 by making the input unambiguous in this respect.
311
312 There is another complication: some symbols (bars) sometimes are
313 linked across staffs. I should first think of a way to do this in
314 LilyPond, before even considering a syntax.
315
316
317 =head2 Volta
318
319 uhh?
320
321 =head2 Numbers
322
323 The syntax of /, * and : has to be settled, we have
324
325         - notes (1, 2, 4, 8 etc)
326         - meter 2*4
327         - plet 2/3
328         - multiple notes: 3*4
329         - abbreviations (not implemented)  c4/4 or c4*4
330
331 =head2 Filtering
332
333 This is a idea of mine: we could filter some request types from
334 voices,
335
336 eg:
337
338         \mel1 = \music { c-. d-. e-. f-. \meter {2*4} g-. a-. b.- c-. }
339
340         \m1 = \filter { "script_req" \mel1 }
341         \m2 = \filter { "command_req" \mel1 }
342         \m3 = \filter { "melodic_req" \mel1 }
343         \m3 = \filter { ("rhythmic_req") && (!"lyric_req") &&
344                 ("stem_req" || "beam_req") \mel1 }
345                 % syntax needs change. Clash with () slur?
346
347         \mel2 = \music { c c g  g a a g2 }
348
349         \combined = \merge { \m1, \mel2  }
350
351 This means m1 contains the scripts, of \mel, \m2 only the meter
352 command surrounded by (essentially) some skips, and \m3 the notes
353 without scripts or meters. This could be a solution to the "command in
354 music vs. command with skip".
355
356 Combined with merging of requests, this would be a powerful tool. In
357 this example \combined is a combination of melody mel2 and the accents
358 of \mel1.
359
360 This idea is for advanced users, but it would come in handy in urtext
361 editions:
362
363         include "mozart-horn.ly"
364
365         \m1 = \merge { \urmozart + \dennisbrain_interpretation }
366         \m2 = \merge { \urmozart + \barrytuckwell_interpretation }
367
368
369 =head2 Proposed operators:
370
371 Just ideas:
372
373         || && !         filter syntax 
374         ++              concatenation of voices
375         +               merging of voices
376
377
378 =head2 C++ OOP like input.
379
380 I don't see the big win of this.
381
382         score sc1= melody;
383         sc1.staff{\verse};
384         sc1.staff{<\b1 \b2>}
385         sc1.paper=mypaperdef;
386
387
388 We're not doing a programming language. In this syntax the parser has
389 to lookup what sc1 means, decide if it should copied shallow/deep,
390 decide if has a staff block, switch the mode after it finds that staff
391 takes music. May be I'm just ranting, but it looks hairy to
392 me. Remember that at this stage we're just filling structs.
393
394 In a distant future there might be a need for programming (are you
395 listening, Philip Glass?), but I think that would be something for
396 Mudela version 3. And I think using m4 (or something alike) would be
397 just as convenient.
398
399 =head2 Transposition
400
401 Has to be done. How about:
402
403         \transpose { \from c \to g \music { ... }} 
404
405 =head2 Quoting
406
407 Difficult. Hmm...
408
409         \oboe = \music { ........................ }
410
411         \oboefragment = \extract { \from 5*2 \to 6*2 \music { \oboe } }
412
413