]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/hu/learning/fundamental.itely
Merge branch 'web-experimental' into lilypond/translation
[lilypond.git] / Documentation / hu / learning / fundamental.itely
1 @c -*- coding: utf-8; mode: texinfo; documentlanguage: hu -*-
2 @c This file is part of learning.tely
3 @ignore
4     Translation of GIT committish: 48c2b169dc8a9bc2ab2c767cbb83b57cc158742b
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  For details, see the Contributors'
8     Guide, node Updating translation committishes..
9 @end ignore
10
11
12 @c -*- coding: utf-8; mode: texinfo; -*-
13 @c \version "2.13.36"
14 @node Alapfogalmak
15 @chapter Alapfogalmak
16 @translationof Fundamental concepts
17 @translationof Fundamental concepts
18
19 Miután megtanultuk, hogyan állíthatunk elő gyönyörű kottákat egyszerű szöveges
20 fájlokból, ebben a szakaszban megismerjük azokat a fogalmakat és technikákat,
21 amelyek segítségével hasonlóan gyönyörű, de bonyolultabb kottákat készíthetünk.
22
23 @menu
24 * Hogyan működnek a LilyPond bemeneti fájlok?::
25 * A szólamok zenét tartalmaznak::
26 * Kontextusok és ábrázolók::
27 * A sablonok kibővítése::
28 @end menu
29
30 @node Hogyan működnek a LilyPond bemeneti fájlok?
31 @section Hogyan működnek a LilyPond bemeneti fájlok?
32 @translationof How LilyPond input files work
33 @translationof How LilyPond input files work
34
35 A LilyPond bemeneti formátuma meglehetősen rugalmas, így a tapasztalt
36 felhasználóknak nagy szabadságot ad abban, hogyan strukturálják a
37 forrásfájljaikat. Azonban ez a rugalmasság az újdonsült felhasználók számára
38 bonyolult lehet. Ez a szakasz elmagyarázza a struktúra nagy részét, az
39 egyszerűség kedvéért bizonyos részleteket elnagyolva. A bemeneti formátum
40 felépítésének teljes leírása a @ruser{File structure} c. szakaszban olvasható.
41
42 @menu
43 * Bevezetés a LilyPond fájlok szerkezetébe::
44 * A kotta egy összetett zenei kifejezés::
45 * Zenei kifejezések egymásba ágyazása::
46 * A gerendák és ívek átfedhetik egymást::
47 @end menu
48
49 @node Bevezetés a LilyPond fájlok szerkezetébe
50 @subsection Bevezetés a LilyPond fájlok szerkezetébe
51 @translationof Introduction to the LilyPond file structure
52 @translationof Introduction to the LilyPond file structure
53
54 @c index bemeneti formátum
55 @c index fájlstruktúra
56
57 A LilyPond bemeneti fájlok szerkezetére egy tipikus példa:
58
59 @example
60 \version @w{"@version{}"}
61
62 \header @{ @}
63
64 \score @{
65   @var{...összetett zenei kifejezés...}  % ide jön a zene!
66   \layout @{ @}
67   \midi @{ @}
68 @}
69 @end example
70
71 @noindent
72 Ennek az alapvető mintának sok változata lehetséges, de ez a példa jó
73 kiindulási alapot jelent.
74
75 @funindex \book
76 @funindex book
77 @funindex \score
78 @funindex score
79 @cindex book
80 @cindex score
81
82 Eddig egyik példa sem használta a @code{\score@{@}} parancsot. Ennek oka, hogy
83 a LilyPond automatikusan hozzáadja az egyszerű bemenethez a szükséges
84 parancsokat. A következő bemenet például:
85
86 @example
87 \relative c'' @{
88   c4 a d c
89 @}
90 @end example
91
92 @noindent
93 a következő rövidítése:
94
95 @example
96 \book @{
97   \score @{
98     \new Staff @{
99       \new Voice @{
100         \relative c'' @{
101           c4 a b c
102         @}
103       @}
104     @}
105     \layout @{ @}
106   @}
107 @}
108 @end example
109
110 Más szóval, ha a bemenet egyetlen zenei kifejezést tartalmaz, a LilyPond úgy
111 értelmezi a fájlt, mintha a zenei kifejezés körül már szerepelnének a fenti
112 parancsok.
113
114 @cindex implicit kontextusok
115
116 @strong{Figyelem!} A dokumentációban sok példa nem tartalmazza a
117 @code{\new Staff} és @code{\new Voice} parancsokat, így azok implicite kerülnek
118 létrehozásra. Ez egyszerű példáknál jól működik, de bonyolultabb esetekben,
119 főleg, ha más parancsokat is használunk, a kontextusok implicit létrehozása
120 meglepő kimenetet eredményezhet, például nemkívánatos kottasorok jelenlétét.
121 A kontextusok explicit megadásának módja a @ref{Kontextusok és ábrázolók} c.
122 részben olvasható.
123
124 @warning{Többszólamú zeneművek esetén ajánlott explicit módon létrehozni a
125 kottasorokat és az azon belüli szólamokat.}
126
127 Egyelőre térjünk vissza az első példánkhoz, és vizsgáljuk meg csak a
128 @code{\score} parancsot.
129
130 A @code{\score} blokkon belül először pontosan egy zenei kifejezésnek kell
131 következnie.
132 Emlékezzünk arra, hogy egy zenei kifejezés lehet egy hang is, de akár
133 egy olyan nagy összetett kifejezés is, mint:
134
135 @example
136 @{
137   \new StaffGroup <<
138     @var{...egy teljes Wagner-opera zenei anyaga...}
139   >>
140 @}
141 @end example
142
143 @noindent
144 Mivel mindez egy @code{@{ ... @}} blokkban szerepel, egy zenei
145 kifejezésnek számít.
146
147 Ahogy korábban láttuk, a @code{\score} blokk a zenén kívül más definíciókat is
148 tartalmazhat, mint például:
149
150 @example
151 \score @{
152   @{ c'4 a b c' @}
153   \header @{ @}
154   \layout @{ @}
155   \midi @{ @}
156 @}
157 @end example
158
159 @funindex \header
160 @funindex header
161 @funindex \layout
162 @funindex layout
163 @funindex \midi
164 @funindex midi
165 @cindex header
166 @cindex layout
167 @cindex midi
168
169 @noindent
170 Ez a három parancs -- @code{\header}, @code{\layout} és @code{\midi} --
171 speciális: az eddigi parancsokkal ellentétben @emph{nem} zenei kifejezések, és
172 nem azok részei. A @code{\score} blokkon belül vagy kívül is elhelyezkedhetnek
173 -- például a @code{\header} (fejléc) blokk, melyben a kotta adatait (pl. cím,
174 szerző stb.) lehet megadni, legtöbbször a @code{\score} parancs előtt szerepel,
175 ahogy a szakasz elején található példában is látható.
176
177 A két további, még ismeretlen parancs: @code{\layout @{@}} és
178 @code{\midi @{@}}. Ezek ebben a formában rendre azt jelentik, hogy a LilyPond
179 kottaképet, ill. hangzó anyagot állítson elő. Teljes leírásuk a Kottaírás
180 Kézikönyvében található, a @ruser{Score layout} és a
181 @ruser{Creating MIDI files} szakaszokban.
182
183 @cindex több kotta
184 @cindex implicit book blokk
185 @funindex \book
186 @funindex book
187
188 Egy fájlban több @code{\score} blokk lehet. Mindegyik egy-egy zeneművet
189 vagy tételt jelöl, de ezek egy kimeneti fájlban fognak megjelenni. Nem
190 szükséges @code{\book} blokkba foglalni őket -- ez implicite megtörténik.
191 Ha azonban több kimeneti fájlt szeretnénk kapni egy forrásfájlból, akkor több
192 @code{\book} blokkot kell megadnunk -- kimeneti fájlonként egyet-egyet.
193
194 Összegezve:
195
196 Minden @code{\book} blokk külön kimeneti fájlt eredményez (pl. egy-egy PDF
197 állományt). Ha nem szerepel explicit módon a forráskódban, akkor a LilyPond
198 körülveszi az egész forráskódot egy @code{\book} blokkal.
199
200 Egy @code{\book} blokkon belül minden @code{\score} blokk különálló zenei
201 egységet jelöl.
202
203 @cindex layout blokk helye
204
205 Minden @code{\layout} blokk arra a @code{\score} vagy @code{\book} blokkra
206 érvényes, amelyben szerepel -- tehát egy @code{\score} blokkon belüli
207 @code{\layout} blokk csakis arra az egy @code{\score} blokkra vonatkozik,
208 de egy @code{\score} blokkon kívüli @code{\layout} blokk a @code{\score}
209 blokkot tartalmazó (akár explicit, akár implicit) @code{\book} blokkon belüli
210 minden @code{\score} blokkra érvényes.
211
212 A részletek a @ruser{Multiple scores in a book} c. részben olvashatók.
213
214 @cindex változók
215
216 Fájljainkat áttekinthetőbbé tehetjük változók definiálásával (ld.
217 @ref{Művek szervezettebbé tétele változók segítségével}). Minden sablonban ezt
218 a módszert használjuk:
219
220 @example
221 dallam = \relative c' @{
222   c4 a b c
223 @}
224
225 \score @{
226   \dallam
227 @}
228 @end example
229
230 Amikor a LilyPond feldolgozza ezt a fájlt, a @code{dallam} változó értékét
231 (azaz mindent az egyenlőségjel utáni zenei kifejezésből) beszúrja mindenhova,
232 ahol @code{\dallam} hivatkozást lát. A változók nevére nincs sok megkötés -- a
233 következők mind helyes példák:  @code{dallam}, @code{jobbkéz}, @code{fuvola},
234 @code{BII} stb. A @ref{Kevesebb gépelés változókkal és függvényekkel} c.
235 szakasz további információkat tartalmaz. Mindössze annyi a korlátozás, hogy a
236 változónevek csak betűket tartalmazhatnak, és nem ütközhetnek a
237 LilyPond parancsok neveivel. A pontos szabályok a @ruser{File structure} c.
238 részben vannak leírva.
239
240 @seealso
241 A bemeneti formátum teljes definíciója a
242 @ruser{File structure} c. szakaszban található.
243
244 @node A kotta egy összetett zenei kifejezés
245 @subsection A kotta egy összetett zenei kifejezés
246 @translationof Score is a (single) compound musical expression
247 @translationof Score is a (single) compound musical expression
248
249 @funindex \score
250 @funindex score
251 @cindex score
252 @cindex összetett zenei kifejezés
253
254 Az előző szakaszban (@ref{Bevezetés a LilyPond fájlok szerkezetébe}) már láttuk
255 a LilyPond fájlok általános felépítését. De a legfontosabb részt mintha
256 átugrottuk volna: mi kerüljön a @code{\score} blokk belsejébe?
257
258 Valójában ez sokkal egyszerűbb, mint gondolnánk. Ez a mondat mindent
259 megmagyaráz:
260
261 @quotation
262 @emph{A @code{\score} blokknak egy összetett zenei kifejezéssel kell
263 kezdődnie.}
264 @end quotation
265
266 @noindent
267 Az összetett zenei kifejezés fogalmát már tisztáztuk
268 @ref{A zenei kifejezés fogalma} c. részben. Láttuk, hogy építhetünk fel nagy
269 zenei kifejezéseket kis részekből -- először hangokból, aztán akkordokból stb.
270 Most egy összetett zenei kifejezést vizsgálunk meg felülről lefelé. Az
271 egyszerűség kedvéért egy zongorakíséretes dal lesz a példánk. Először is
272 szükségünk van az énekes és a zongorista szólamára.
273
274 @example
275 \score @{
276   <<
277     \new Staff = "ének" <<
278     >>
279     \new PianoStaff = "zongora" <<
280     >>
281   >>
282   \layout @{ @}
283 @}
284 @end example
285
286 Elneveztük a két szólamot @qq{ének} és @qq{zongora} néven. Ez nem kötelező,
287 de jó szokás, hogy első pillantásra lássuk, melyik szólam mire szolgál.
288
289 Emlékezzünk arra, hogy @code{<< ... >>} szolgál több szólam jelölésére. Ennek
290 hatására az ének- és a zongoraszólam egymás alatt fog megjelenni a kottában.
291 A zongoraszólam két kottasort fog tartalmazni, az énekszólam pedig egy
292 kottasort és egy dalszöveget, így mindkettőhöz @code{<< ... >>} blokk kell.
293 A dalszöveghez az @code{\addlyrics} parancsot fogjuk használni. Ha szükséges
294 feleleveníteni, az @ref{Egyszerű dalok kottázása} c. részben olvashatunk róla.
295
296 @lilypond[verbatim,quote,ragged-right]
297 \score {
298   <<
299     \new Staff = "ének" <<
300       \new Voice = "dallam" { c'1 }
301       \addlyrics { Szólt }
302     >>
303     \new PianoStaff = "zongora" <<
304       \new Staff = "jobbkéz" { c'1 }
305       \new Staff = "balkéz" { c'1 }
306     >>
307   >>
308   \layout { }
309 }
310 @end lilypond
311
312 Most megvan a teljes struktúra. Az énekszólam egy @code{Voice} kontextust
313 tartalmaz a hangoknak, és egy strófányi dalszöveget. A zongoraszólam pedig
314 a jobb- és balkéz kottasorait tartalmazza.
315
316 Most elkezdhetjük kitölteni a hangokat. Elkezdhetnénk közvetlenül a Voice
317 kontextus belsejébe beleírni, hogy:
318
319 @example
320 \relative c'' @{
321   r4 d8\noBeam g, c4 r
322 @}
323 @end example
324
325 De ha ezt tennénk, a @code{\score} blokk nagyon bonyolult lenne, és nem lehetne
326 átlátni a szólamok szerkezetét. Így érdemes változókat használni. A dalszöveg
327 változóként való megadására a @code{\lyricmode} parancsot kell használni, hogy
328 a LilyPond dalszövegként és ne hangokként értelmezze a változó tartalmát.
329 (A dalszöveg egy külön beviteli mód, ezekből még több is van, ld. az
330 @ruser{Input modes} c. részt.)
331
332 Tehát miután definiáltuk a megfelelő változókat, hivatkoztunk rájuk, és
333 basszuskulccsal láttuk el a balkezet, kész egy valódi mű kezdete:
334
335 @lilypond[verbatim,quote,ragged-right]
336 dallam = \relative c'' { r4 d8\noBeam g, c4 r }
337 dalszöveg = \lyricmode { Szólt az Úr, }
338 jobbkéz = \relative c'' { <g d g,>2~ <g d g,> }
339 balkéz = \relative c { b2 e2 }
340
341 \score {
342   <<
343     \new Staff = "ének" <<
344       \new Voice = "dallam" { \dallam }
345       \addlyrics { \dalszöveg }
346     >>
347     \new PianoStaff = "zongora" <<
348       \new Staff = "jobbkéz" { \jobbkéz }
349       \new Staff = "balkéz" {
350         \clef "bass"
351         \balkéz
352       }
353     >>
354   >>
355   \layout { }
356 }
357 @end lilypond
358
359 Amikor a @code{\score} blokkot írjuk vagy olvassuk, mindig lassan, gondosan
360 járjunk el. Haladjunk kívülről befelé, a magas szintű felépítéstől a részletek
361 felé haladva. Nagyban segít, ha ügyelünk a behúzásokra -- minden blokk
362 kezdődjön egy tabulátorral beljebb, így az egy szinten levő blokkok ugyanolyan
363 mértékben lesznek behúzva.
364
365 @seealso
366 Referencia: @ruser{Structure of a score}.
367
368
369 @node Zenei kifejezések egymásba ágyazása
370 @subsection Zenei kifejezések egymásba ágyazása
371 @translationof Nesting music expressions
372
373 @cindex ideiglenes kottasorok
374 @cindex ossia
375
376 Ossiák bevitelekor jön jól, hogy kottasorok bármikor, darab közben is
377 kezdődhetnek, és bármikor végződhetnek. Álljon itt erre egy példa:
378
379 @lilypond[verbatim,quote,ragged-right]
380 \new Staff {
381   \relative g' {
382     r4 g8 g c4 c8 d |
383     e4 r8
384     <<
385       { f c c }
386       \new Staff {
387         f8 f c
388       }
389     >>
390     r4 |
391   }
392 }
393 @end lilypond
394
395 @noindent
396 Figyeljük meg, hogy a kulcs mérete némileg kisebb, mint a sor elején szereplő
397 kulcsé (mint ahogy kulcsváltásnál is).
398
399 @cindex kottasorok pozíciója
400
401 Az ossia a kottasor fölött is elhelyezkedhet:
402
403 @lilypond[verbatim,quote,ragged-right]
404 \new Staff = "main" {
405   \relative g' {
406     r4 g8 g c4 c8 d |
407     e4 r8
408     <<
409       { f c c }
410       \new Staff \with {
411         alignAboveContext = #"main" }
412       { f8 f c }
413     >>
414     r4 |
415   }
416 }
417 @end lilypond
418
419 Ebben a példában a még ismeretlen @code{\with} parancsot használtuk, amelyet
420 később ismertetünk. Most elég annyit tudni róla, hogy a kottasor bizonyos
421 tulajdonságainak módosítására szolgál. Itt egy olyan tulajdonságot adunk meg,
422 ami azt mondja, hogy az új kottasor a @qq{main} nevű kottasor felett
423 helyezkedjen el (ahelyett, hogy alatta helyezkedne el, ami az alapértelmezés).
424
425
426 @seealso
427 Az ossiákat általában kulcs és ütemmutató nélkül, valamint kisebb méretben
428 szedjük. Ehhez további új parancsok kellenek; ld. az @ref{Size of objects} és
429 @ruser{Ossia staves} szakaszokat.
430
431
432 @node A gerendák és ívek átfedhetik egymást
433 @subsection A gerendák és ívek átfedhetik egymást
434 @translationof On the un-nestedness of brackets and ties
435
436 @cindex zárójeltípusok
437 @cindex zárójelek egymásba ágyazása
438
439 Már sok zárójelfajtával találkoztunk a LilyPond fájlok írása közben. Ezekre
440 különböző szabályok vonatkoznak, amelyeket érdemes tisztázni. Ismételjük át
441 ezeket a típusokat.
442
443 @need 50
444 @multitable @columnfractions .3 .7
445 @headitem Zárójelfajta
446   @tab Szerep
447 @item @code{@{ .. @}}
448   @tab Egymás után megszólaló hangokat tartalmaz
449 @item @code{< .. >}
450   @tab Egy akkord hangjait tartalmazza
451 @item @code{<< .. >>}
452   @tab Egyszerre megszólaló zenei kifejezéseket tartalmaz
453 @item @code{( .. )}
454   @tab Egy ív kezdetét és végét jelöli
455 @item @code{\( .. \)}
456   @tab Egy frazeálóív kezdetét és végét jelöli
457 @item @code{[ .. ]}
458   @tab Egy kézi gerenda kezdetét és végét jelöli
459 @end multitable
460
461 A LilyPond világán kívül a különböző fajtájú zárójeleket megfelelően egymásba
462 kell ágyazni, pl. így: @code{<< [ @{ ( .. ) @} ] >>}. Tehát a záró
463 zárójeleknek pontosan fordított sorrendben kell állniuk, mint a nyitó
464 zárójeleknek. A fenti táblázatban szereplő első három típusnál (a blokkoknál)
465 ezt a LilyPond is megköveteli. A többi parancsnál ez nem követelmény.
466 Valójában ezekre nem is úgy érdemes gondolni, mint a zárójelekre, hanem olyan
467 jelzésekre, amelyek zenei elemek kezdetét és végét jelölik.
468
469 Tehát például egy frazeálóív kezdődhet egy kézzel megadott gerenda előtt, és
470 befejeződhet a gerenda vége előtt -- lehet, hogy nem a legzeneibb megoldás, de
471 lehetséges:
472
473 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
474  { g8\( a b[ c b\) a] }
475 @end lilypond
476
477 Általánosságban az ívek, frazeálóívek, kötőívek és gerendák átnyúlhatnak
478 a triolák és előkék határain. A következő példában az 1. sorban egy gerenda,
479 a 2. sorban egy kötőív nyúl bele egy triolába, a 3. és 4. sorban pedig
480 mindezek mellett még egy kötőív is található két triola között, valamint egy
481 frazeálóív, amely túlnyúlik a triolán.
482
483 @lilypond[quote,verbatim,fragment,ragged-right]
484 {
485   r16[ g16 \times 2/3 {r16 e'8] }
486   g16( a \times 2/3 {b d) e' }
487   g8[( a \times 2/3 {b d') e'~]}
488   \times 4/5 {e'32\( a b d' e'} a'4.\)
489 }
490 @end lilypond
491
492
493 @node A szólamok zenét tartalmaznak
494 @section A szólamok zenét tartalmaznak
495 @translationof Voices contain music
496
497
498 Singers need voices to sing, and so does LilyPond.
499 The actual music for all instruments in a score
500 is contained in Voices -- the most fundamental
501 of all LilyPond's concepts.
502
503 @menu
504 * Hangzatos szólamok::
505 * Szólamok kézi létrehozása::
506 * Szólamok és vokális zene::
507 @end menu
508
509 @node Hangzatos szólamok
510 @subsection Hangzatos szólamok
511 @translationof I'm hearing Voices
512
513
514 @cindex polyphony
515 @cindex layers
516 @cindex multiple voices
517 @cindex voices, multiple
518 @cindex Voice context
519 @cindex context, Voice
520 @cindex simultaneous music
521 @cindex music, simultaneous
522 @cindex concurrent music
523 @cindex music, concurrent
524 @cindex voices vs. chords
525 @cindex chords vs. voices
526
527 The lowest, most fundamental or innermost layers in a LilyPond
528 score are called @q{Voice contexts} or just @q{Voices} for short.
529 Voices are sometimes called @q{layers} in other notation
530 packages.
531
532 In fact, a Voice layer or context is the only one which can contain
533 music.  If a Voice context is not explicitly declared one is created
534 automatically, as we saw at the beginning of this chapter.  Some
535 instruments such as an Oboe can play only one note at a time.  Music
536 written for such instruments is monophonic and requires just a single
537 voice.  Instruments which can play more than one note at a time like
538 the piano will often require multiple voices to encode the different
539 concurrent notes and rhythms they are capable of playing.
540
541 A single voice can contain many notes in a chord, of course,
542 so when exactly are multiple voices needed?  Look first at
543 this example of four chords:
544
545 @lilypond[quote,verbatim,fragment,ragged-right,relative=1]
546 \key g \major
547 <d g>4 <d fis> <d a'> <d g>
548 @end lilypond
549
550 This can be expressed using just the single angle bracket chord
551 symbols, @code{< ... >}, and for this just a single voice is
552 needed.  But suppose the F-sharp were actually an eighth-note
553 followed by an eighth-note G, a passing note on the way to the A?
554 Now we have two notes which start at the same time but have
555 different durations: the quarter-note D and the eighth-note
556 F-sharp.  How are these to be coded?  They cannot be written as
557 a chord because all the notes in a chord must have the same
558 duration.  And they cannot be written as two sequential notes
559 as they need to start at the same time.  This is when two
560 voices are required.
561
562 Let us see how this is done in LilyPond input syntax.
563
564 @funindex << \\ >>
565 @funindex \\
566
567 The easiest way to enter fragments with more than one voice on a
568 staff is to enter each voice as a sequence (with @code{@{...@}}),
569 and combine them simultaneously with angle brackets, @code{<<...>>}.
570 The fragments must also be separated with double backward slashes,
571 @code{\\}, to place them in separate voices.  Without these, the
572 notes would be entered into a single voice, which would usually
573 cause errors.  This technique is particularly suited to pieces of
574 music which are largely monophonic with occasional short sections
575 of polyphony.
576
577 Here's how we split the chords above into two voices and add both
578 the passing note and a slur:
579
580 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
581 \key g \major
582 %    Voice "1"                  Voice "2"
583 << { g4 fis8( g) a4 g }  \\  { d4 d d d }  >>
584 @end lilypond
585
586 Notice how the stems of the second voice now point down.
587
588 Here's another simple example:
589
590 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
591 \key d \minor
592 %    Voice "1"             Voice "2"
593 << { r4 g g4. a8 }    \\ { d,2 d4 g }       >>
594 << { bes4 bes c bes } \\ { g4 g g8( a) g4 } >>
595 << { a2. r4 }         \\ { fis2. s4 }       >>
596 @end lilypond
597
598 It is not necessary to use a separate @code{<< \\ >>} construct
599 for each bar. For music with few notes in each bar this layout
600 can help the legibility of the code, but if there are many
601 notes in each bar it may be better to split out each voice
602 separately, like this:
603
604 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
605 \key d \minor
606 << {
607   % Voice "1"
608   r4 g g4. a8 |
609   bes4 bes c bes |
610   a2. r4 |
611 } \\ {
612   % Voice "2"
613   d,2 d4 g |
614   g4 g g8( a) g4 |
615   fis2. s4 |
616 } >>
617 @end lilypond
618
619
620 @cindex voices, naming
621 @cindex voices crossing brackets
622 @cindex slurs crossing brackets
623 @cindex ties crossing brackest
624
625 This example has just two voices, but the same construct may be
626 used to encode three or more voices by adding more back-slash
627 separators.
628
629 The Voice contexts bear the names @code{"1"}, @code{"2"}, etc.
630 In each of these contexts, the vertical direction of slurs,
631 stems, ties, dynamics etc., is set appropriately.
632
633 @lilypond[quote,verbatim,fragment]
634 \new Staff \relative c' {
635   % Main voice
636   c16 d e f
637   %    Voice "1"     Voice "2"                 Voice "3"
638   << { g4 f e } \\ { r8 e4 d c8~ } >>
639   << { d2 e2 }  \\ { c8 b16 a b8 g~ g2 } \\ { s4 b4 c2 } >>
640 }
641 @end lilypond
642
643 These voices are all separate from the main voice that contains
644 the notes just outside the @code{<< .. >>} construct.  Let's call
645 this the @emph{simultaneous construct}.  Slurs and ties may only
646 connect notes within the same voice, so slurs and ties cannot go
647 into or out of a simultaneous construct.  Conversely,
648 parallel voices from separate simultaneous constructs on the same
649 staff are the same voice.  Other voice-related properties also
650 carry across simultaneous constructs.  Here is the same example,
651 with different colors and note heads for each voice.  Note that
652 changes in one voice do not affect other voices, but they do
653 persist in the same voice later.  Note also that tied notes may be
654 split across the same voices in two constructs, shown here in the
655 blue triangle voice.
656
657 @lilypond[quote,verbatim]
658 \new Staff \relative c' {
659   % Main voice
660   c16 d e f
661   <<  % Bar 1
662     {
663       \voiceOneStyle
664       g4 f e
665     }
666   \\
667     {
668       \voiceTwoStyle
669       r8 e4 d c8~
670     }
671   >>
672   <<  % Bar 2
673      % Voice 1 continues
674     { d2 e2 }
675   \\
676      % Voice 2 continues
677     { c8 b16 a b8 g ~ g2 }
678   \\
679     {
680       \voiceThreeStyle
681       s4 b4 c2
682     }
683   >>
684 }
685 @end lilypond
686
687 @funindex \voiceOneStyle
688 @funindex \voiceTwoStyle
689 @funindex \voiceThreeStyle
690 @funindex \voiceFourStyle
691 @funindex \voiceNeutralStyle
692
693 The commands @code{\voiceXXXStyle} are mainly intended for use in
694 educational documents such as this one.  They modify the color
695 of the note head, the stem and the beams, and the style of the
696 note head, so that the voices may be easily distinguished.
697 Voice one is set to red diamonds, voice two to blue triangles,
698 voice three to green crossed circles, and voice four (not used
699 here) to magenta crosses;  @code{\voiceNeutralStyle} (also not
700 used here) reverts the style back to the default.
701 We shall see later how commands like these may be created by the
702 user.
703 See @ref{Visibility and color of objects} and
704 @ref{Using variables for tweaks}.
705
706 @cindex polyphony and relative note entry
707 @cindex relative note entry and polyphony
708
709 Polyphony does not change the relationship of notes within a
710 @code{\relative @{ @}} block.  Each note is still calculated
711 relative to the note immediately preceding it, or to the first
712 note of the preceding chord.  So in
713
714 @example
715 \relative c' @{ noteA << < noteB noteC > \\ noteD >> noteE @}
716 @end example
717
718 @noindent
719 @code{noteB} is relative to @code{noteA}                      @*
720 @code{noteC} is relative to @code{noteB}, not @code{noteA};   @*
721 @code{noteD} is relative to @code{noteB}, not @code{noteA} or
722 @code{noteC};                                                 @*
723 @code{noteE} is relative to @code{noteD}, not @code{noteA}.
724
725 An alternative way, which may be clearer if the notes in the
726 voices are widely separated, is to place a @code{\relative}
727 command at the start of each voice:
728
729 @example
730 \relative c' @{ noteA ... @}
731 <<
732   \relative c'' @{ < noteB noteC > ... @}
733 \\
734   \relative g' @{ noteD ... @}
735 >>
736 \relative c' @{ noteE ... @}
737 @end example
738
739 Let us finally analyze the voices in a more complex piece of music.
740 Here are the notes from the first two bars of the second of Chopin's
741 Deux Nocturnes, Op 32.  This example will be used at later stages in
742 this and the next chapter to illustrate several techniques for
743 producing notation, so please ignore for now anything in the
744 underlying code which looks mysterious and concentrate just on the
745 music and the voices -- the complications will all be explained in
746 later sections.
747
748 @c The following should appear as music without code
749 @lilypond[quote,ragged-right]
750 \new Staff \relative c'' {
751   \key aes \major
752   <<  % Voice one
753     { c2 aes4. bes8 }
754   \\  % Voice two
755     { aes2 f4 fes }
756   \\  % No voice three
757   \\  % Voice four
758     {
759       % Ignore these for now - they are explained in Ch 4
760       \once \override NoteColumn #'force-hshift = #0
761       <ees c>2
762       \once \override NoteColumn #'force-hshift = #0.5
763       des2
764     }
765   >> |
766   <c ees aes c>1 |
767 }
768 @end lilypond
769
770 The direction of the stems is often used to indicate the continuity of
771 two simultaneous melodic lines.  Here the stems of the highest notes
772 are all pointing up and the stems of the lower notes are all pointing
773 down.  This is the first indication that more than one voice is
774 required.
775
776 But the real need for multiple voices arises when notes
777 which start at the same time have different durations.
778 Look at the notes which start at beat three in the first
779 bar.  The A-flat is a dotted quarter note, the F is a
780 quarter note and the D-flat is a half note.  These
781 cannot be written as a chord as all the notes in a chord
782 must have the same duration.  Neither can they be written
783 as sequential notes, as they must start at the same time.
784 This section of the bar requires three voices, and the
785 normal practice would be to write the whole bar as three
786 voices, as shown below, where we have used different note heads
787 and colors for the three voices.  Again, the code behind this
788 example will be explained later, so ignore anything you do
789 not understand.
790
791 @c The following should appear as music without code
792 @c The three voice styles should be defined in -init
793 @lilypond[quote,ragged-right]
794 \new Staff \relative c'' {
795   \key aes \major
796   <<
797     {  % Voice one
798       \voiceOneStyle
799       c2 aes4. bes8
800     }
801   \\  % Voice two
802     { \voiceTwoStyle
803       aes2 f4 fes
804     }
805   \\  % No Voice three (we want stems down)
806   \\  % Voice four
807     { \voiceThreeStyle
808       % Ignore these for now - they are explained in Ch 4
809       \once \override NoteColumn #'force-hshift = #0
810       <ees c>2
811       \once \override NoteColumn #'force-hshift = #0.5
812       des2
813     }
814   >>
815   <c ees aes c>1
816 }
817 @end lilypond
818
819
820 Let us try to encode this music from scratch.  As we
821 shall see, this encounters some difficulties.  We begin as
822 we have learnt, using the @code{<< \\  >>} construct to
823 enter the music of the first bar in three voices:
824
825 @lilypond[quote,verbatim,fragment,ragged-right]
826 \new Staff \relative c'' {
827   \key aes \major
828   <<
829     { c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { <ees c>2 des2 }
830   >>
831   <c ees aes c>1
832 }
833 @end lilypond
834
835 @cindex stem down
836 @cindex voices and stem directions
837 @cindex stem directions and voices
838 @cindex stem up
839
840 The stem directions are automatically assigned with the
841 odd-numbered voices taking upward stems and the even-numbered
842 voices downward ones.  The stems for voices 1 and 2 are right,
843 but the stems in voice 3 should go down in this particular piece
844 of music.  We can correct this by skipping voice three
845 and placing the music in voice four. This is done by simply
846 adding another pair of @code{\\}.
847
848 @lilypond[quote,verbatim,fragment,ragged-right]
849 \new Staff \relative c'' {
850   \key aes \major
851   <<  % Voice one
852     { c2 aes4. bes8 }
853   \\  % Voice two
854     { aes2 f4 fes }
855   \\  % Omit Voice three
856   \\  % Voice four
857     { <ees c>2 des2 }
858   >>
859   <c ees aes c>1
860 }
861 @end lilypond
862
863 @noindent
864 We see that this fixes the stem direction, but exposes a problem
865 sometimes encountered with multiple voices -- the stems of the notes
866 in one voice can collide with the note heads in other voices.  In
867 laying out the notes, LilyPond allows the notes or chords from two
868 voices to occupy the same vertical note column provided the stems are
869 in opposite directions, but the notes from the third and fourth voices
870 are displaced, if necessary, to avoid the note heads colliding.  This
871 usually works well, but in this example the notes of the lowest voice
872 are clearly not well placed by default. LilyPond provides several ways
873 to adjust the horizontal placing of notes.  We are not quite ready yet
874 to see how to correct this, so we shall leave this problem until a
875 later section --- see the @code{force-hshift} property in @ref{Fixing
876 overlapping notation}.
877
878
879 @seealso
880 Notation Reference: @ruser{Multiple voices}.
881
882
883 @node Szólamok kézi létrehozása
884 @subsection Szólamok kézi létrehozása
885 @translationof Explicitly instantiating voices
886
887
888 @funindex \voiceOne
889 @funindex voiceOne
890 @funindex \voiceTwo
891 @funindex voiceTwo
892 @funindex \voiceThree
893 @funindex voiceThree
894 @funindex \voiceFour
895 @funindex voiceFour
896 @funindex \oneVoice
897 @funindex oneVoice
898 @funindex \new Voice
899 @cindex voice contexts, creating
900
901 Voice contexts can also be created manually
902 inside a @code{<< >>} block to create polyphonic music, using
903 @code{\voiceOne} ... @code{\voiceFour} to indicate the required
904 directions of stems, slurs, etc.  In longer scores this method
905 is clearer, as it permits the voices to be separated and to be
906 given more descriptive names.
907
908 Specifically, the construct @code{<< \\ >>} which we used in
909 the previous section:
910
911 @example
912 \new Staff @{
913   \relative c' @{
914     << @{ e4 f g a @} \\ @{ c,4 d e f @} >>
915   @}
916 @}
917 @end example
918
919 @noindent
920 is equivalent to
921
922 @example
923 \new Staff <<
924   \new Voice = "1" @{ \voiceOne \relative c' @{ e4 f g a @} @}
925   \new Voice = "2" @{ \voiceTwo \relative c' @{ c4 d e f @} @}
926 >>
927 @end example
928
929 Both of the above would produce
930
931 @c The following example should not display the code
932 @lilypond[ragged-right,quote]
933 \new Staff <<
934   \new Voice = "1" { \voiceOne \relative c' { e4 f g a } }
935   \new Voice = "2" { \voiceTwo \relative c' { c4 d e f } }
936 >>
937 @end lilypond
938
939 @cindex voices, reverting to single
940 @cindex reverting to a single voice
941
942 The @code{\voiceXXX} commands set the direction of stems, slurs,
943 ties, articulations, text annotations, augmentation dots of dotted
944 notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree}
945 make these objects point upwards, while @code{\voiceTwo} and
946 @code{\voiceFour} make them point downwards.  These commands also
947 generate a horizontal shift for each voice when this is required
948 to avoid clashes of note heads.  The command @code{\oneVoice}
949 reverts the settings back to the normal values for a single voice.
950
951 Let us see in some simple examples exactly what effect
952 @code{\oneVoice}, @code{\voiceOne} and @code{voiceTwo} have on
953 markup, ties, slurs, and dynamics:
954
955 @lilypond[quote,ragged-right,verbatim]
956 \relative c'{
957   % Default behavior or behavior after \oneVoice
958   c d8~ d e4( f g a) b-> c
959 }
960 @end lilypond
961
962 @lilypond[quote,ragged-right,verbatim]
963 \relative c'{
964   \voiceOne
965   c d8~ d e4( f g a) b-> c
966   \oneVoice
967   c, d8~ d e4( f g a) b-> c
968 }
969 @end lilypond
970
971 @lilypond[quote,ragged-right,verbatim]
972 \relative c'{
973   \voiceTwo
974   c d8~ d e4( f g a) b-> c
975   \oneVoice
976   c, d8~ d e4( f g a) b-> c
977 }
978 @end lilypond
979
980 Now let's look at three different ways to notate the same passage
981 of polyphonic music, each of which is advantageous in different
982 circumstances, using the example from the previous section.
983
984 An expression that appears directly inside a @code{<< >>} belongs
985 to the main voice (but, note, @strong{not} in a @code{<< \\ >>}
986 construct).  This is useful when extra voices appear while the
987 main voice is playing.  Here is a more correct rendition of our
988 example.  The red diamond-shaped notes
989 demonstrate that the main melody is now in a single voice context,
990 permitting a phrasing slur to be drawn over them.
991
992 @lilypond[quote,ragged-right,verbatim]
993 \new Staff \relative c' {
994   \voiceOneStyle
995   % The following notes are monophonic
996   c16^( d e f
997   % Start simultaneous section of three voices
998   <<
999     % Continue the main voice in parallel
1000     { g4 f e | d2 e2) | }
1001     % Initiate second voice
1002     \new Voice {
1003       % Set stems, etc., down
1004       \voiceTwo
1005       r8 e4 d c8~ | c8 b16 a b8 g~ g2 |
1006     }
1007     % Initiate third voice
1008     \new Voice {
1009       % Set stems, etc, up
1010       \voiceThree
1011       s2. | s4 b4 c2 |
1012     }
1013   >>
1014 }
1015 @end lilypond
1016
1017 @cindex nesting music expressions
1018 @cindex nesting simultaneous constructs
1019 @cindex nesting voices
1020 @cindex voices, temporary
1021 @cindex voices, nesting
1022
1023 More deeply nested polyphony constructs are possible, and if a
1024 voice appears only briefly this might be a more natural way to
1025 typeset the music:
1026
1027 @lilypond[quote,ragged-right,verbatim]
1028 \new Staff \relative c' {
1029   c16^( d e f
1030   <<
1031     { g4 f e | d2 e2) | }
1032     \new Voice {
1033       \voiceTwo
1034       r8 e4 d c8~
1035       <<
1036         { c8 b16 a b8 g~ g2 }
1037         \new Voice {
1038           \voiceThree
1039           s4 b4 c2
1040         }
1041       >>
1042     }
1043   >>
1044 }
1045 @end lilypond
1046
1047 @cindex spacing notes
1048
1049 This method of nesting new voices briefly is useful
1050 when only small sections of the music
1051 are polyphonic, but when the whole staff is largely polyphonic
1052 it can be clearer to use multiple voices throughout, using
1053 spacing notes to step over sections where the voice is silent,
1054 as here:
1055
1056 @lilypond[quote,ragged-right,verbatim]
1057 \new Staff \relative c' <<
1058   % Initiate first voice
1059   \new Voice {
1060     \voiceOne
1061     c16^( d e f g4 f e | d2 e2) |
1062   }
1063   % Initiate second voice
1064   \new Voice {
1065     % Set stems, etc, down
1066     \voiceTwo
1067     s4 r8 e4 d c8~ | c8 b16 a b8 g~ g2 |
1068   }
1069   % Initiate third voice
1070   \new Voice {
1071     % Set stems, etc, up
1072     \voiceThree
1073     s1 | s4 b4 c2 |
1074   }
1075 >>
1076 @end lilypond
1077
1078 @subsubheading Note columns
1079
1080 @cindex note column
1081 @cindex note collisions
1082 @cindex collisions, notes
1083 @cindex shift commands
1084 @funindex \shiftOff
1085 @funindex shiftOff
1086 @funindex \shiftOn
1087 @funindex shiftOn
1088 @funindex \shiftOnn
1089 @funindex shiftOnn
1090 @funindex \shiftOnnn
1091 @funindex shiftOnnn
1092
1093 Closely spaced notes in a chord, or notes occurring at the same
1094 time in different voices, are arranged in two, occasionally more,
1095 columns to prevent the note heads overlapping.  These are called
1096 note columns.  There are separate columns for each voice, and
1097 the currently specified voice-dependent shift is applied to the
1098 note column if there would otherwise be a collision.  This can
1099 be seen in the example above.  In bar 2 the C in voice two is
1100 shifted to the right relative to the D in voice one, and in the
1101 final chord the C in voice three is also shifted to the right
1102 relative to the other notes.
1103
1104 The @code{\shiftOn}, @code{\shiftOnn}, @code{\shiftOnnn}, and
1105 @code{\shiftOff} commands specify the degree to which notes and
1106 chords of the voice should be shifted if a collision
1107 would otherwise occur. By default, the outer voices (normally
1108 voices one and two) have @code{\shiftOff} specified, while the
1109 inner voices (three and four) have @code{\shiftOn} specified.
1110 When a shift is applied, voices one and three are shifted to
1111 the right and voices two and four to the left.
1112
1113 @code{\shiftOnn} and @code{\shiftOnnn} define further shift
1114 levels which may be specified temporarily to resolve collisions
1115 in complex situations -- see @ref{Real music example}.
1116
1117 A note column can contain just one note (or chord) from a voice
1118 with stems up and one note (or chord) from a voice with stems
1119 down.  If notes from two voices which have their stems in the
1120 same direction are placed at the same position and both voices
1121 have no shift or the same shift specified, the error message
1122 @qq{Too many clashing note columns} will be produced.
1123
1124
1125 @seealso
1126 Notation Reference: @ruser{Multiple voices}.
1127
1128
1129 @node Szólamok és vokális zene
1130 @subsection Szólamok és vokális zene
1131 @translationof Voices and vocals
1132
1133 Vocal music presents a special difficulty: we need to combine two
1134 expressions -- notes and lyrics.
1135
1136 @funindex \new Lyrics
1137 @funindex \lyricsto
1138 @funindex lyricsto
1139 @funindex Lyrics
1140 @cindex Lyrics context, creating
1141 @cindex lyrics, linking to voice
1142
1143 You have already seen the @code{\addlyrics@{@}} command, which
1144 handles simple scores well.  However, this technique is
1145 quite limited.  For more complex music, you must introduce the
1146 lyrics in a @code{Lyrics} context using @code{\new Lyrics} and
1147 explicitly link
1148 the lyrics to the notes with @code{\lyricsto@{@}}, using the
1149 name assigned to the Voice.
1150
1151 @lilypond[quote,verbatim,fragment]
1152 <<
1153   \new Voice = "one" \relative c'' {
1154     \autoBeamOff
1155     \time 2/4
1156     c4 b8. a16 g4. f8 e4 d c2
1157   }
1158   \new Lyrics \lyricsto "one" {
1159     No more let sins and sor -- rows grow.
1160   }
1161 >>
1162 @end lilypond
1163
1164 Note that the lyrics must be linked to a @code{Voice} context,
1165 @emph{not} a @code{Staff} context.  This is a case where it is
1166 necessary to create @code{Staff} and @code{Voice} contexts
1167 explicitly.
1168
1169 @cindex lyrics and beaming
1170 @cindex beaming and lyrics
1171 @funindex \autoBeamOff
1172 @funindex autoBeamOff
1173
1174 The automatic beaming which LilyPond uses by default works well
1175 for instrumental music, but not so well for music with lyrics,
1176 where beaming is either not required at all or is used to indicate
1177 melismata in the lyrics.  In the example above we use the command
1178 @code{\autoBeamOff} to turn off the automatic beaming.
1179
1180 @funindex \new ChoirStaff
1181 @funindex ChoirStaff
1182 @funindex \lyricmode
1183 @funindex lyricmode
1184 @cindex vocal score structure
1185 @cindex choir staff
1186
1187 Let us reuse the earlier example from Judas Maccabæus to
1188 illustrate this more flexible technique.  We first recast
1189 it to use variables so the music and lyrics can be separated
1190 from the staff structure.  We also introduce a ChoirStaff
1191 bracket.  The lyrics themselves must be introduced with
1192 @code{\lyricmode} to ensure they are interpreted as lyrics
1193 rather than music.
1194
1195 @lilypond[quote,verbatim]
1196 global = { \time 6/8 \partial 8 \key f \major}
1197 SopOneMusic = \relative c'' {
1198   c8 | c([ bes)] a a([ g)] f | f'4. b, | c4.~ c4 | }
1199 SopTwoMusic = \relative c' {
1200   r8 | r4. r4 c8 | a'([ g)] f f([ e)] d | e([ d)] c bes' | }
1201 SopOneLyrics = \lyricmode {
1202   Let | flee -- cy flocks the | hills a -- dorn, __ | }
1203 SopTwoLyrics = \lyricmode {
1204   Let | flee -- cy flocks the | hills a -- dorn, | }
1205
1206 \score {
1207   \new ChoirStaff <<
1208     \new Staff <<
1209       \new Voice = "SopOne" {
1210         \global
1211         \SopOneMusic
1212       }
1213       \new Lyrics \lyricsto "SopOne" {
1214         \SopOneLyrics
1215       }
1216     >>
1217     \new Staff <<
1218       \new Voice = "SopTwo" {
1219         \global
1220         \SopTwoMusic
1221       }
1222       \new Lyrics \lyricsto "SopTwo" {
1223         \SopTwoLyrics
1224       }
1225     >>
1226   >>
1227 }
1228 @end lilypond
1229
1230 This is the basic structure of all vocal scores.  More staves may be
1231 added as required, more voices may be added to the staves, more verses
1232 may be added to the lyrics, and the variables containing the music can
1233 easily be placed in separate files should they become too long.
1234
1235 @cindex hymn structure
1236 @cindex SATB structure
1237 @cindex vocal scores with multiple verses
1238 @cindex multiple vocal verses
1239 @cindex verses, multiple vocal
1240
1241 Here is an example of the first line of a hymn with four
1242 verses, set for SATB.  In this case the words for all four
1243 parts are the same.  Note how we use variables to separate the
1244 music notation and words from the staff structure.  See too
1245 how a variable, which we have chosen to call @q{TimeKey}, is used
1246 to hold several commands for use within the two staves.  In other
1247 examples this is often called @q{global}.
1248
1249 @lilypond[quote,verbatim]
1250 TimeKey = { \time 4/4 \partial 4 \key c \major}
1251 SopMusic   = \relative c' { c4 | e4. e8 g4  g  | a a g | }
1252 AltoMusic  = \relative c' { c4 | c4. c8 e4  e  | f f e | }
1253 TenorMusic = \relative c  { e4 | g4. g8 c4. b8 | a8 b c d e4 | }
1254 BassMusic  = \relative c  { c4 | c4. c8 c4  c  | f8 g a b c4 | }
1255 VerseOne   = \lyricmode {
1256   E -- | ter -- nal fa -- ther, | strong to save, | }
1257 VerseTwo   = \lyricmode {
1258   O | Christ, whose voice the | wa -- ters heard, | }
1259 VerseThree = \lyricmode {
1260   O | Ho -- ly Spi -- rit, | who didst brood | }
1261 VerseFour  = \lyricmode {
1262   O | Tri -- ni -- ty of | love and pow'r | }
1263
1264 \score {
1265   \new ChoirStaff <<
1266     \new Staff <<
1267       \clef "treble"
1268       \new Voice = "Sop"  { \voiceOne \TimeKey \SopMusic }
1269       \new Voice = "Alto" { \voiceTwo \AltoMusic }
1270       \new Lyrics \lyricsto "Sop" { \VerseOne   }
1271       \new Lyrics \lyricsto "Sop" { \VerseTwo   }
1272       \new Lyrics \lyricsto "Sop" { \VerseThree }
1273       \new Lyrics \lyricsto "Sop" { \VerseFour  }
1274     >>
1275     \new Staff <<
1276       \clef "bass"
1277       \new Voice = "Tenor" { \voiceOne \TimeKey \TenorMusic }
1278       \new Voice = "Bass"  { \voiceTwo \BassMusic }
1279     >>
1280   >>
1281 }
1282 @end lilypond
1283
1284 @cindex verse and refrain
1285
1286 We end with an example to show how we might code a solo verse which
1287 continues into a two-part refrain in two staves.  The positioning
1288 of the sequential and simultaneous sections to achieve this within
1289 a single score is quite tricky, so follow the explanation carefully!
1290
1291 Let's start with a score block containing a @code{ChoirStaff}, as
1292 we would like the brace to appear at the start of the chorus.
1293 Normally you would need angle brackets after @code{\new ChoirStaff}
1294 to bring in all the staves in parallel, but here we want to
1295 defer the parallelism during the solo so we use braces, although
1296 angle brackets here wouldn't hurt.  Inside the @code{ChoirStaff} we
1297 want first the staff which will contain the verse.  This must
1298 contain notes and lyrics in parallel, so here we need angle
1299 brackets around the @code{\new Voice} and @code{\new Lyrics} to
1300 start them at the same time:
1301
1302 @lilypond[quote,verbatim,ragged-right]
1303 versenotes = \relative c'' {
1304   \clef "treble"
1305   \key g \major
1306   \time 3/4
1307   g g g | b b b |
1308 }
1309 versewords = \lyricmode {
1310   One two three four five six
1311 }
1312 \score {
1313   \new ChoirStaff {
1314     \new Staff <<
1315       \new Voice = "verse" {
1316         \versenotes \break
1317       }
1318       \new Lyrics \lyricsto verse {
1319         \versewords
1320       }
1321     >>
1322   }
1323 }
1324 @end lilypond
1325
1326 That gives the verse line.
1327
1328 Now we want to continue with refrainA on the same staff while a
1329 second staff is introduced in parallel with it for refrainB, so
1330 this is a parallel section which must be positioned immediately
1331 following the @code{\break} in the verse Voice.  Yes, @emph{within}
1332 the verse Voice!  Here's that parallel section.  More staves
1333 could be introduced here in the same way.
1334
1335 @example
1336 <<
1337   \refrainnotesA
1338   \new Lyrics \lyricsto verse @{
1339     \refrainwordsA
1340   @}
1341   \new Staff <<
1342     \new Voice = "refrainB" @{
1343       \refrainnotesB
1344     @}
1345     \new Lyrics \lyricsto "refrainB" @{
1346       \refrainwordsB
1347     @}
1348   >>
1349 >>
1350 @end example
1351
1352 Here's the final result with two staves in the chorus showing
1353 how the parallel section is positioned within the verse Voice:
1354
1355 @lilypond[quote,verbatim, ragged-right]
1356 versenotes = \relative c'' {
1357   \clef "treble"
1358   \key g \major
1359   \time 3/4
1360   g g g | b b b |
1361 }
1362 refrainnotesA = \relative c'' {
1363   \time 2/4
1364   c c | g g \bar "|."
1365 }
1366 refrainnotesB = \relative c {
1367   \clef "bass"
1368   \key g \major
1369   c e | d d |
1370 }
1371 versewords = \lyricmode {
1372   One two three four five six
1373 }
1374 refrainwordsA = \lyricmode {
1375   la la la la
1376 }
1377 refrainwordsB = \lyricmode {
1378   dum dum dum dum
1379 }
1380 \score {
1381   \new ChoirStaff {
1382     \new Staff <<
1383       \new Voice = "verse" {
1384         \versenotes \break
1385         <<
1386           \refrainnotesA
1387           \new Lyrics \lyricsto "verse" {
1388             \refrainwordsA
1389           }
1390           \new Staff <<
1391             \new Voice = "refrainB" {
1392               \refrainnotesB
1393             }
1394             \new Lyrics \lyricsto "refrainB" {
1395               \refrainwordsB
1396             }
1397           >>
1398         >>
1399       }
1400       \new Lyrics \lyricsto "verse" {
1401         \versewords
1402       }
1403     >>
1404   }
1405 }
1406 @end lilypond
1407
1408 @cindex book, example of using
1409 @funindex \book
1410 @funindex book
1411
1412 However, although this is an interesting and useful exercise to
1413 help you to understand how sequential and simultaneous blocks work,
1414 in practice one would perhaps choose to code this as two
1415 @code{\score} blocks within an implicit @code{\book} block, as
1416 follows:
1417
1418 @lilypond[quote,verbatim,ragged-right]
1419 versenotes = \relative c'' {
1420   \clef "treble"
1421   \key g \major
1422   \time 3/4
1423   g g g | b b b |
1424 }
1425 refrainnotesA = \relative c'' {
1426   \time 2/4
1427   c c | g g \bar "|."
1428 }
1429 refrainnotesB = \relative c {
1430   \clef "bass"
1431   \key g \major
1432   c e | d d |
1433 }
1434 versewords = \lyricmode {
1435   One two three four five six
1436 }
1437 refrainwordsA = \lyricmode {
1438   la la la la
1439 }
1440 refrainwordsB = \lyricmode {
1441   dum dum dum dum
1442 }
1443 \score {
1444   \new Staff <<
1445     \new Voice = "verse" {
1446       \versenotes
1447     }
1448     \new Lyrics \lyricsto "verse" {
1449       \versewords
1450     }
1451   >>
1452 }
1453
1454 \score {
1455   \new ChoirStaff <<
1456     \new Staff <<
1457       \new Voice = "refrainA" {
1458         \refrainnotesA
1459       }
1460       \new Lyrics \lyricsto "refrainA" {
1461         \refrainwordsA
1462       }
1463     >>
1464     \new Staff <<
1465       \new Voice = "refrainB" {
1466         \refrainnotesB
1467       }
1468       \new Lyrics \lyricsto "refrainB" {
1469         \refrainwordsB
1470       }
1471     >>
1472   >>
1473 }
1474 @end lilypond
1475
1476
1477 @seealso
1478 Notation Reference: @ruser{Vocal music}.
1479
1480
1481 @node Kontextusok és ábrázolók
1482 @section Kontextusok és ábrázolók
1483 @translationof Contexts and engravers
1484
1485
1486 Kontextusok és ábrázolók have been mentioned informally
1487 in earlier sections; we now must look at
1488 these concepts in more detail, as they are important
1489 in the fine-tuning of LilyPond output.
1490
1491
1492 @menu
1493 * A kontextus fogalma::
1494 * Kontextusok létrehozása::
1495 * Az ábrázoló fogalma::
1496 * Kontextusok tulajdonságainak módosítása::
1497 * Ábrázolók hozzáadása és eltávolítása::
1498 @end menu
1499
1500 @node A kontextus fogalma
1501 @subsection A kontextus fogalma
1502 @translationof Contexts explained
1503
1504 @cindex contexts explained
1505
1506 When music is printed, many notational elements which do not
1507 appear explicitly in the input file must be added to the
1508 output.  For example, compare the input and output of the
1509 following example:
1510
1511 @lilypond[quote,verbatim,relative=2,fragment]
1512 cis4 cis2. g4
1513 @end lilypond
1514
1515 The input is rather sparse, but in the output, bar lines,
1516 accidentals, clef, and time signature have been added.  When
1517 LilyPond @emph{interprets} the input the musical information
1518 is parsed from left to right, similar to the way a performer
1519 reads the score.  While reading the input, the program remembers
1520 where measure boundaries are, and which pitches require explicit
1521 accidentals.  This information must be held on several levels.
1522 For example, an accidental affects only a single staff, while
1523 a bar line must be synchronized across the entire score.
1524
1525 Within LilyPond, these rules and bits of information are grouped in
1526 @emph{Contexts}.  We have already introduced the @code{Voice} context.
1527 Others are the @code{Staff} and @code{Score} contexts.  Contexts are
1528 hierarchical to reflect the hierarchical nature of a musical score.
1529 For example: a @code{Staff} context can contain many @code{Voice}
1530 contexts, and a @code{Score} context can contain many @code{Staff}
1531 contexts.
1532
1533 @quotation
1534 @sourceimage{context-example,5cm,,}
1535 @end quotation
1536
1537 Each context has the responsibility for enforcing some notation rules,
1538 creating some notation objects and maintaining the associated
1539 properties.  For example, the @code{Voice} context may introduce an
1540 accidental and then the @code{Staff} context maintains the rule to
1541 show or suppress the accidental for the remainder of the measure.
1542
1543 As another example, the synchronization of bar lines is, by default,
1544 handled in the @code{Score} context.
1545 However, in some music we may not want the bar lines to be
1546 synchronized -- consider a polymetric score in 4/4 and 3/4 time.
1547 In such cases, we must modify the default settings of the
1548 @code{Score} and @code{Staff} contexts.
1549
1550 For very simple scores, contexts are created implicitly, and you need
1551 not be aware of them.  For larger pieces, such as anything with more
1552 than one staff, they must be
1553 created explicitly to make sure that you get as many staves as you
1554 need, and that they are in the correct order.  For typesetting pieces
1555 with specialized notation, it is usual to modify existing, or
1556 even to define totally new, contexts.
1557
1558 In addition to the @code{Score,} @code{Staff} and
1559 @code{Voice} contexts there are contexts which fit between
1560 the score and staff levels to control staff groups, such as the
1561 @code{PianoStaff} and @code{ChoirStaff} contexts.  There
1562 are also alternative staff and voice contexts, and contexts for
1563 lyrics, percussion, fret boards, figured bass, etc.
1564
1565 The names of all context types are formed from one or more
1566 words, each word being capitalized and joined immediately to the
1567 preceding word with no hyphen or underscore, e.g.,
1568 @code{GregorianTranscriptionStaff}.
1569
1570
1571 @seealso
1572 Notation Reference: @ruser{A kontextus fogalma}.
1573
1574
1575 @node Kontextusok létrehozása
1576 @subsection Kontextusok létrehozása
1577 @translationof Creating contexts
1578
1579
1580 @funindex \new
1581 @funindex new
1582 @cindex new contexts
1583 @cindex creating contexts
1584 @cindex contexts, creating
1585
1586 In an input file a score block, introduced with a @code{\score}
1587 command, contains a single music expression and an associated
1588 output definition (either a @code{\layout} or a @code{\midi} block).
1589 The @code{Score} context is usually left to be created automatically
1590 when the interpretation of that music expression starts.
1591
1592 For scores with only one voice and one staff, the @code{Voice} and
1593 @code{Staff} contexts may also be left to be created automatically,
1594 but for more complex scores it is necessary to create them by hand.
1595 The simplest command that does this is @code{\new}.  It is prepended
1596 to a music expression, for example
1597
1598 @example
1599 \new @var{type} @var{music-expression}
1600 @end example
1601
1602 @noindent
1603 where @var{type} is a context name (like @code{Staff} or
1604 @code{Voice}).  This command creates a new context, and starts
1605 interpreting the @var{music-expression} within that context.
1606
1607 (Note that a @code{\new Score} command is not normally required,
1608 as the essential top-level @code{Score} context is created
1609 automatically when the music expression within the @code{\score}
1610 block is interpreted.  The only reason for creating a @code{Score}
1611 context explicitly using @code{\new Score} is to introduce a
1612 @code{\with} block in which one or more score-wide default values
1613 of context properties may be specified.  Information on using
1614 @code{\with} blocks can be found under the heading
1615 @qq{Setting context properties with @code{\\with} } in
1616 @ref{Kontextusok tulajdonságainak módosítása}.)
1617
1618 You have seen many practical examples which created new
1619 @code{Staff} and @code{Voice} contexts in earlier sections, but
1620 to remind you how these commands are used in practice, here's an
1621 annotated real-music example:
1622
1623 @lilypond[quote,verbatim,ragged-right]
1624 \score {  % start of single compound music expression
1625   <<  % start of simultaneous staves section
1626     \time 2/4
1627     \new Staff {  % create RH staff
1628       \key g \minor
1629       \clef "treble"
1630       \new Voice {  % create voice for RH notes
1631         \relative c'' {  % start of RH notes
1632           d4 ees16 c8.
1633           d4 ees16 c8.
1634         }  % end of RH notes
1635       }  % end of RH voice
1636     }  % end of RH staff
1637     \new Staff <<  % create LH staff; needs two simultaneous voices
1638       \key g \minor
1639       \clef "bass"
1640       \new Voice {  % create LH voice one
1641         \voiceOne
1642         \relative g {  % start of LH voice one notes
1643           g8 <bes d> ees, <g c>
1644           g8 <bes d> ees, <g c>
1645         }  % end of LH voice one notes
1646       }  % end of LH voice one
1647       \new Voice {  % create LH voice two
1648         \voiceTwo
1649         \relative g {  % start of LH voice two notes
1650           g4 ees
1651           g4 ees
1652         }  % end of LH voice two notes
1653       }  % end of LH voice two
1654     >>  % end of LH staff
1655   >>  % end of simultaneous staves section
1656 }  % end of single compound music expression
1657 @end lilypond
1658
1659 (Note how all the statements which open a block with either a
1660 curly bracket, @code{@{}, or double angle brackets, @code{<<},
1661 are indented by two further spaces, and the corresponding
1662 closing bracket is indented by exactly the same amount.  While
1663 this is not required, following this practice will greatly
1664 reduce the number of @q{unmatched bracket} errors, and is
1665 strongly recommended.  It enables the structure of the music to
1666 be seen at a glance, and any unmatched brackets will be obvious.
1667 Note too how the LH staff is created using double angle brackets
1668 because it requires two voices for its music, whereas the RH staff
1669 is created with a single music expression surrounded by curly
1670 brackets because it requires only one voice.)
1671
1672 @cindex contexts, naming
1673 @cindex naming contexts
1674
1675 The @code{\new} command may also give an identifying name to the
1676 context to distinguish it from other contexts of the same type,
1677
1678 @example
1679 \new @var{type} = @var{id} @var{music-expression}
1680 @end example
1681
1682 Note the distinction between the name of the context type,
1683 @code{Staff}, @code{Voice}, etc, and the identifying name of a
1684 particular instance of that type, which can be any sequence of letters
1685 invented by the user.  Digits and spaces can also be used in the
1686 identifying name, but then it has to be placed in quotes,
1687 i.e. @code{\new Staff = "MyStaff 1" @var{music-expression}}.
1688 The identifying name is used to
1689 refer back to that particular instance of a context.  We saw this in
1690 use in the section on lyrics, see @ref{Szólamok és vokális zene}.
1691
1692
1693 @seealso
1694 Notation Reference: @ruser{Kontextusok létrehozása}.
1695
1696
1697 @node Az ábrázoló fogalma
1698 @subsection Az ábrázoló fogalma
1699 @subsection Az ábrázoló fogalma
1700
1701 @cindex engravers
1702
1703 Every mark on the printed output of a score produced by LilyPond
1704 is produced by an @code{Engraver}.  Thus there is an engraver
1705 to print staves, one to print note heads, one for stems, one for
1706 beams, etc, etc.  In total there are over 120 such engravers!
1707 Fortunately, for most scores it is not necessary to know about
1708 more than a few, and for simple scores you do not need to know
1709 about any.
1710
1711 Engravers live and operate in Contexts.  Engravers such as the
1712 @code{Metronome_mark_engraver}, whose action and output apply to the
1713 score as a whole, operate in the highest level context -- the
1714 @code{Score} context.
1715
1716 The @code{Clef_engraver} and @code{Key_engraver} are to be
1717 found in every @code{Staff} Context, as different staves may require
1718 different clefs and keys.
1719
1720 The @code{Note_heads_engraver} and @code{Stem_engraver} live
1721 in every @code{Voice} context, the lowest level context of all.
1722
1723 Each engraver processes the particular objects associated
1724 with its function, and maintains the properties that relate
1725 to that function.  These properties, like the properties
1726 associated with contexts, may be modified to change the
1727 operation of the engraver or the appearance of those elements
1728 in the printed score.
1729
1730 Engravers all have compound names formed from words which
1731 describe their function.  Just the first word is capitalized,
1732 and the remainder are joined to it with underscores.  Thus
1733 the @code{Staff_symbol_engraver} is responsible for creating the
1734 lines of the staff, the @code{Clef_engraver} determines and sets
1735 the pitch reference point on the staff by drawing a clef symbol.
1736
1737 Here are some of the most common engravers together with their
1738 function.  You will see it is usually easy to guess the function
1739 from the name, or vice versa.
1740
1741 @multitable @columnfractions .3 .7
1742 @headitem Engraver
1743   @tab Function
1744 @item Accidental_engraver
1745   @tab Makes accidentals, cautionary and suggested accidentals
1746 @item Beam_engraver
1747   @tab Engraves beams
1748 @item Clef_engraver
1749   @tab Engraves clefs
1750 @item Completion_heads_engraver
1751   @tab Splits notes which cross bar lines
1752 @c The old Dynamic_engraver is deprecated. -jm
1753 @item New_dynamic_engraver
1754   @tab Creates hairpins and dynamic texts
1755 @item Forbid_line_break_engraver
1756   @tab Prevents line breaks if a musical element is still active
1757 @item Key_engraver
1758   @tab Creates the key signature
1759 @item Metronome_mark_engraver
1760   @tab Engraves metronome marking
1761 @item Note_heads_engraver
1762   @tab Engraves note heads
1763 @item Rest_engraver
1764   @tab Engraves rests
1765 @item Staff_symbol_engraver
1766   @tab Engraves the five (by default) lines of the staff
1767 @item Stem_engraver
1768   @tab Creates stems and single-stem tremolos
1769 @item Time_signature_engraver
1770   @tab Creates time signatures
1771 @end multitable
1772
1773 @smallspace
1774
1775 We shall see later how the output of LilyPond can be changed
1776 by modifying the action of Engravers.
1777
1778
1779 @seealso
1780 Internals reference: @rinternals{Engravers and Performers}.
1781
1782
1783 @node Kontextusok tulajdonságainak módosítása
1784 @subsection Kontextusok tulajdonságainak módosítása
1785 @translationof Modifying context properties
1786
1787 @cindex context properties
1788 @cindex context properties, modifying
1789 @cindex modifying context properties
1790 @funindex \set
1791 @funindex set
1792 @funindex \unset
1793 @funindex unset
1794
1795 Contexts are responsible for holding the values of a number of
1796 context @emph{properties}.  Many of them can be changed to
1797 influence the interpretation of the input and so change the
1798 appearance of the output.  They are changed by the
1799 @code{\set} command.  This takes the form
1800
1801 @example
1802 \set @emph{ContextName}.@emph{propertyName} = #@emph{value}
1803 @end example
1804
1805 Where the @emph{ContextName} is usually @code{Score},
1806 @code{Staff} or @code{Voice}.  It may be omitted,
1807 in which case the current context (typically @code{Voice}) is assumed.
1808
1809 The names of context properties consist of words joined
1810 together with no hyphens or underscores, all except the
1811 first having a capital letter.  Here are a few examples
1812 of some commonly used ones.  There are many more.
1813
1814 @c attempt to force this onto a new page
1815 @need 50
1816 @multitable @columnfractions .25 .15 .45 .15
1817 @headitem propertyName
1818   @tab Type
1819   @tab Function
1820   @tab Example Value
1821 @item extraNatural
1822   @tab Boolean
1823   @tab If true, set extra natural signs before accidentals
1824   @tab @code{#t}, @code{#f}
1825 @item currentBarNumber
1826   @tab Integer
1827   @tab Set the current bar number
1828   @tab @code{50}
1829 @item doubleSlurs
1830   @tab Boolean
1831   @tab If true, print slurs both above and below notes
1832   @tab @code{#t}, @code{#f}
1833 @item instrumentName
1834   @tab Text
1835   @tab Set the name to be placed at the start of the staff
1836   @tab @code{"Cello I"}
1837 @item fontSize
1838   @tab Real
1839   @tab Increase or decrease the font size
1840   @tab @code{2.4}
1841 @item stanza
1842   @tab Text
1843   @tab Set the text to print before the start of a verse
1844   @tab @code{"2"}
1845 @end multitable
1846
1847 @noindent
1848 where a Boolean is either True (@code{#t}) or False (@code{#f}),
1849 an Integer is a positive whole number, a Real is a positive
1850 or negative decimal number, and text is enclosed in double
1851 apostrophes.  Note the occurrence of hash signs,
1852 (@code{#}), in two different places -- as part of the Boolean
1853 value before the @code{t} or @code{f}, and before @emph{value}
1854 in the @code{\set} statement.  So when a Boolean is being
1855 entered you need to code two hash signs, e.g., @code{##t}.
1856
1857 @cindex properties operating in contexts
1858 @cindex setting properties within contexts
1859
1860 Before we can set any of these properties we need to know
1861 in which context they operate.  Sometimes this is obvious,
1862 but occasionally it can be tricky.  If the wrong context
1863 is specified, no error message is produced, but the expected
1864 action will not take place.  For example, the
1865 @code{instrumentName} clearly lives in the @code{Staff} context, since
1866 it is the staff that is to be named.
1867 In this example the first staff is labelled, but not the second,
1868 because we omitted the context name.
1869
1870 @lilypond[quote,verbatim,ragged-right]
1871 <<
1872   \new Staff \relative c'' {
1873     \set Staff.instrumentName = #"Soprano"
1874     c4 c
1875  }
1876   \new Staff \relative c' {
1877   \set instrumentName = #"Alto"  % Wrong!
1878   d4 d
1879  }
1880 >>
1881 @end lilypond
1882
1883 Remember the default context name is @code{Voice}, so the second
1884 @code{\set} command set the property @code{instrumentName} in the
1885 @code{Voice} context to @qq{Alto}, but as LilyPond does not look
1886 for any such property in the @code{Voice} context, no
1887 further action took place.  This is not an error, and no error
1888 message is logged in the log file.
1889
1890 Similarly, if the property name is mis-spelt no error message is
1891 produced, and clearly the expected action cannot be performed.  In
1892 fact, you can set any (fictitious) @q{property} using any name you
1893 like in any context that exists by using the @code{\set} command.  But
1894 if the name is not known to LilyPond it will not cause any action to
1895 be taken.  Some text editors with special support for LilyPond input
1896 files document property names with bullets when you hover them with
1897 the mouse, like JEdit with LilyPondTool, or highlight unknown property
1898 names differently, like ConTEXT.  If you do not use an editor with
1899 such features, it is recommended to check the property name in the
1900 Internals Reference: see @rinternals{Tunable context properties}, or
1901 @rinternals{Contexts}.
1902
1903 The @code{instrumentName} property will take effect only
1904 if it is set in the @code{Staff} context, but
1905 some properties can be set in more than one context.
1906 For example, the property @code{extraNatural} is by
1907 default set to ##t (true) for all staves.
1908 If it is set to ##f (false) in one particular @code{Staff}
1909 context it applies just to the accidentals on that staff.
1910 If it is set to false in the @code{Score} context
1911 it applies to all staves.
1912
1913 So this turns off extra naturals in one staff:
1914
1915 @lilypond[quote,verbatim,ragged-right]
1916 <<
1917   \new Staff \relative c'' {
1918     ais4 aes
1919   }
1920   \new Staff \relative c'' {
1921     \set Staff.extraNatural = ##f
1922     ais4 aes
1923   }
1924 >>
1925 @end lilypond
1926
1927 @noindent
1928 and this turns them off in all staves:
1929
1930 @lilypond[quote,verbatim,ragged-right]
1931 <<
1932   \new Staff \relative c'' {
1933     ais4 aes
1934   }
1935   \new Staff \relative c'' {
1936     \set Score.extraNatural = ##f
1937     ais4 aes
1938   }
1939 >>
1940 @end lilypond
1941
1942 As another example, if @code{clefOctavation} is set in
1943 the @code{Score} context this immediately changes the value
1944 of the octavation in all current staves and sets a new default
1945 value which will be applied to all staves.
1946
1947 The opposite command, @code{\unset}, effectively removes the
1948 property from the context, which causes most properties to
1949 revert to their default value.  Usually @code{\unset} is not
1950 required as a new @code{\set} command will achieve what is
1951 wanted.
1952
1953 The @code{\set} and @code{\unset} commands can appear anywhere
1954 in the input file and will take effect from the time they are
1955 encountered until the end of the score or until the property is
1956 @code{\set} or @code{\unset} again.  Let's try changing the
1957 font size, which affects the size of the note heads (among
1958 other things) several times.  The change is from the default
1959 value, not the most recently set value.
1960
1961 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
1962 c4
1963 % make note heads smaller
1964 \set fontSize = #-4
1965 d e
1966 % make note heads larger
1967 \set fontSize = #2.5
1968 f g
1969 % return to default size
1970 \unset fontSize
1971 a b
1972 @end lilypond
1973
1974 We have now seen how to set the values of several different types of
1975 property.  Note that integers and numbers are always preceded by a
1976 hash sign, @code{#}, while a true or false value is specified by
1977 @code{##t} and @code{##f}, with two hash signs.  A text property
1978 should be enclosed in double quotation signs, as above, although we
1979 shall see later that text can actually be specified in a much more
1980 general way by using the very powerful @code{\markup} command.
1981
1982 @subsubheading Setting context properties with @code{\with}
1983
1984 @funindex \with
1985 @funindex with
1986 @cindex context properties, setting with \with
1987
1988 The default value of context properties may be set at the time the
1989 context is created.  Sometimes this is a clearer way of setting a
1990 property value if it is to remain fixed for the duration of
1991 the context.  When a context is created with a @code{\new}
1992 command it may be followed immediately by a @code{\with @{ .. @}}
1993 block in which the default property values are set.  For example,
1994 if we wish to suppress the printing of extra naturals for the
1995 duration of a staff we would write:
1996
1997 @example
1998 \new Staff \with @{ extraNatural = ##f @}
1999 @end example
2000
2001 @noindent
2002 like this:
2003
2004 @lilypond[quote,verbatim,ragged-right]
2005 <<
2006   \new Staff
2007   \relative c'' {
2008     gis ges aes ais
2009   }
2010   \new Staff \with { extraNatural = ##f }
2011   \relative c'' {
2012     gis ges aes ais
2013   }
2014 >>
2015 @end lilypond
2016
2017 Or, if the property override is to be applied to all staves
2018 within the score, it may be appended to an explicit
2019 @code{\new Score} command, like this:
2020
2021 @lilypond[quote,verbatim,ragged-right]
2022 \score {
2023   \new Score \with { extraNatural = ##f } <<
2024     \new Staff {
2025       \relative c'' {
2026         gis ges aes ais
2027       }
2028     }
2029     \new Staff {
2030       \relative c'' {
2031         gis ges aes ais
2032       }
2033     }
2034   >>
2035 }
2036 @end lilypond
2037
2038 Properties set in this way may still be changed dynamically using
2039 @code{\set} and returned to the default value set in the
2040 @code{\with} block with @code{\unset}.
2041
2042 @cindex fontSize, default and setting
2043
2044 So if the @code{fontSize} property is set in a @code{\with} clause
2045 it sets the default value of the font size.  If it is later changed
2046 with @code{\set}, this new default value may be restored with the
2047 @code{\unset fontSize} command.
2048
2049 @subsubheading Setting context properties with @code{\context}
2050
2051 @cindex context properties, setting with \context
2052 @funindex \context
2053 @funindex context
2054
2055 The values of context properties may be set in @emph{all} contexts
2056 of a particular type, such as all @code{Staff} contexts, with a single
2057 command.  The context type is identified by using its
2058 type name, like @code{Staff}, prefixed by a back-slash: @code{\Staff}.
2059 The statement which sets the property value is the same as that in a
2060 @code{\with} block, introduced above.  It is placed in a
2061 @code{\context} block within a @code{\layout} block.  Each
2062 @code{\context} block will affect all contexts of the type specified
2063 throughout the @code{\score} or @code{\book} block in which the
2064 @code{\layout} block appears.  Here is a example to show the format:
2065
2066 @lilypond[verbatim,quote]
2067 \score {
2068   \new Staff {
2069     \relative c'' {
2070       cis4 e d ces
2071     }
2072   }
2073   \layout {
2074     \context {
2075       \Staff
2076       extraNatural = ##t
2077     }
2078   }
2079 }
2080 @end lilypond
2081
2082 @noindent
2083 Context properties set in this way may be overridden for particular
2084 instances of contexts by statements in a @code{\with} block, and by
2085 @code{\set} commands embedded in music statements.
2086
2087
2088 @seealso
2089 Notation Reference:
2090 @ruser{Changing context default settings}.
2091 @ruser{The set command}.
2092
2093 Internals Reference:
2094 @rinternals{Contexts},
2095 @rinternals{Tunable context properties}.
2096
2097
2098 @node Ábrázolók hozzáadása és eltávolítása
2099 @subsection Ábrázolók hozzáadása és eltávolítása
2100 @translationof Adding and removing engravers
2101
2102 @cindex engravers, adding
2103 @cindex adding engravers
2104 @cindex engravers, removing
2105 @cindex removing engravers
2106
2107 @funindex \consists
2108 @funindex consists
2109 @funindex \remove
2110 @funindex remove
2111
2112 We have seen that contexts each contain several engravers, each
2113 of which is responsible for producing a particular part of the
2114 output, like bar lines, staves, note heads, stems, etc.  If an
2115 engraver is removed from a context, it can no longer produce its
2116 output.  This is a crude way of modifying the output, but it
2117 can sometimes be useful.
2118
2119 @subsubheading Changing a single context
2120
2121 To remove an engraver from a single context we use the
2122 @code{\with} command placed immediately after the context creation
2123 command, as in the previous section.
2124
2125 As an illustration, let's repeat an example from the previous section
2126 with the staff lines removed.  Remember that the staff lines are
2127 produced by the @code{Staff_symbol_engraver}.
2128
2129 @lilypond[quote,verbatim,ragged-right]
2130 \new Staff \with {
2131   \remove Staff_symbol_engraver
2132 }
2133 \relative c' {
2134   c4
2135   \set fontSize = #-4  % make note heads smaller
2136   d e
2137   \set fontSize = #2.5  % make note heads larger
2138   f g
2139   \unset fontSize  % return to default size
2140   a b
2141 }
2142 @end lilypond
2143
2144 @cindex ambitus engraver
2145
2146 Engravers can also be added to individual contexts.
2147 The command to do this is
2148
2149 @code{\consists @var{Engraver_name}},
2150
2151 @noindent
2152 placed inside a @code{\with} block.  Some vocal scores have an ambitus
2153 placed at the beginning of a staff to indicate the range of notes in
2154 that staff -- see @rglos{ambitus}.  The ambitus is produced by the
2155 @code{Ambitus_engraver}, which is not normally included in any
2156 context.  If we add it to the @code{Voice} context, it calculates the
2157 range from that voice only:
2158
2159 @lilypond[quote,verbatim,ragged-right]
2160 \new Staff <<
2161   \new Voice \with {
2162     \consists Ambitus_engraver
2163   }
2164   \relative c'' {
2165     \voiceOne
2166     c a b g
2167   }
2168   \new Voice
2169   \relative c' {
2170     \voiceTwo
2171     c e d f
2172   }
2173 >>
2174 @end lilypond
2175
2176 @noindent
2177 but if we add the ambitus engraver to the
2178 @code{Staff} context, it calculates the range from all
2179 the notes in all the voices on that staff:
2180
2181 @lilypond[quote,verbatim,ragged-right]
2182 \new Staff \with {
2183     \consists Ambitus_engraver
2184   }
2185   <<
2186   \new Voice
2187   \relative c'' {
2188     \voiceOne
2189     c a b g
2190   }
2191   \new Voice
2192   \relative c' {
2193     \voiceTwo
2194     c e d f
2195   }
2196 >>
2197 @end lilypond
2198
2199 @subsubheading Changing all contexts of the same type
2200
2201 @funindex \layout
2202 @funindex layout
2203
2204 The examples above show how to remove or add engravers to
2205 individual contexts.  It is also possible to remove or add
2206 engravers to every context of a specific type by placing the
2207 commands in the appropriate context in a @code{\layout}
2208 block.  For example, if we wanted to show an ambitus for every
2209 staff in a four-staff score, we could write
2210
2211 @lilypond[quote,verbatim,ragged-right]
2212 \score {
2213   <<
2214     \new Staff <<
2215       \relative c'' {
2216         c a b g
2217       }
2218     >>
2219     \new Staff <<
2220       \relative c' {
2221         c a b g
2222       }
2223     >>
2224     \new Staff <<
2225       \clef "G_8"
2226       \relative c' {
2227         c a b g
2228       }
2229     >>
2230     \new Staff <<
2231       \clef "bass"
2232       \relative c {
2233         c a b g
2234       }
2235     >>
2236   >>
2237   \layout {
2238     \context {
2239       \Staff
2240       \consists Ambitus_engraver
2241     }
2242   }
2243 }
2244 @end lilypond
2245
2246 @noindent
2247 The values of context properties may also be set
2248 for all contexts of a particular type by including the
2249 @code{\set} command in a @code{\context} block in the
2250 same way.
2251
2252
2253 @seealso
2254 Notation Reference: @ruser{Modifying context plug-ins},
2255 @ruser{Changing context default settings}.
2256
2257
2258 @node A sablonok kibővítése
2259 @section A sablonok kibővítése
2260 @translationof Extending the templates
2261
2262 You've read the tutorial, you know how to write music, you
2263 understand the fundamental concepts.  But how can you
2264 get the staves that you want?  Well, you can find lots of
2265 templates (see @ref{Templates}) which may give you a start.
2266 But what if you want something that isn't covered there?  Read on.
2267
2268 @menu
2269 * Szoprán és cselló::
2270 * Négyszólamú vegyeskar::
2271 * Kotta létrehozása az alapoktól::
2272 * Kevesebb gépelés változókkal és függvényekkel::
2273 * Partitúra és szólamkották::
2274 @end menu
2275
2276 @node Szoprán és cselló
2277 @subsection Szoprán és cselló
2278 @translationof Soprano and cello
2279
2280 @cindex template, modifying
2281 @cindex modifying templates
2282
2283 Start off with the template that seems closest to what you want to
2284 end up with.  Let's say that you want to write something for
2285 soprano and cello.  In this case, we would start with the
2286 @q{Notes and lyrics} template (for the soprano part).
2287
2288 @example
2289 \version @w{"@version{}"}
2290 melody = \relative c' @{
2291   \clef treble
2292   \key c \major
2293   \time 4/4
2294   a4 b c d
2295 @}
2296
2297 text = \lyricmode @{
2298   Aaa Bee Cee Dee
2299 @}
2300
2301 \score @{
2302   <<
2303     \new Voice = "one" @{
2304       \autoBeamOff
2305       \melody
2306     @}
2307     \new Lyrics \lyricsto "one" \text
2308   >>
2309   \layout @{ @}
2310   \midi @{ @}
2311 @}
2312 @end example
2313
2314 Now we want to add a cello part.  Let's look at the @q{Notes only} example:
2315
2316 @example
2317 \version @w{"@version{}"}
2318 melody = \relative c' @{
2319   \clef treble
2320   \key c \major
2321   \time 4/4
2322   a4 b c d
2323 @}
2324
2325 \score @{
2326   \new Staff \melody
2327   \layout @{ @}
2328   \midi @{ @}
2329 @}
2330 @end example
2331
2332 We don't need two @code{\version} commands.  We'll need the
2333 @code{melody} section.  We don't want two @code{\score} sections
2334 -- if we had two @code{\score}s, we'd get the two parts separately.
2335 We want them together, as a duet.  Within the @code{\score}
2336 section, we don't need two @code{\layout} or @code{\midi}.
2337
2338 If we simply cut and paste the @code{melody} section, we would
2339 end up with two @code{melody} definitions.  This would not generate
2340 an error, but the second one would be used for both melodies.
2341 So let's rename them to make them distinct.  We'll call the
2342 section for the soprano @code{sopranoMusic} and the section for
2343 the cello @code{celloMusic}.  While we're doing this, let's rename
2344 @code{text} to be @code{sopranoLyrics}.  Remember to rename both
2345 instances of all these names -- both the initial definition (the
2346 @code{melody = \relative c' @{ } part) and the name's use (in the
2347 @code{\score} section).
2348
2349 While we're doing this, let's change the cello part's staff --
2350 celli normally use bass clef.  We'll also give the cello some
2351 different notes.
2352
2353 @example
2354 \version @w{"@version{}"}
2355 sopranoMusic = \relative c' @{
2356   \clef treble
2357   \key c \major
2358   \time 4/4
2359   a4 b c d
2360 @}
2361
2362 sopranoLyrics = \lyricmode @{
2363   Aaa Bee Cee Dee
2364 @}
2365
2366 celloMusic = \relative c @{
2367   \clef bass
2368   \key c \major
2369   \time 4/4
2370   d4 g fis8 e d4
2371 @}
2372
2373 \score @{
2374   <<
2375     \new Voice = "one" @{
2376       \autoBeamOff
2377       \sopranoMusic
2378     @}
2379     \new Lyrics \lyricsto "one" \sopranoLyrics
2380   >>
2381   \layout @{ @}
2382   \midi @{ @}
2383 @}
2384 @end example
2385
2386 This is looking promising, but the cello part won't appear in the
2387 score -- we haven't used it in the @code{\score} section.  If we
2388 want the cello part to appear under the soprano part, we need to add
2389
2390 @example
2391 \new Staff \celloMusic
2392 @end example
2393
2394 @noindent
2395 underneath the soprano stuff.  We also need to add @code{<<} and
2396 @code{>>} around the music -- that tells LilyPond that there's
2397 more than one thing (in this case, two @code{Staves}) happening
2398 at once.  The @code{\score} looks like this now:
2399
2400 @c Indentation in this example is deliberately poor
2401 @example
2402 \score @{
2403   <<
2404     <<
2405       \new Voice = "one" @{
2406         \autoBeamOff
2407         \sopranoMusic
2408       @}
2409       \new Lyrics \lyricsto "one" \sopranoLyrics
2410     >>
2411     \new Staff \celloMusic
2412   >>
2413   \layout @{ @}
2414   \midi @{ @}
2415 @}
2416 @end example
2417
2418 @noindent
2419 This looks a bit messy; the indentation is messed up now.  That is
2420 easily fixed.  Here's the complete soprano and cello template.
2421
2422 @lilypond[quote,verbatim,ragged-right,addversion]
2423 sopranoMusic = \relative c' {
2424   \clef treble
2425   \key c \major
2426   \time 4/4
2427   a4 b c d
2428 }
2429
2430 sopranoLyrics = \lyricmode {
2431   Aaa Bee Cee Dee
2432 }
2433
2434 celloMusic = \relative c {
2435   \clef bass
2436   \key c \major
2437   \time 4/4
2438   d4 g fis8 e d4
2439 }
2440
2441 \score {
2442   <<
2443     <<
2444       \new Voice = "one" {
2445         \autoBeamOff
2446         \sopranoMusic
2447       }
2448       \new Lyrics \lyricsto "one" \sopranoLyrics
2449     >>
2450     \new Staff \celloMusic
2451   >>
2452   \layout { }
2453   \midi { }
2454 }
2455 @end lilypond
2456
2457
2458 @seealso
2459 The starting templates can be found in the @q{Templates} appendix,
2460 see @ref{Single staff}.
2461
2462
2463 @node Négyszólamú vegyeskar
2464 @subsection Négyszólamú vegyeskar
2465 @translationof Four-part SATB vocal score
2466
2467 @cindex template, SATB
2468 @cindex SATB template
2469
2470 Most vocal scores of music written for four-part mixed choir
2471 with orchestral accompaniment such as Mendelssohn's Elijah or
2472 Handel's Messiah have the choral music and words on four
2473 staves, one for each of SATB, with a piano reduction of the
2474 orchestral accompaniment underneath.  Here's an example
2475 from Handel's Messiah:
2476
2477 @c The following should appear as music without code
2478 @lilypond[quote,ragged-right]
2479 global = { \key d \major \time 4/4 }
2480 sopranoMusic = \relative c'' {
2481   \clef "treble"
2482   r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2483 }
2484 sopranoWords = \lyricmode {
2485   Wor -- thy is the lamb that was slain
2486 }
2487 altoMusic = \relative a' {
2488   \clef "treble"
2489   r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
2490 }
2491 altoWords = \sopranoWords
2492 tenorMusic = \relative c' {
2493   \clef "G_8"
2494   r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2495 }
2496 tenorWords = \sopranoWords
2497 bassMusic = \relative c' {
2498   \clef "bass"
2499   r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2500 }
2501 bassWords = \sopranoWords
2502 upper = \relative a' {
2503   \clef "treble"
2504   \global
2505   r4 <a d fis>2 <a e' a>4
2506   <d fis d'>4. <d fis d'>8 <a d a'>2
2507   <g cis g'>4 <a d fis> <a cis e>2
2508 }
2509 lower = \relative c, {
2510   \clef "bass"
2511   \global
2512   <d d'>4 <d d'>2 <cis cis'>4
2513   <b b'>4. <b' b'>8 <fis fis'>2
2514   <e e'>4 <d d'> <a' a'>2
2515 }
2516
2517 \score {
2518   <<  % combine ChoirStaff and PianoStaff in parallel
2519     \new ChoirStaff <<
2520       \new Staff = "sopranos" <<
2521         \set Staff.instrumentName = #"Soprano"
2522         \new Voice = "sopranos" {
2523           \global
2524           \sopranoMusic
2525         }
2526       >>
2527       \new Lyrics \lyricsto "sopranos" {
2528         \sopranoWords
2529       }
2530       \new Staff = "altos" <<
2531         \set Staff.instrumentName = #"Alto"
2532         \new Voice = "altos" {
2533           \global
2534           \altoMusic
2535         }
2536       >>
2537       \new Lyrics \lyricsto "altos" { \altoWords }
2538       \new Staff = "tenors" <<
2539         \set Staff.instrumentName = #"Tenor"
2540         \new Voice = "tenors" {
2541           \global
2542           \tenorMusic
2543         }
2544       >>
2545       \new Lyrics \lyricsto "tenors" { \tenorWords }
2546       \new Staff = "basses" <<
2547         \set Staff.instrumentName = #"Bass"
2548         \new Voice = "basses" {
2549           \global
2550           \bassMusic
2551         }
2552       >>
2553       \new Lyrics \lyricsto "basses" {
2554         \bassWords
2555       }
2556     >>  % end ChoirStaff
2557     \new PianoStaff <<
2558       \set PianoStaff.instrumentName = #"Piano"
2559       \new Staff = "upper" \upper
2560       \new Staff = "lower" \lower
2561     >>
2562   >>
2563 }
2564 @end lilypond
2565
2566 None of the templates provides this layout exactly.  The nearest is
2567 @q{SATB vocal score and automatic piano reduction} -- see @ref{Vocal
2568 ensembles} -- but we need to change the layout and add a piano
2569 accompaniment which is not derived automatically from the vocal parts.
2570 The variables holding the music and words for the vocal parts are
2571 fine, but we shall need to add variables for the piano reduction.
2572
2573 The order in which the contexts appear in the ChoirStaff of the
2574 template do not correspond with the order in the vocal score shown
2575 above.  We need to rearrange them so there are four staves with the
2576 words written directly underneath the notes for each part.  All the
2577 voices should be @code{\voiceOne}, which is the default, so the
2578 @code{\voiceXXX} commands should be removed.  We also need to specify
2579 the tenor clef for the tenors.  The way in which lyrics are specified
2580 in the template has not yet been encountered so we need to use the
2581 method with which we are familiar.  We should also add the names of
2582 each staff.
2583
2584 Doing this gives for our ChoirStaff:
2585
2586 @example
2587     \new ChoirStaff <<
2588       \new Staff = "sopranos" <<
2589         \set Staff.instrumentName = #"Soprano"
2590         \new Voice = "sopranos" @{
2591           \global
2592           \sopranoMusic
2593         @}
2594       >>
2595       \new Lyrics \lyricsto "sopranos" @{
2596         \sopranoWords
2597      @}
2598       \new Staff = "altos" <<
2599         \set Staff.instrumentName = #"Alto"
2600         \new Voice = "altos" @{
2601           \global
2602           \altoMusic
2603         @}
2604       >>
2605       \new Lyrics \lyricsto "altos" @{
2606         \altoWords
2607       @}
2608       \new Staff = "tenors" <<
2609         \set Staff.instrumentName = #"Tenor"
2610         \new Voice = "tenors" @{
2611           \global
2612           \tenorMusic
2613         @}
2614       >>
2615       \new Lyrics \lyricsto "tenors" @{
2616         \tenorWords
2617       @}
2618       \new Staff = "basses" <<
2619         \set Staff.instrumentName = #"Bass"
2620         \new Voice = "basses" @{
2621           \global
2622           \bassMusic
2623         @}
2624       >>
2625       \new Lyrics \lyricsto "basses" @{
2626         \bassWords
2627       @}
2628     >>  % end ChoirStaff
2629 @end example
2630
2631 Next we must work out the piano part.  This is
2632 easy - we just pull out the piano part from the
2633 @q{Solo piano} template:
2634
2635 @example
2636 \new PianoStaff <<
2637   \set PianoStaff.instrumentName = #"Piano  "
2638   \new Staff = "upper" \upper
2639   \new Staff = "lower" \lower
2640 >>
2641 @end example
2642
2643 and add the variable definitions for @code{upper}
2644 and @code{lower}.
2645
2646 The ChoirStaff and PianoStaff must be combined
2647 using angle brackets as we want them to be
2648 stacked one above the other:
2649
2650 @example
2651 <<  % combine ChoirStaff and PianoStaff one above the other
2652   \new ChoirStaff <<
2653     \new Staff = "sopranos" <<
2654       \new Voice = "sopranos" @{
2655         \global
2656         \sopranoMusic
2657       @}
2658     >>
2659     \new Lyrics \lyricsto "sopranos" @{
2660       \sopranoWords
2661      @}
2662     \new Staff = "altos" <<
2663       \new Voice = "altos" @{
2664         \global
2665         \altoMusic
2666       @}
2667     >>
2668     \new Lyrics \lyricsto "altos" @{
2669       \altoWords
2670     @}
2671     \new Staff = "tenors" <<
2672       \clef "G_8"  % tenor clef
2673       \new Voice = "tenors" @{
2674         \global
2675         \tenorMusic
2676       @}
2677     >>
2678     \new Lyrics \lyricsto "tenors" @{
2679       \tenorWords
2680     @}
2681     \new Staff = "basses" <<
2682       \clef "bass"
2683       \new Voice = "basses" @{
2684         \global
2685         \bassMusic
2686       @}
2687     >>
2688     \new Lyrics \lyricsto "basses" @{
2689       \bassWords
2690     @}
2691   >>  % end ChoirStaff
2692
2693   \new PianoStaff <<
2694     \set PianoStaff.instrumentName = #"Piano"
2695     \new Staff = "upper" \upper
2696     \new Staff = "lower" \lower
2697   >>
2698 >>
2699 @end example
2700
2701 Combining all these together and adding the music
2702 for the three bars of the example above gives:
2703
2704 @lilypond[quote,verbatim,ragged-right,addversion]
2705 global = {
2706   \key d \major
2707   \time 4/4
2708 }
2709 sopranoMusic = \relative c'' {
2710   \clef "treble"
2711   r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2712 }
2713 sopranoWords = \lyricmode {
2714   Wor -- thy is the lamb that was slain
2715 }
2716 altoMusic = \relative a' {
2717   \clef "treble"
2718   r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
2719 }
2720 altoWords = \sopranoWords
2721 tenorMusic = \relative c' {
2722   \clef "G_8"
2723   r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2724 }
2725 tenorWords = \sopranoWords
2726 bassMusic = \relative c' {
2727   \clef "bass"
2728   r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2729 }
2730 bassWords = \sopranoWords
2731 upper = \relative a' {
2732   \clef "treble"
2733   \global
2734   r4 <a d fis>2 <a e' a>4
2735   <d fis d'>4. <d fis d'>8 <a d a'>2
2736   <g cis g'>4 <a d fis> <a cis e>2
2737 }
2738 lower = \relative c, {
2739   \clef "bass"
2740   \global
2741   <d d'>4 <d d'>2 <cis cis'>4
2742   <b b'>4. <b' b'>8 <fis fis'>2
2743   <e e'>4 <d d'> <a' a'>2
2744 }
2745
2746 \score {
2747   <<  % combine ChoirStaff and PianoStaff in parallel
2748     \new ChoirStaff <<
2749       \new Staff = "sopranos" <<
2750         \set Staff.instrumentName = #"Soprano"
2751         \new Voice = "sopranos" {
2752           \global
2753           \sopranoMusic
2754         }
2755       >>
2756       \new Lyrics \lyricsto "sopranos" {
2757         \sopranoWords
2758       }
2759       \new Staff = "altos" <<
2760         \set Staff.instrumentName = #"Alto"
2761         \new Voice = "altos" {
2762           \global
2763           \altoMusic
2764         }
2765       >>
2766       \new Lyrics \lyricsto "altos" {
2767         \altoWords
2768       }
2769       \new Staff = "tenors" <<
2770         \set Staff.instrumentName = #"Tenor"
2771         \new Voice = "tenors" {
2772           \global
2773           \tenorMusic
2774         }
2775       >>
2776       \new Lyrics \lyricsto "tenors" {
2777         \tenorWords
2778       }
2779       \new Staff = "basses" <<
2780         \set Staff.instrumentName = #"Bass"
2781         \new Voice = "basses" {
2782           \global
2783           \bassMusic
2784         }
2785       >>
2786       \new Lyrics \lyricsto "basses" {
2787         \bassWords
2788       }
2789     >>  % end ChoirStaff
2790
2791     \new PianoStaff <<
2792       \set PianoStaff.instrumentName = #"Piano  "
2793       \new Staff = "upper" \upper
2794       \new Staff = "lower" \lower
2795     >>
2796   >>
2797 }
2798 @end lilypond
2799
2800
2801 @node Kotta létrehozása az alapoktól
2802 @subsection Kotta létrehozása az alapoktól
2803 @translationof Building a score from scratch
2804
2805 @cindex template, writing your own
2806 @cindex example of writing a score
2807 @cindex writing a score, example
2808 @cindex score, example of writing
2809
2810 After gaining some facility with writing LilyPond code, you
2811 may find that it is easier to build a score from scratch
2812 rather than modifying one of the templates.  You can also
2813 develop your own style this way to suit the sort of music you
2814 like.  Let's see how to put together the score for an organ
2815 prelude as an example.
2816
2817 We begin with a header section.  Here go the title, name
2818 of composer, etc, then come any variable definitions, and
2819 finally the score block.  Let's start with these in outline
2820 and fill in the details later.
2821
2822 We'll use the first two bars of Bach's prelude
2823 based on @emph{Jesu, meine Freude} which is written for two
2824 manuals and pedal organ.  You can see these two bars of music
2825 at the bottom of this section.  The top manual part has two voices,
2826 the lower and pedal organ one each.  So we need four
2827 music definitions and one to define the time signature
2828 and key:
2829
2830 @example
2831 \version @w{"@version{}"}
2832 \header @{
2833   title = "Jesu, meine Freude"
2834   composer = "J S Bach"
2835 @}
2836 TimeKey = @{
2837   \time 4/4
2838   \key c \minor
2839 @}
2840 ManualOneVoiceOneMusic = @{ s1 @}
2841 ManualOneVoiceTwoMusic = @{ s1 @}
2842 ManualTwoMusic = @{ s1 @}
2843 PedalOrganMusic = @{ s1 @}
2844
2845 \score @{
2846 @}
2847 @end example
2848
2849 For now we've just used a spacer note, @code{s1},
2850 instead of the real music.  We'll add that later.
2851
2852 Next let's see what should go in the score block.
2853 We simply mirror the staff structure we want.
2854 Organ music is usually written on three staves,
2855 one for each manual and one for the pedals.  The
2856 manual staves should be bracketed together, so we
2857 need to use a PianoStaff for them.  The first
2858 manual part needs two voices and the second manual
2859 part just one.
2860
2861 @example
2862   \new PianoStaff <<
2863     \new Staff = "ManualOne" <<
2864       \new Voice @{
2865         \ManualOneVoiceOneMusic
2866       @}
2867       \new Voice @{
2868         \ManualOneVoiceTwoMusic
2869       @}
2870     >>  % end ManualOne Staff context
2871     \new Staff = "ManualTwo" <<
2872       \new Voice @{
2873         \ManualTwoMusic
2874       @}
2875     >>  % end ManualTwo Staff context
2876   >>  % end PianoStaff context
2877 @end example
2878
2879 Next we need to add a staff for the pedal organ.
2880 This goes underneath the PianoStaff, but it must
2881 be simultaneous with it, so we need angle brackets
2882 around the two.  Missing these out would generate
2883 an error in the log file.  It's a common mistake
2884 which you'll make sooner or later!  Try copying
2885 the final example at the end of this section,
2886 remove these angle brackets, and compile it to
2887 see what errors it generates.
2888
2889 @example
2890 <<  % PianoStaff and Pedal Staff must be simultaneous
2891   \new PianoStaff <<
2892     \new Staff = "ManualOne" <<
2893       \new Voice @{
2894         \ManualOneVoiceOneMusic
2895       @}
2896       \new Voice @{
2897         \ManualOneVoiceTwoMusic
2898       @}
2899     >>  % end ManualOne Staff context
2900     \new Staff = "ManualTwo" <<
2901       \new Voice @{
2902         \ManualTwoMusic
2903       @}
2904     >>  % end ManualTwo Staff context
2905   >>  % end PianoStaff context
2906   \new Staff = "PedalOrgan" <<
2907     \new Voice @{
2908       \PedalOrganMusic
2909     @}
2910   >>
2911 >>
2912 @end example
2913
2914 It is not necessary to use the simultaneous construct
2915 @code{<< .. >>} for the manual two staff and the pedal organ staff,
2916 since they contain only one music expression, but it does no harm,
2917 and always using angle brackets after @code{\new Staff} is a good
2918 habit to cultivate in case there are multiple voices.  The opposite
2919 is true for Voices: these should habitually be followed by braces
2920 @code{@{ .. @}} in case your music is coded in several variables
2921 which need to run consecutively.
2922
2923 Let's add this structure to the score block, and adjust the indenting.
2924 We also add the appropriate clefs, ensure stems, ties and slurs in
2925 each voice on the upper staff point to the right direction with
2926 @code{\voiceOne} and @code{\voiceTwo}, and enter the time signature
2927 and key to each staff using our predefined variable, @code{\TimeKey}.
2928
2929 @example
2930 \score @{
2931   <<  % PianoStaff and Pedal Staff must be simultaneous
2932     \new PianoStaff <<
2933       \new Staff = "ManualOne" <<
2934         \TimeKey  % set time signature and key
2935         \clef "treble"
2936         \new Voice @{
2937           \voiceOne
2938           \ManualOneVoiceOneMusic
2939         @}
2940         \new Voice @{
2941           \voiceTwo
2942           \ManualOneVoiceTwoMusic
2943         @}
2944       >>  % end ManualOne Staff context
2945       \new Staff = "ManualTwo" <<
2946         \TimeKey
2947         \clef "bass"
2948         \new Voice @{
2949           \ManualTwoMusic
2950         @}
2951       >>  % end ManualTwo Staff context
2952     >>  % end PianoStaff context
2953     \new Staff = "PedalOrgan" <<
2954       \TimeKey
2955       \clef "bass"
2956       \new Voice @{
2957         \PedalOrganMusic
2958       @}
2959     >>  % end PedalOrgan Staff
2960   >>
2961 @}  % end Score context
2962 @end example
2963
2964 That completes the structure.  Any three-staff organ music
2965 will have a similar structure, although the number of voices
2966 may vary.  All that remains now
2967 is to add the music, and combine all the parts together.
2968
2969 @lilypond[quote,verbatim,ragged-right,addversion]
2970 \header {
2971   title = "Jesu, meine Freude"
2972   composer = "J S Bach"
2973 }
2974 TimeKey = {
2975   \time 4/4
2976   \key c \minor
2977 }
2978 ManualOneVoiceOneMusic = \relative g' {
2979   g4 g f ees
2980   d2 c2
2981 }
2982 ManualOneVoiceTwoMusic = \relative c' {
2983   ees16 d ees8~ ees16 f ees d c8 d~ d c~
2984   c c4 b8 c8. g16 c b c d
2985 }
2986 ManualTwoMusic = \relative c' {
2987   c16 b c8~ c16 b c g a8 g~ g16 g aes ees
2988   f ees f d g aes g f ees d e8~ ees16 f ees d
2989 }
2990 PedalOrganMusic = \relative c {
2991   r8 c16 d ees d ees8~ ees16 a, b g c b c8
2992   r16 g ees f g f g8 c,2
2993 }
2994
2995 \score {
2996   <<  % PianoStaff and Pedal Staff must be simultaneous
2997     \new PianoStaff <<
2998       \new Staff = "ManualOne" <<
2999         \TimeKey  % set time signature and key
3000         \clef "treble"
3001         \new Voice {
3002           \voiceOne
3003           \ManualOneVoiceOneMusic
3004         }
3005         \new Voice {
3006           \voiceTwo
3007           \ManualOneVoiceTwoMusic
3008         }
3009       >>  % end ManualOne Staff context
3010       \new Staff = "ManualTwo" <<
3011         \TimeKey
3012         \clef "bass"
3013         \new Voice {
3014           \ManualTwoMusic
3015         }
3016       >>  % end ManualTwo Staff context
3017     >>  % end PianoStaff context
3018     \new Staff = "PedalOrgan" <<
3019       \TimeKey
3020       \clef "bass"
3021       \new Voice {
3022         \PedalOrganMusic
3023       }
3024     >>  % end PedalOrgan Staff context
3025   >>
3026 }  % end Score context
3027 @end lilypond
3028
3029
3030 @node Kevesebb gépelés változókkal és függvényekkel
3031 @subsection Kevesebb gépelés változókkal és függvényekkel
3032 @translationof Saving typing with variables and functions
3033
3034 @cindex variables
3035 @cindex variables
3036
3037 By this point, you've seen this kind of thing:
3038
3039 @lilypond[quote,verbatim,ragged-right]
3040 hornNotes = \relative c'' { c4 b dis c }
3041 \score {
3042   {
3043     \hornNotes
3044   }
3045 }
3046 @end lilypond
3047
3048 You may even realize that this could be useful in minimalist music:
3049
3050 @lilypond[quote,verbatim,ragged-right]
3051 fragmentA = \relative c'' { a4 a8. b16 }
3052 fragmentB = \relative c'' { a8. gis16 ees4 }
3053 violin = \new Staff {
3054   \fragmentA
3055   \fragmentA
3056   \fragmentB
3057   \fragmentA
3058 }
3059 \score {
3060   {
3061     \violin
3062   }
3063 }
3064 @end lilypond
3065
3066 However, you can also use these variables (also known as
3067 macros, or user-defined commands) for tweaks:
3068
3069 @c TODO Avoid padtext - not needed with skylining
3070 @lilypond[quote,verbatim,ragged-right]
3071 dolce = \markup { \italic \bold dolce }
3072 padText = { \once \override TextScript #'padding = #5.0 }
3073 fthenp=_\markup { \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p }
3074 violin = \relative c'' {
3075   \repeat volta 2 {
3076     c4._\dolce b8 a8 g a b
3077     \padText
3078     c4.^"hi there!" d8 e' f g d
3079     c,4.\fthenp b8 c4 c-.
3080   }
3081 }
3082 \score {
3083   {
3084     \violin
3085   }
3086 \layout { ragged-right=##t }
3087 }
3088 @end lilypond
3089
3090 These variables are obviously useful for saving
3091 typing.  But they're worth considering even if you
3092 only use them once -- they reduce complexity.  Let's
3093 look at the previous example without any
3094 variables.  It's a lot harder to read, especially
3095 the last line.
3096
3097 @example
3098 violin = \relative c'' @{
3099   \repeat volta 2 @{
3100     c4._\markup @{ \italic \bold dolce @} b8 a8 g a b
3101     \once \override TextScript #'padding = #5.0
3102     c4.^"hi there!" d8 e' f g d
3103     c,4.\markup @{ \dynamic f \italic \small @{ 2nd @}
3104       \hspace #0.1 \dynamic p @}
3105     b8 c4 c-.
3106   @}
3107 @}
3108 @end example
3109
3110 @c TODO Replace the following with a better example  -td
3111 @c Skylining handles this correctly without padText
3112
3113 So far we've seen static substitution -- when LilyPond
3114 sees @code{\padText}, it replaces it with the stuff that
3115 we've defined it to be (ie the stuff to the right of
3116 @code{padtext=}).
3117
3118 LilyPond can handle non-static substitution, too (you
3119 can think of these as functions).
3120
3121 @lilypond[quote,verbatim,ragged-right]
3122 padText =
3123 #(define-music-function (parser location padding) (number?)
3124   #{
3125     \once \override TextScript #'padding = #$padding
3126   #})
3127
3128 \relative c''' {
3129   c4^"piu mosso" b a b
3130   \padText #1.8
3131   c4^"piu mosso" d e f
3132   \padText #2.6
3133   c4^"piu mosso" fis a g
3134 }
3135 @end lilypond
3136
3137 Using variables is also a good way to reduce work if the
3138 LilyPond input syntax changes (see
3139 @rprogram{Updating files with convert-ly}).  If
3140 you have a single definition (such as @code{\dolce}) for all your
3141 input files (see @ref{Style sheets}), then if the syntax changes, you
3142 only need to update your single @code{\dolce} definition,
3143 instead of making changes throughout every @file{.ly} file.
3144
3145
3146 @node Partitúra és szólamkották
3147 @subsection Partitúra és szólamkották
3148 @translationof Scores and parts
3149
3150 In orchestral music, all notes are printed twice.  Once in a part for
3151 the musicians, and once in a full score for the conductor.  Variables can
3152 be used to avoid double work.  The music is entered once, and stored in
3153 a variable.  The contents of that variable is then used to generate
3154 both the part and the full score.
3155
3156 It is convenient to define the notes in a special file.  For example,
3157 suppose that the file @file{horn-music.ly} contains the following part
3158 of a horn/@/bassoon duo
3159
3160 @example
3161 hornNotes = \relative c @{
3162   \time 2/4
3163   r4 f8 a cis4 f e d
3164 @}
3165 @end example
3166
3167 @noindent
3168 Then, an individual part is made by putting the following in a file
3169
3170 @example
3171 \include "horn-music.ly"
3172 \header @{
3173   instrument = "Horn in F"
3174 @}
3175
3176 @{
3177  \transpose f c' \hornNotes
3178 @}
3179 @end example
3180
3181 The line
3182
3183 @example
3184 \include "horn-music.ly"
3185 @end example
3186
3187 @noindent
3188 substitutes the contents of @file{horn-music.ly} at this position in
3189 the file, so @code{hornNotes} is defined afterwards.  The command
3190 @code{\transpose f@tie{}c'} indicates that the argument, being
3191 @code{\hornNotes}, should be transposed by a fifth upwards.  Sounding
3192 @code{f} is denoted by notated @code{c'}, which corresponds with the
3193 tuning of a normal French Horn in@tie{}F.  The transposition can be seen
3194 in the following output
3195
3196 @lilypond[quote,ragged-right]
3197 \transpose f c' \relative c {
3198   \time 2/4
3199   r4 f8 a cis4 f e d
3200 }
3201 @end lilypond
3202
3203 In ensemble pieces, one of the voices often does not play for many
3204 measures.  This is denoted by a special rest, the multi-measure
3205 rest.  It is entered with a capital @code{R} followed by a duration
3206 (@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
3207 etc.).  By multiplying the
3208 duration, longer rests can be constructed.  For example, this rest
3209 takes 3@tie{}measures in 2/4 time
3210
3211 @example
3212 R2*3
3213 @end example
3214
3215 When printing the part, multi-rests
3216 must be condensed.  This is done by setting a run-time variable
3217
3218 @example
3219 \set Score.skipBars = ##t
3220 @end example
3221
3222 @noindent
3223 This command sets the property @code{skipBars} in the
3224 @code{Score} context to true (@code{##t}).  Prepending the rest and
3225 this option to the music above, leads to the following result
3226
3227 @lilypond[quote,ragged-right]
3228 \transpose f c' \relative c {
3229   \time 2/4
3230   \set Score.skipBars = ##t
3231   R2*3
3232   r4 f8 a cis4 f e d
3233 }
3234 @end lilypond
3235
3236
3237 The score is made by combining all of the music together.  Assuming
3238 that the other voice is in @code{bassoonNotes} in the file
3239 @file{bassoon-music.ly}, a score is made with
3240
3241 @example
3242 \include "bassoon-music.ly"
3243 \include "horn-music.ly"
3244
3245 <<
3246   \new Staff \hornNotes
3247   \new Staff \bassoonNotes
3248 >>
3249 @end example
3250
3251 @noindent
3252 leading to
3253
3254 @lilypond[quote,ragged-right]
3255 \relative c <<
3256   \new Staff {
3257     \time 2/4
3258     R2*3
3259     r4 f8 a cis4 f e d
3260   }
3261   \new Staff {
3262     \clef bass
3263     r4 d,8 f | gis4 c | b bes |
3264     a8 e f4 | g d | gis f |
3265   }
3266 >>
3267 @end lilypond