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