]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/hu/learning/fundamental.itely
Release: bump/rewind VERSION
[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.17.29"
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 \tuplet 3/2 {r16 e'8] }
486   g16( a \tuplet 3/2 {b d) e' }
487   g8[( a \tuplet 3/2 {b d') e'~]}
488   \tuplet 5/4 {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 @translationof Engravers explained
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 @item Dynamic_engraver
1753   @tab Creates hairpins and dynamic texts
1754 @item Forbid_line_break_engraver
1755   @tab Prevents line breaks if a musical element is still active
1756 @item Key_engraver
1757   @tab Creates the key signature
1758 @item Metronome_mark_engraver
1759   @tab Engraves metronome marking
1760 @item Note_heads_engraver
1761   @tab Engraves note heads
1762 @item Rest_engraver
1763   @tab Engraves rests
1764 @item Staff_symbol_engraver
1765   @tab Engraves the five (by default) lines of the staff
1766 @item Stem_engraver
1767   @tab Creates stems and single-stem tremolos
1768 @item Time_signature_engraver
1769   @tab Creates time signatures
1770 @end multitable
1771
1772 @smallspace
1773
1774 We shall see later how the output of LilyPond can be changed
1775 by modifying the action of Engravers.
1776
1777
1778 @seealso
1779 Internals reference: @rinternals{Engravers and Performers}.
1780
1781
1782 @node Kontextusok tulajdonságainak módosítása
1783 @subsection Kontextusok tulajdonságainak módosítása
1784 @translationof Modifying context properties
1785
1786 @cindex context properties
1787 @cindex context properties, modifying
1788 @cindex modifying context properties
1789 @funindex \set
1790 @funindex set
1791 @funindex \unset
1792 @funindex unset
1793
1794 Contexts are responsible for holding the values of a number of
1795 context @emph{properties}.  Many of them can be changed to
1796 influence the interpretation of the input and so change the
1797 appearance of the output.  They are changed by the
1798 @code{\set} command.  This takes the form
1799
1800 @example
1801 \set @emph{ContextName}.@emph{propertyName} = #@emph{value}
1802 @end example
1803
1804 Where the @emph{ContextName} is usually @code{Score},
1805 @code{Staff} or @code{Voice}.  It may be omitted,
1806 in which case the current context (typically @code{Voice}) is assumed.
1807
1808 The names of context properties consist of words joined
1809 together with no hyphens or underscores, all except the
1810 first having a capital letter.  Here are a few examples
1811 of some commonly used ones.  There are many more.
1812
1813 @c attempt to force this onto a new page
1814 @need 50
1815 @multitable @columnfractions .25 .15 .45 .15
1816 @headitem propertyName
1817   @tab Type
1818   @tab Function
1819   @tab Example Value
1820 @item extraNatural
1821   @tab Boolean
1822   @tab If true, set extra natural signs before accidentals
1823   @tab @code{#t}, @code{#f}
1824 @item currentBarNumber
1825   @tab Integer
1826   @tab Set the current bar number
1827   @tab @code{50}
1828 @item doubleSlurs
1829   @tab Boolean
1830   @tab If true, print slurs both above and below notes
1831   @tab @code{#t}, @code{#f}
1832 @item instrumentName
1833   @tab Text
1834   @tab Set the name to be placed at the start of the staff
1835   @tab @code{"Cello I"}
1836 @item fontSize
1837   @tab Real
1838   @tab Increase or decrease the font size
1839   @tab @code{2.4}
1840 @item stanza
1841   @tab Text
1842   @tab Set the text to print before the start of a verse
1843   @tab @code{"2"}
1844 @end multitable
1845
1846 @noindent
1847 where a Boolean is either True (@code{#t}) or False (@code{#f}),
1848 an Integer is a positive whole number, a Real is a positive
1849 or negative decimal number, and text is enclosed in double
1850 apostrophes.  Note the occurrence of hash signs,
1851 (@code{#}), in two different places -- as part of the Boolean
1852 value before the @code{t} or @code{f}, and before @emph{value}
1853 in the @code{\set} statement.  So when a Boolean is being
1854 entered you need to code two hash signs, e.g., @code{##t}.
1855
1856 @cindex properties operating in contexts
1857 @cindex setting properties within contexts
1858
1859 Before we can set any of these properties we need to know
1860 in which context they operate.  Sometimes this is obvious,
1861 but occasionally it can be tricky.  If the wrong context
1862 is specified, no error message is produced, but the expected
1863 action will not take place.  For example, the
1864 @code{instrumentName} clearly lives in the @code{Staff} context, since
1865 it is the staff that is to be named.
1866 In this example the first staff is labeled, but not the second,
1867 because we omitted the context name.
1868
1869 @lilypond[quote,verbatim,ragged-right]
1870 <<
1871   \new Staff \relative c'' {
1872     \set Staff.instrumentName = #"Soprano"
1873     c4 c
1874  }
1875   \new Staff \relative c' {
1876   \set instrumentName = #"Alto"  % Wrong!
1877   d4 d
1878  }
1879 >>
1880 @end lilypond
1881
1882 Remember the default context name is @code{Voice}, so the second
1883 @code{\set} command set the property @code{instrumentName} in the
1884 @code{Voice} context to @qq{Alto}, but as LilyPond does not look
1885 for any such property in the @code{Voice} context, no
1886 further action took place.  This is not an error, and no error
1887 message is logged in the log file.
1888
1889 Similarly, if the property name is mis-spelt no error message is
1890 produced, and clearly the expected action cannot be performed.  In
1891 fact, you can set any (fictitious) @q{property} using any name you
1892 like in any context that exists by using the @code{\set} command.  But
1893 if the name is not known to LilyPond it will not cause any action to
1894 be taken.  Some text editors with special support for LilyPond input
1895 files document property names with bullets when you hover them with
1896 the mouse, like JEdit with LilyPondTool, or highlight unknown property
1897 names differently, like ConTEXT.  If you do not use an editor with
1898 such features, it is recommended to check the property name in the
1899 Internals Reference: see @rinternals{Tunable context properties}, or
1900 @rinternals{Contexts}.
1901
1902 The @code{instrumentName} property will take effect only
1903 if it is set in the @code{Staff} context, but
1904 some properties can be set in more than one context.
1905 For example, the property @code{extraNatural} is by
1906 default set to ##t (true) for all staves.
1907 If it is set to ##f (false) in one particular @code{Staff}
1908 context it applies just to the accidentals on that staff.
1909 If it is set to false in the @code{Score} context
1910 it applies to all staves.
1911
1912 So this turns off extra naturals in one staff:
1913
1914 @lilypond[quote,verbatim,ragged-right]
1915 <<
1916   \new Staff \relative c'' {
1917     ais4 aes
1918   }
1919   \new Staff \relative c'' {
1920     \set Staff.extraNatural = ##f
1921     ais4 aes
1922   }
1923 >>
1924 @end lilypond
1925
1926 @noindent
1927 and this turns them off in all staves:
1928
1929 @lilypond[quote,verbatim,ragged-right]
1930 <<
1931   \new Staff \relative c'' {
1932     ais4 aes
1933   }
1934   \new Staff \relative c'' {
1935     \set Score.extraNatural = ##f
1936     ais4 aes
1937   }
1938 >>
1939 @end lilypond
1940
1941 As another example, if @code{clefTransposition} is set in
1942 the @code{Score} context this immediately changes the value
1943 of the octavation in all current staves and sets a new default
1944 value which will be applied to all staves.
1945
1946 The opposite command, @code{\unset}, effectively removes the
1947 property from the context, which causes most properties to
1948 revert to their default value.  Usually @code{\unset} is not
1949 required as a new @code{\set} command will achieve what is
1950 wanted.
1951
1952 The @code{\set} and @code{\unset} commands can appear anywhere
1953 in the input file and will take effect from the time they are
1954 encountered until the end of the score or until the property is
1955 @code{\set} or @code{\unset} again.  Let's try changing the
1956 font size, which affects the size of the note heads (among
1957 other things) several times.  The change is from the default
1958 value, not the most recently set value.
1959
1960 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
1961 c4
1962 % make note heads smaller
1963 \set fontSize = #-4
1964 d e
1965 % make note heads larger
1966 \set fontSize = #2.5
1967 f g
1968 % return to default size
1969 \unset fontSize
1970 a b
1971 @end lilypond
1972
1973 We have now seen how to set the values of several different types of
1974 property.  Note that integers and numbers are always preceded by a
1975 hash sign, @code{#}, while a true or false value is specified by
1976 @code{##t} and @code{##f}, with two hash signs.  A text property
1977 should be enclosed in double quotation signs, as above, although we
1978 shall see later that text can actually be specified in a much more
1979 general way by using the very powerful @code{\markup} command.
1980
1981 @subsubheading Setting context properties with @code{\with}
1982
1983 @funindex \with
1984 @funindex with
1985 @cindex context properties, setting with \with
1986
1987 The default value of context properties may be set at the time the
1988 context is created.  Sometimes this is a clearer way of setting a
1989 property value if it is to remain fixed for the duration of
1990 the context.  When a context is created with a @code{\new}
1991 command it may be followed immediately by a @code{\with @{ .. @}}
1992 block in which the default property values are set.  For example,
1993 if we wish to suppress the printing of extra naturals for the
1994 duration of a staff we would write:
1995
1996 @example
1997 \new Staff \with @{ extraNatural = ##f @}
1998 @end example
1999
2000 @noindent
2001 like this:
2002
2003 @lilypond[quote,verbatim,ragged-right]
2004 <<
2005   \new Staff
2006   \relative c'' {
2007     gis ges aes ais
2008   }
2009   \new Staff \with { extraNatural = ##f }
2010   \relative c'' {
2011     gis ges aes ais
2012   }
2013 >>
2014 @end lilypond
2015
2016 Or, if the property override is to be applied to all staves
2017 within the score, it may be appended to an explicit
2018 @code{\new Score} command, like this:
2019
2020 @lilypond[quote,verbatim,ragged-right]
2021 \score {
2022   \new Score \with { extraNatural = ##f } <<
2023     \new Staff {
2024       \relative c'' {
2025         gis ges aes ais
2026       }
2027     }
2028     \new Staff {
2029       \relative c'' {
2030         gis ges aes ais
2031       }
2032     }
2033   >>
2034 }
2035 @end lilypond
2036
2037 Properties set in this way may still be changed dynamically using
2038 @code{\set} and returned to the default value set in the
2039 @code{\with} block with @code{\unset}.
2040
2041 @cindex fontSize, default and setting
2042
2043 So if the @code{fontSize} property is set in a @code{\with} clause
2044 it sets the default value of the font size.  If it is later changed
2045 with @code{\set}, this new default value may be restored with the
2046 @code{\unset fontSize} command.
2047
2048 @subsubheading Setting context properties with @code{\context}
2049
2050 @cindex context properties, setting with \context
2051 @funindex \context
2052 @funindex context
2053
2054 The values of context properties may be set in @emph{all} contexts
2055 of a particular type, such as all @code{Staff} contexts, with a single
2056 command.  The context type is identified by using its
2057 type name, like @code{Staff}, prefixed by a back-slash: @code{\Staff}.
2058 The statement which sets the property value is the same as that in a
2059 @code{\with} block, introduced above.  It is placed in a
2060 @code{\context} block within a @code{\layout} block.  Each
2061 @code{\context} block will affect all contexts of the type specified
2062 throughout the @code{\score} or @code{\book} block in which the
2063 @code{\layout} block appears.  Here is a example to show the format:
2064
2065 @lilypond[verbatim,quote]
2066 \score {
2067   \new Staff {
2068     \relative c'' {
2069       cis4 e d ces
2070     }
2071   }
2072   \layout {
2073     \context {
2074       \Staff
2075       extraNatural = ##t
2076     }
2077   }
2078 }
2079 @end lilypond
2080
2081 @noindent
2082 Context properties set in this way may be overridden for particular
2083 instances of contexts by statements in a @code{\with} block, and by
2084 @code{\set} commands embedded in music statements.
2085
2086
2087 @seealso
2088 Notation Reference:
2089 @ruser{Changing context default settings}.
2090 @ruser{The set command}.
2091
2092 Internals Reference:
2093 @rinternals{Contexts},
2094 @rinternals{Tunable context properties}.
2095
2096
2097 @node Ábrázolók hozzáadása és eltávolítása
2098 @subsection Ábrázolók hozzáadása és eltávolítása
2099 @translationof Adding and removing engravers
2100
2101 @cindex engravers, adding
2102 @cindex adding engravers
2103 @cindex engravers, removing
2104 @cindex removing engravers
2105
2106 @funindex \consists
2107 @funindex consists
2108 @funindex \remove
2109 @funindex remove
2110
2111 We have seen that contexts each contain several engravers, each
2112 of which is responsible for producing a particular part of the
2113 output, like bar lines, staves, note heads, stems, etc.  If an
2114 engraver is removed from a context, it can no longer produce its
2115 output.  This is a crude way of modifying the output, but it
2116 can sometimes be useful.
2117
2118 @subsubheading Changing a single context
2119
2120 To remove an engraver from a single context we use the
2121 @code{\with} command placed immediately after the context creation
2122 command, as in the previous section.
2123
2124 As an illustration, let's repeat an example from the previous section
2125 with the staff lines removed.  Remember that the staff lines are
2126 produced by the @code{Staff_symbol_engraver}.
2127
2128 @lilypond[quote,verbatim,ragged-right]
2129 \new Staff \with {
2130   \remove "Staff_symbol_engraver"
2131 }
2132 \relative c' {
2133   c4
2134   \set fontSize = #-4  % make note heads smaller
2135   d e
2136   \set fontSize = #2.5  % make note heads larger
2137   f g
2138   \unset fontSize  % return to default size
2139   a b
2140 }
2141 @end lilypond
2142
2143 @cindex ambitus engraver
2144
2145 Engravers can also be added to individual contexts.
2146 The command to do this is
2147
2148 @code{\consists @var{Engraver_name}},
2149
2150 @noindent
2151 placed inside a @code{\with} block.  Some vocal scores have an ambitus
2152 placed at the beginning of a staff to indicate the range of notes in
2153 that staff -- see @rglos{ambitus}.  The ambitus is produced by the
2154 @code{Ambitus_engraver}, which is not normally included in any
2155 context.  If we add it to the @code{Voice} context, it calculates the
2156 range from that voice only:
2157
2158 @lilypond[quote,verbatim,ragged-right]
2159 \new Staff <<
2160   \new Voice \with {
2161     \consists "Ambitus_engraver"
2162   }
2163   \relative c'' {
2164     \voiceOne
2165     c a b g
2166   }
2167   \new Voice
2168   \relative c' {
2169     \voiceTwo
2170     c e d f
2171   }
2172 >>
2173 @end lilypond
2174
2175 @noindent
2176 but if we add the ambitus engraver to the
2177 @code{Staff} context, it calculates the range from all
2178 the notes in all the voices on that staff:
2179
2180 @lilypond[quote,verbatim,ragged-right]
2181 \new Staff \with {
2182     \consists "Ambitus_engraver"
2183   }
2184   <<
2185   \new Voice
2186   \relative c'' {
2187     \voiceOne
2188     c a b g
2189   }
2190   \new Voice
2191   \relative c' {
2192     \voiceTwo
2193     c e d f
2194   }
2195 >>
2196 @end lilypond
2197
2198 @subsubheading Changing all contexts of the same type
2199
2200 @funindex \layout
2201 @funindex layout
2202
2203 The examples above show how to remove or add engravers to
2204 individual contexts.  It is also possible to remove or add
2205 engravers to every context of a specific type by placing the
2206 commands in the appropriate context in a @code{\layout}
2207 block.  For example, if we wanted to show an ambitus for every
2208 staff in a four-staff score, we could write
2209
2210 @lilypond[quote,verbatim,ragged-right]
2211 \score {
2212   <<
2213     \new Staff <<
2214       \relative c'' {
2215         c a b g
2216       }
2217     >>
2218     \new Staff <<
2219       \relative c' {
2220         c a b g
2221       }
2222     >>
2223     \new Staff <<
2224       \clef "G_8"
2225       \relative c' {
2226         c a b g
2227       }
2228     >>
2229     \new Staff <<
2230       \clef "bass"
2231       \relative c {
2232         c a b g
2233       }
2234     >>
2235   >>
2236   \layout {
2237     \context {
2238       \Staff
2239       \consists "Ambitus_engraver"
2240     }
2241   }
2242 }
2243 @end lilypond
2244
2245 @noindent
2246 The values of context properties may also be set
2247 for all contexts of a particular type by including the
2248 @code{\set} command in a @code{\context} block in the
2249 same way.
2250
2251
2252 @seealso
2253 Notation Reference: @ruser{Modifying context plug-ins},
2254 @ruser{Changing context default settings}.
2255
2256
2257 @node A sablonok kibővítése
2258 @section A sablonok kibővítése
2259 @translationof Extending the templates
2260
2261 You've read the tutorial, you know how to write music, you
2262 understand the fundamental concepts.  But how can you
2263 get the staves that you want?  Well, you can find lots of
2264 templates (see @ref{Templates}) which may give you a start.
2265 But what if you want something that isn't covered there?  Read on.
2266
2267 @menu
2268 * Szoprán és cselló::
2269 * Négyszólamú vegyeskar::
2270 * Kotta létrehozása az alapoktól::
2271 * Kevesebb gépelés változókkal és függvényekkel::
2272 * Partitúra és szólamkották::
2273 @end menu
2274
2275 @node Szoprán és cselló
2276 @subsection Szoprán és cselló
2277 @translationof Soprano and cello
2278
2279 @cindex template, modifying
2280 @cindex modifying templates
2281
2282 Start off with the template that seems closest to what you want to
2283 end up with.  Let's say that you want to write something for
2284 soprano and cello.  In this case, we would start with the
2285 @q{Notes and lyrics} template (for the soprano part).
2286
2287 @example
2288 \version @w{"@version{}"}
2289 melody = \relative c' @{
2290   \clef treble
2291   \key c \major
2292   \time 4/4
2293   a4 b c d
2294 @}
2295
2296 text = \lyricmode @{
2297   Aaa Bee Cee Dee
2298 @}
2299
2300 \score @{
2301   <<
2302     \new Voice = "one" @{
2303       \autoBeamOff
2304       \melody
2305     @}
2306     \new Lyrics \lyricsto "one" \text
2307   >>
2308   \layout @{ @}
2309   \midi @{ @}
2310 @}
2311 @end example
2312
2313 Now we want to add a cello part.  Let's look at the @q{Notes only} example:
2314
2315 @example
2316 \version @w{"@version{}"}
2317 melody = \relative c' @{
2318   \clef treble
2319   \key c \major
2320   \time 4/4
2321   a4 b c d
2322 @}
2323
2324 \score @{
2325   \new Staff \melody
2326   \layout @{ @}
2327   \midi @{ @}
2328 @}
2329 @end example
2330
2331 We don't need two @code{\version} commands.  We'll need the
2332 @code{melody} section.  We don't want two @code{\score} sections
2333 -- if we had two @code{\score}s, we'd get the two parts separately.
2334 We want them together, as a duet.  Within the @code{\score}
2335 section, we don't need two @code{\layout} or @code{\midi}.
2336
2337 If we simply cut and paste the @code{melody} section, we would
2338 end up with two @code{melody} definitions.  This would not generate
2339 an error, but the second one would be used for both melodies.
2340 So let's rename them to make them distinct.  We'll call the
2341 section for the soprano @code{sopranoMusic} and the section for
2342 the cello @code{celloMusic}.  While we're doing this, let's rename
2343 @code{text} to be @code{sopranoLyrics}.  Remember to rename both
2344 instances of all these names -- both the initial definition (the
2345 @code{melody = \relative c' @{ } part) and the name's use (in the
2346 @code{\score} section).
2347
2348 While we're doing this, let's change the cello part's staff --
2349 celli normally use bass clef.  We'll also give the cello some
2350 different notes.
2351
2352 @example
2353 \version @w{"@version{}"}
2354 sopranoMusic = \relative c' @{
2355   \clef treble
2356   \key c \major
2357   \time 4/4
2358   a4 b c d
2359 @}
2360
2361 sopranoLyrics = \lyricmode @{
2362   Aaa Bee Cee Dee
2363 @}
2364
2365 celloMusic = \relative c @{
2366   \clef bass
2367   \key c \major
2368   \time 4/4
2369   d4 g fis8 e d4
2370 @}
2371
2372 \score @{
2373   <<
2374     \new Voice = "one" @{
2375       \autoBeamOff
2376       \sopranoMusic
2377     @}
2378     \new Lyrics \lyricsto "one" \sopranoLyrics
2379   >>
2380   \layout @{ @}
2381   \midi @{ @}
2382 @}
2383 @end example
2384
2385 This is looking promising, but the cello part won't appear in the
2386 score -- we haven't used it in the @code{\score} section.  If we
2387 want the cello part to appear under the soprano part, we need to add
2388
2389 @example
2390 \new Staff \celloMusic
2391 @end example
2392
2393 @noindent
2394 underneath the soprano stuff.  We also need to add @code{<<} and
2395 @code{>>} around the music -- that tells LilyPond that there's
2396 more than one thing (in this case, two @code{Staves}) happening
2397 at once.  The @code{\score} looks like this now:
2398
2399 @c Indentation in this example is deliberately poor
2400 @example
2401 \score @{
2402   <<
2403     <<
2404       \new Voice = "one" @{
2405         \autoBeamOff
2406         \sopranoMusic
2407       @}
2408       \new Lyrics \lyricsto "one" \sopranoLyrics
2409     >>
2410     \new Staff \celloMusic
2411   >>
2412   \layout @{ @}
2413   \midi @{ @}
2414 @}
2415 @end example
2416
2417 @noindent
2418 This looks a bit messy; the indentation is messed up now.  That is
2419 easily fixed.  Here's the complete soprano and cello template.
2420
2421 @lilypond[quote,verbatim,ragged-right,addversion]
2422 sopranoMusic = \relative c' {
2423   \clef treble
2424   \key c \major
2425   \time 4/4
2426   a4 b c d
2427 }
2428
2429 sopranoLyrics = \lyricmode {
2430   Aaa Bee Cee Dee
2431 }
2432
2433 celloMusic = \relative c {
2434   \clef bass
2435   \key c \major
2436   \time 4/4
2437   d4 g fis8 e d4
2438 }
2439
2440 \score {
2441   <<
2442     <<
2443       \new Voice = "one" {
2444         \autoBeamOff
2445         \sopranoMusic
2446       }
2447       \new Lyrics \lyricsto "one" \sopranoLyrics
2448     >>
2449     \new Staff \celloMusic
2450   >>
2451   \layout { }
2452   \midi { }
2453 }
2454 @end lilypond
2455
2456
2457 @seealso
2458 The starting templates can be found in the @q{Templates} appendix,
2459 see @ref{Single staff}.
2460
2461
2462 @node Négyszólamú vegyeskar
2463 @subsection Négyszólamú vegyeskar
2464 @translationof Four-part SATB vocal score
2465
2466 @cindex template, SATB
2467 @cindex SATB template
2468
2469 Most vocal scores of music written for four-part mixed choir
2470 with orchestral accompaniment such as Mendelssohn's Elijah or
2471 Handel's Messiah have the choral music and words on four
2472 staves, one for each of SATB, with a piano reduction of the
2473 orchestral accompaniment underneath.  Here's an example
2474 from Handel's Messiah:
2475
2476 @c The following should appear as music without code
2477 @lilypond[quote,ragged-right]
2478 global = { \key d \major \time 4/4 }
2479 sopranoMusic = \relative c'' {
2480   \clef "treble"
2481   r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2482 }
2483 sopranoWords = \lyricmode {
2484   Wor -- thy is the lamb that was slain
2485 }
2486 altoMusic = \relative a' {
2487   \clef "treble"
2488   r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
2489 }
2490 altoWords = \sopranoWords
2491 tenorMusic = \relative c' {
2492   \clef "G_8"
2493   r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2494 }
2495 tenorWords = \sopranoWords
2496 bassMusic = \relative c' {
2497   \clef "bass"
2498   r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2499 }
2500 bassWords = \sopranoWords
2501 upper = \relative a' {
2502   \clef "treble"
2503   \global
2504   r4 <a d fis>2 <a e' a>4
2505   <d fis d'>4. <d fis d'>8 <a d a'>2
2506   <g cis g'>4 <a d fis> <a cis e>2
2507 }
2508 lower = \relative c, {
2509   \clef "bass"
2510   \global
2511   <d d'>4 <d d'>2 <cis cis'>4
2512   <b b'>4. <b' b'>8 <fis fis'>2
2513   <e e'>4 <d d'> <a' a'>2
2514 }
2515
2516 \score {
2517   <<  % combine ChoirStaff and PianoStaff in parallel
2518     \new ChoirStaff <<
2519       \new Staff = "sopranos" <<
2520         \set Staff.instrumentName = #"Soprano"
2521         \new Voice = "sopranos" {
2522           \global
2523           \sopranoMusic
2524         }
2525       >>
2526       \new Lyrics \lyricsto "sopranos" {
2527         \sopranoWords
2528       }
2529       \new Staff = "altos" <<
2530         \set Staff.instrumentName = #"Alto"
2531         \new Voice = "altos" {
2532           \global
2533           \altoMusic
2534         }
2535       >>
2536       \new Lyrics \lyricsto "altos" { \altoWords }
2537       \new Staff = "tenors" <<
2538         \set Staff.instrumentName = #"Tenor"
2539         \new Voice = "tenors" {
2540           \global
2541           \tenorMusic
2542         }
2543       >>
2544       \new Lyrics \lyricsto "tenors" { \tenorWords }
2545       \new Staff = "basses" <<
2546         \set Staff.instrumentName = #"Bass"
2547         \new Voice = "basses" {
2548           \global
2549           \bassMusic
2550         }
2551       >>
2552       \new Lyrics \lyricsto "basses" {
2553         \bassWords
2554       }
2555     >>  % end ChoirStaff
2556     \new PianoStaff <<
2557       \set PianoStaff.instrumentName = #"Piano"
2558       \new Staff = "upper" \upper
2559       \new Staff = "lower" \lower
2560     >>
2561   >>
2562 }
2563 @end lilypond
2564
2565 None of the templates provides this layout exactly.  The nearest is
2566 @q{SATB vocal score and automatic piano reduction} -- see @ref{Vocal
2567 ensembles} -- but we need to change the layout and add a piano
2568 accompaniment which is not derived automatically from the vocal parts.
2569 The variables holding the music and words for the vocal parts are
2570 fine, but we shall need to add variables for the piano reduction.
2571
2572 The order in which the contexts appear in the ChoirStaff of the
2573 template do not correspond with the order in the vocal score shown
2574 above.  We need to rearrange them so there are four staves with the
2575 words written directly underneath the notes for each part.  All the
2576 voices should be @code{\voiceOne}, which is the default, so the
2577 @code{\voiceXXX} commands should be removed.  We also need to specify
2578 the tenor clef for the tenors.  The way in which lyrics are specified
2579 in the template has not yet been encountered so we need to use the
2580 method with which we are familiar.  We should also add the names of
2581 each staff.
2582
2583 Doing this gives for our ChoirStaff:
2584
2585 @example
2586     \new ChoirStaff <<
2587       \new Staff = "sopranos" <<
2588         \set Staff.instrumentName = #"Soprano"
2589         \new Voice = "sopranos" @{
2590           \global
2591           \sopranoMusic
2592         @}
2593       >>
2594       \new Lyrics \lyricsto "sopranos" @{
2595         \sopranoWords
2596      @}
2597       \new Staff = "altos" <<
2598         \set Staff.instrumentName = #"Alto"
2599         \new Voice = "altos" @{
2600           \global
2601           \altoMusic
2602         @}
2603       >>
2604       \new Lyrics \lyricsto "altos" @{
2605         \altoWords
2606       @}
2607       \new Staff = "tenors" <<
2608         \set Staff.instrumentName = #"Tenor"
2609         \new Voice = "tenors" @{
2610           \global
2611           \tenorMusic
2612         @}
2613       >>
2614       \new Lyrics \lyricsto "tenors" @{
2615         \tenorWords
2616       @}
2617       \new Staff = "basses" <<
2618         \set Staff.instrumentName = #"Bass"
2619         \new Voice = "basses" @{
2620           \global
2621           \bassMusic
2622         @}
2623       >>
2624       \new Lyrics \lyricsto "basses" @{
2625         \bassWords
2626       @}
2627     >>  % end ChoirStaff
2628 @end example
2629
2630 Next we must work out the piano part.  This is
2631 easy - we just pull out the piano part from the
2632 @q{Solo piano} template:
2633
2634 @example
2635 \new PianoStaff <<
2636   \set PianoStaff.instrumentName = #"Piano  "
2637   \new Staff = "upper" \upper
2638   \new Staff = "lower" \lower
2639 >>
2640 @end example
2641
2642 and add the variable definitions for @code{upper}
2643 and @code{lower}.
2644
2645 The ChoirStaff and PianoStaff must be combined
2646 using angle brackets as we want them to be
2647 stacked one above the other:
2648
2649 @example
2650 <<  % combine ChoirStaff and PianoStaff one above the other
2651   \new ChoirStaff <<
2652     \new Staff = "sopranos" <<
2653       \new Voice = "sopranos" @{
2654         \global
2655         \sopranoMusic
2656       @}
2657     >>
2658     \new Lyrics \lyricsto "sopranos" @{
2659       \sopranoWords
2660      @}
2661     \new Staff = "altos" <<
2662       \new Voice = "altos" @{
2663         \global
2664         \altoMusic
2665       @}
2666     >>
2667     \new Lyrics \lyricsto "altos" @{
2668       \altoWords
2669     @}
2670     \new Staff = "tenors" <<
2671       \clef "G_8"  % tenor clef
2672       \new Voice = "tenors" @{
2673         \global
2674         \tenorMusic
2675       @}
2676     >>
2677     \new Lyrics \lyricsto "tenors" @{
2678       \tenorWords
2679     @}
2680     \new Staff = "basses" <<
2681       \clef "bass"
2682       \new Voice = "basses" @{
2683         \global
2684         \bassMusic
2685       @}
2686     >>
2687     \new Lyrics \lyricsto "basses" @{
2688       \bassWords
2689     @}
2690   >>  % end ChoirStaff
2691
2692   \new PianoStaff <<
2693     \set PianoStaff.instrumentName = #"Piano"
2694     \new Staff = "upper" \upper
2695     \new Staff = "lower" \lower
2696   >>
2697 >>
2698 @end example
2699
2700 Combining all these together and adding the music
2701 for the three bars of the example above gives:
2702
2703 @lilypond[quote,verbatim,ragged-right,addversion]
2704 global = {
2705   \key d \major
2706   \time 4/4
2707 }
2708 sopranoMusic = \relative c'' {
2709   \clef "treble"
2710   r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2711 }
2712 sopranoWords = \lyricmode {
2713   Wor -- thy is the lamb that was slain
2714 }
2715 altoMusic = \relative a' {
2716   \clef "treble"
2717   r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
2718 }
2719 altoWords = \sopranoWords
2720 tenorMusic = \relative c' {
2721   \clef "G_8"
2722   r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2723 }
2724 tenorWords = \sopranoWords
2725 bassMusic = \relative c' {
2726   \clef "bass"
2727   r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2728 }
2729 bassWords = \sopranoWords
2730 upper = \relative a' {
2731   \clef "treble"
2732   \global
2733   r4 <a d fis>2 <a e' a>4
2734   <d fis d'>4. <d fis d'>8 <a d a'>2
2735   <g cis g'>4 <a d fis> <a cis e>2
2736 }
2737 lower = \relative c, {
2738   \clef "bass"
2739   \global
2740   <d d'>4 <d d'>2 <cis cis'>4
2741   <b b'>4. <b' b'>8 <fis fis'>2
2742   <e e'>4 <d d'> <a' a'>2
2743 }
2744
2745 \score {
2746   <<  % combine ChoirStaff and PianoStaff in parallel
2747     \new ChoirStaff <<
2748       \new Staff = "sopranos" <<
2749         \set Staff.instrumentName = #"Soprano"
2750         \new Voice = "sopranos" {
2751           \global
2752           \sopranoMusic
2753         }
2754       >>
2755       \new Lyrics \lyricsto "sopranos" {
2756         \sopranoWords
2757       }
2758       \new Staff = "altos" <<
2759         \set Staff.instrumentName = #"Alto"
2760         \new Voice = "altos" {
2761           \global
2762           \altoMusic
2763         }
2764       >>
2765       \new Lyrics \lyricsto "altos" {
2766         \altoWords
2767       }
2768       \new Staff = "tenors" <<
2769         \set Staff.instrumentName = #"Tenor"
2770         \new Voice = "tenors" {
2771           \global
2772           \tenorMusic
2773         }
2774       >>
2775       \new Lyrics \lyricsto "tenors" {
2776         \tenorWords
2777       }
2778       \new Staff = "basses" <<
2779         \set Staff.instrumentName = #"Bass"
2780         \new Voice = "basses" {
2781           \global
2782           \bassMusic
2783         }
2784       >>
2785       \new Lyrics \lyricsto "basses" {
2786         \bassWords
2787       }
2788     >>  % end ChoirStaff
2789
2790     \new PianoStaff <<
2791       \set PianoStaff.instrumentName = #"Piano  "
2792       \new Staff = "upper" \upper
2793       \new Staff = "lower" \lower
2794     >>
2795   >>
2796 }
2797 @end lilypond
2798
2799
2800 @node Kotta létrehozása az alapoktól
2801 @subsection Kotta létrehozása az alapoktól
2802 @translationof Building a score from scratch
2803
2804 @cindex template, writing your own
2805 @cindex example of writing a score
2806 @cindex writing a score, example
2807 @cindex score, example of writing
2808
2809 After gaining some facility with writing LilyPond code, you
2810 may find that it is easier to build a score from scratch
2811 rather than modifying one of the templates.  You can also
2812 develop your own style this way to suit the sort of music you
2813 like.  Let's see how to put together the score for an organ
2814 prelude as an example.
2815
2816 We begin with a header section.  Here go the title, name
2817 of composer, etc, then come any variable definitions, and
2818 finally the score block.  Let's start with these in outline
2819 and fill in the details later.
2820
2821 We'll use the first two bars of Bach's prelude
2822 based on @emph{Jesu, meine Freude} which is written for two
2823 manuals and pedal organ.  You can see these two bars of music
2824 at the bottom of this section.  The top manual part has two voices,
2825 the lower and pedal organ one each.  So we need four
2826 music definitions and one to define the time signature
2827 and key:
2828
2829 @example
2830 \version @w{"@version{}"}
2831 \header @{
2832   title = "Jesu, meine Freude"
2833   composer = "J S Bach"
2834 @}
2835 TimeKey = @{
2836   \time 4/4
2837   \key c \minor
2838 @}
2839 ManualOneVoiceOneMusic = @{ s1 @}
2840 ManualOneVoiceTwoMusic = @{ s1 @}
2841 ManualTwoMusic = @{ s1 @}
2842 PedalOrganMusic = @{ s1 @}
2843
2844 \score @{
2845 @}
2846 @end example
2847
2848 For now we've just used a spacer note, @code{s1},
2849 instead of the real music.  We'll add that later.
2850
2851 Next let's see what should go in the score block.
2852 We simply mirror the staff structure we want.
2853 Organ music is usually written on three staves,
2854 one for each manual and one for the pedals.  The
2855 manual staves should be bracketed together, so we
2856 need to use a PianoStaff for them.  The first
2857 manual part needs two voices and the second manual
2858 part just one.
2859
2860 @example
2861   \new PianoStaff <<
2862     \new Staff = "ManualOne" <<
2863       \new Voice @{
2864         \ManualOneVoiceOneMusic
2865       @}
2866       \new Voice @{
2867         \ManualOneVoiceTwoMusic
2868       @}
2869     >>  % end ManualOne Staff context
2870     \new Staff = "ManualTwo" <<
2871       \new Voice @{
2872         \ManualTwoMusic
2873       @}
2874     >>  % end ManualTwo Staff context
2875   >>  % end PianoStaff context
2876 @end example
2877
2878 Next we need to add a staff for the pedal organ.
2879 This goes underneath the PianoStaff, but it must
2880 be simultaneous with it, so we need angle brackets
2881 around the two.  Missing these out would generate
2882 an error in the log file.  It's a common mistake
2883 which you'll make sooner or later!  Try copying
2884 the final example at the end of this section,
2885 remove these angle brackets, and compile it to
2886 see what errors it generates.
2887
2888 @example
2889 <<  % PianoStaff and Pedal Staff must be simultaneous
2890   \new PianoStaff <<
2891     \new Staff = "ManualOne" <<
2892       \new Voice @{
2893         \ManualOneVoiceOneMusic
2894       @}
2895       \new Voice @{
2896         \ManualOneVoiceTwoMusic
2897       @}
2898     >>  % end ManualOne Staff context
2899     \new Staff = "ManualTwo" <<
2900       \new Voice @{
2901         \ManualTwoMusic
2902       @}
2903     >>  % end ManualTwo Staff context
2904   >>  % end PianoStaff context
2905   \new Staff = "PedalOrgan" <<
2906     \new Voice @{
2907       \PedalOrganMusic
2908     @}
2909   >>
2910 >>
2911 @end example
2912
2913 It is not necessary to use the simultaneous construct
2914 @code{<< .. >>} for the manual two staff and the pedal organ staff,
2915 since they contain only one music expression, but it does no harm,
2916 and always using angle brackets after @code{\new Staff} is a good
2917 habit to cultivate in case there are multiple voices.  The opposite
2918 is true for Voices: these should habitually be followed by braces
2919 @code{@{ .. @}} in case your music is coded in several variables
2920 which need to run consecutively.
2921
2922 Let's add this structure to the score block, and adjust the indenting.
2923 We also add the appropriate clefs, ensure stems, ties and slurs in
2924 each voice on the upper staff point to the right direction with
2925 @code{\voiceOne} and @code{\voiceTwo}, and enter the time signature
2926 and key to each staff using our predefined variable, @code{\TimeKey}.
2927
2928 @example
2929 \score @{
2930   <<  % PianoStaff and Pedal Staff must be simultaneous
2931     \new PianoStaff <<
2932       \new Staff = "ManualOne" <<
2933         \TimeKey  % set time signature and key
2934         \clef "treble"
2935         \new Voice @{
2936           \voiceOne
2937           \ManualOneVoiceOneMusic
2938         @}
2939         \new Voice @{
2940           \voiceTwo
2941           \ManualOneVoiceTwoMusic
2942         @}
2943       >>  % end ManualOne Staff context
2944       \new Staff = "ManualTwo" <<
2945         \TimeKey
2946         \clef "bass"
2947         \new Voice @{
2948           \ManualTwoMusic
2949         @}
2950       >>  % end ManualTwo Staff context
2951     >>  % end PianoStaff context
2952     \new Staff = "PedalOrgan" <<
2953       \TimeKey
2954       \clef "bass"
2955       \new Voice @{
2956         \PedalOrganMusic
2957       @}
2958     >>  % end PedalOrgan Staff
2959   >>
2960 @}  % end Score context
2961 @end example
2962
2963 That completes the structure.  Any three-staff organ music
2964 will have a similar structure, although the number of voices
2965 may vary.  All that remains now
2966 is to add the music, and combine all the parts together.
2967
2968 @lilypond[quote,verbatim,ragged-right,addversion]
2969 \header {
2970   title = "Jesu, meine Freude"
2971   composer = "J S Bach"
2972 }
2973 TimeKey = {
2974   \time 4/4
2975   \key c \minor
2976 }
2977 ManualOneVoiceOneMusic = \relative g' {
2978   g4 g f ees
2979   d2 c2
2980 }
2981 ManualOneVoiceTwoMusic = \relative c' {
2982   ees16 d ees8~ ees16 f ees d c8 d~ d c~
2983   c c4 b8 c8. g16 c b c d
2984 }
2985 ManualTwoMusic = \relative c' {
2986   c16 b c8~ c16 b c g a8 g~ g16 g aes ees
2987   f ees f d g aes g f ees d e8~ ees16 f ees d
2988 }
2989 PedalOrganMusic = \relative c {
2990   r8 c16 d ees d ees8~ ees16 a, b g c b c8
2991   r16 g ees f g f g8 c,2
2992 }
2993
2994 \score {
2995   <<  % PianoStaff and Pedal Staff must be simultaneous
2996     \new PianoStaff <<
2997       \new Staff = "ManualOne" <<
2998         \TimeKey  % set time signature and key
2999         \clef "treble"
3000         \new Voice {
3001           \voiceOne
3002           \ManualOneVoiceOneMusic
3003         }
3004         \new Voice {
3005           \voiceTwo
3006           \ManualOneVoiceTwoMusic
3007         }
3008       >>  % end ManualOne Staff context
3009       \new Staff = "ManualTwo" <<
3010         \TimeKey
3011         \clef "bass"
3012         \new Voice {
3013           \ManualTwoMusic
3014         }
3015       >>  % end ManualTwo Staff context
3016     >>  % end PianoStaff context
3017     \new Staff = "PedalOrgan" <<
3018       \TimeKey
3019       \clef "bass"
3020       \new Voice {
3021         \PedalOrganMusic
3022       }
3023     >>  % end PedalOrgan Staff context
3024   >>
3025 }  % end Score context
3026 @end lilypond
3027
3028
3029 @node Kevesebb gépelés változókkal és függvényekkel
3030 @subsection Kevesebb gépelés változókkal és függvényekkel
3031 @translationof Saving typing with variables and functions
3032
3033 @cindex variables
3034 @cindex variables
3035
3036 By this point, you've seen this kind of thing:
3037
3038 @lilypond[quote,verbatim,ragged-right]
3039 hornNotes = \relative c'' { c4 b dis c }
3040 \score {
3041   {
3042     \hornNotes
3043   }
3044 }
3045 @end lilypond
3046
3047 You may even realize that this could be useful in minimalist music:
3048
3049 @lilypond[quote,verbatim,ragged-right]
3050 fragmentA = \relative c'' { a4 a8. b16 }
3051 fragmentB = \relative c'' { a8. gis16 ees4 }
3052 violin = \new Staff {
3053   \fragmentA
3054   \fragmentA
3055   \fragmentB
3056   \fragmentA
3057 }
3058 \score {
3059   {
3060     \violin
3061   }
3062 }
3063 @end lilypond
3064
3065 However, you can also use these variables (also known as
3066 macros, or user-defined commands) for tweaks:
3067
3068 @c TODO Avoid padtext - not needed with skylining
3069 @lilypond[quote,verbatim,ragged-right]
3070 dolce = \markup { \italic \bold dolce }
3071 padText = { \once \override TextScript.padding = #5.0 }
3072 fthenp=_\markup { \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p }
3073 violin = \relative c'' {
3074   \repeat volta 2 {
3075     c4._\dolce b8 a8 g a b
3076     \padText
3077     c4.^"hi there!" d8 e' f g d
3078     c,4.\fthenp b8 c4 c-.
3079   }
3080 }
3081 \score {
3082   {
3083     \violin
3084   }
3085 \layout { ragged-right=##t }
3086 }
3087 @end lilypond
3088
3089 These variables are obviously useful for saving
3090 typing.  But they're worth considering even if you
3091 only use them once -- they reduce complexity.  Let's
3092 look at the previous example without any
3093 variables.  It's a lot harder to read, especially
3094 the last line.
3095
3096 @example
3097 violin = \relative c'' @{
3098   \repeat volta 2 @{
3099     c4._\markup @{ \italic \bold dolce @} b8 a8 g a b
3100     \once \override TextScript.padding = #5.0
3101     c4.^"hi there!" d8 e' f g d
3102     c,4.\markup @{ \dynamic f \italic \small @{ 2nd @}
3103       \hspace #0.1 \dynamic p @}
3104     b8 c4 c-.
3105   @}
3106 @}
3107 @end example
3108
3109 @c TODO Replace the following with a better example  -td
3110 @c Skylining handles this correctly without padText
3111
3112 So far we've seen static substitution -- when LilyPond
3113 sees @code{\padText}, it replaces it with the stuff that
3114 we've defined it to be (ie the stuff to the right of
3115 @code{padtext=}).
3116
3117 LilyPond can handle non-static substitution, too (you
3118 can think of these as functions).
3119
3120 @lilypond[quote,verbatim,ragged-right]
3121 padText =
3122 #(define-music-function (parser location padding) (number?)
3123   #{
3124     \once \override TextScript.padding = #padding
3125   #})
3126
3127 \relative c''' {
3128   c4^"piu mosso" b a b
3129   \padText #1.8
3130   c4^"piu mosso" d e f
3131   \padText #2.6
3132   c4^"piu mosso" fis a g
3133 }
3134 @end lilypond
3135
3136 Using variables is also a good way to reduce work if the
3137 LilyPond input syntax changes (see
3138 @rprogram{Updating files with convert-ly}).  If
3139 you have a single definition (such as @code{\dolce}) for all your
3140 input files (see @ref{Style sheets}), then if the syntax changes, you
3141 only need to update your single @code{\dolce} definition,
3142 instead of making changes throughout every @file{.ly} file.
3143
3144
3145 @node Partitúra és szólamkották
3146 @subsection Partitúra és szólamkották
3147 @translationof Scores and parts
3148
3149 In orchestral music, all notes are printed twice.  Once in a part for
3150 the musicians, and once in a full score for the conductor.  Variables can
3151 be used to avoid double work.  The music is entered once, and stored in
3152 a variable.  The contents of that variable is then used to generate
3153 both the part and the full score.
3154
3155 It is convenient to define the notes in a special file.  For example,
3156 suppose that the file @file{horn-music.ly} contains the following part
3157 of a horn/@/bassoon duo
3158
3159 @example
3160 hornNotes = \relative c @{
3161   \time 2/4
3162   r4 f8 a cis4 f e d
3163 @}
3164 @end example
3165
3166 @noindent
3167 Then, an individual part is made by putting the following in a file
3168
3169 @example
3170 \include "horn-music.ly"
3171 \header @{
3172   instrument = "Horn in F"
3173 @}
3174
3175 @{
3176  \transpose f c' \hornNotes
3177 @}
3178 @end example
3179
3180 The line
3181
3182 @example
3183 \include "horn-music.ly"
3184 @end example
3185
3186 @noindent
3187 substitutes the contents of @file{horn-music.ly} at this position in
3188 the file, so @code{hornNotes} is defined afterwards.  The command
3189 @code{\transpose f@tie{}c'} indicates that the argument, being
3190 @code{\hornNotes}, should be transposed by a fifth upwards.  Sounding
3191 @code{f} is denoted by notated @code{c'}, which corresponds with the
3192 tuning of a normal French Horn in@tie{}F.  The transposition can be seen
3193 in the following output
3194
3195 @lilypond[quote,ragged-right]
3196 \transpose f c' \relative c {
3197   \time 2/4
3198   r4 f8 a cis4 f e d
3199 }
3200 @end lilypond
3201
3202 In ensemble pieces, one of the voices often does not play for many
3203 measures.  This is denoted by a special rest, the multi-measure
3204 rest.  It is entered with a capital @code{R} followed by a duration
3205 (@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
3206 etc.).  By multiplying the
3207 duration, longer rests can be constructed.  For example, this rest
3208 takes 3@tie{}measures in 2/4 time
3209
3210 @example
3211 R2*3
3212 @end example
3213
3214 When printing the part, multi-rests
3215 must be condensed.  This is done by setting a run-time variable
3216
3217 @example
3218 \set Score.skipBars = ##t
3219 @end example
3220
3221 @noindent
3222 This command sets the property @code{skipBars} in the
3223 @code{Score} context to true (@code{##t}).  Prepending the rest and
3224 this option to the music above, leads to the following result
3225
3226 @lilypond[quote,ragged-right]
3227 \transpose f c' \relative c {
3228   \time 2/4
3229   \set Score.skipBars = ##t
3230   R2*3
3231   r4 f8 a cis4 f e d
3232 }
3233 @end lilypond
3234
3235
3236 The score is made by combining all of the music together.  Assuming
3237 that the other voice is in @code{bassoonNotes} in the file
3238 @file{bassoon-music.ly}, a score is made with
3239
3240 @example
3241 \include "bassoon-music.ly"
3242 \include "horn-music.ly"
3243
3244 <<
3245   \new Staff \hornNotes
3246   \new Staff \bassoonNotes
3247 >>
3248 @end example
3249
3250 @noindent
3251 leading to
3252
3253 @lilypond[quote,ragged-right]
3254 \relative c <<
3255   \new Staff {
3256     \time 2/4
3257     R2*3
3258     r4 f8 a cis4 f e d
3259   }
3260   \new Staff {
3261     \clef bass
3262     r4 d,8 f | gis4 c | b bes |
3263     a8 e f4 | g d | gis f |
3264   }
3265 >>
3266 @end lilypond