1 @c -*- coding: utf-8; mode: texinfo; documentlanguage: hu -*-
2 @c This file is part of learning.tely
4 Translation of GIT committish: 48c2b169dc8a9bc2ab2c767cbb83b57cc158742b
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..
12 @c -*- coding: utf-8; mode: texinfo; -*-
16 @translationof Fundamental concepts
17 @translationof Fundamental concepts
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.
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::
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
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ó.
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::
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
54 @c index bemeneti formátum
55 @c index fájlstruktúra
57 A LilyPond bemeneti fájlok szerkezetére egy tipikus példa:
60 \version @w{"@version{}"}
65 @var{...összetett zenei kifejezés...} % ide jön a zene!
72 Ennek az alapvető mintának sok változata lehetséges, de ez a példa jó
73 kiindulási alapot jelent.
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:
93 a következő rövidítése:
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
114 @cindex implicit kontextusok
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.
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.}
127 Egyelőre térjünk vissza az első példánkhoz, és vizsgáljuk meg csak a
128 @code{\score} parancsot.
130 A @code{\score} blokkon belül először pontosan egy zenei kifejezésnek kell
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:
138 @var{...egy teljes Wagner-opera zenei anyaga...}
144 Mivel mindez egy @code{@{ ... @}} blokkban szerepel, egy zenei
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:
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ó.
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.
184 @cindex implicit book blokk
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.
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.
200 Egy @code{\book} blokkon belül minden @code{\score} blokk különálló zenei
203 @cindex layout blokk helye
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.
212 A részletek a @ruser{Multiple scores in a book} c. részben olvashatók.
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:
221 dallam = \relative c' @{
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.
241 A bemeneti formátum teljes definíciója a
242 @ruser{File structure} c. szakaszban található.
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
252 @cindex összetett zenei kifejezés
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?
258 Valójában ez sokkal egyszerűbb, mint gondolnánk. Ez a mondat mindent
262 @emph{A @code{\score} blokknak egy összetett zenei kifejezéssel kell
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.
277 \new Staff = "ének" <<
279 \new PianoStaff = "zongora" <<
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.
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.
296 @lilypond[verbatim,quote,ragged-right]
299 \new Staff = "ének" <<
300 \new Voice = "dallam" { c'1 }
303 \new PianoStaff = "zongora" <<
304 \new Staff = "jobbkéz" { c'1 }
305 \new Staff = "balkéz" { c'1 }
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.
316 Most elkezdhetjük kitölteni a hangokat. Elkezdhetnénk közvetlenül a Voice
317 kontextus belsejébe beleírni, hogy:
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.)
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:
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 }
343 \new Staff = "ének" <<
344 \new Voice = "dallam" { \dallam }
345 \addlyrics { \dalszöveg }
347 \new PianoStaff = "zongora" <<
348 \new Staff = "jobbkéz" { \jobbkéz }
349 \new Staff = "balkéz" {
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.
366 Referencia: @ruser{Structure of a score}.
369 @node Zenei kifejezések egymásba ágyazása
370 @subsection Zenei kifejezések egymásba ágyazása
371 @translationof Nesting music expressions
373 @cindex ideiglenes kottasorok
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:
379 @lilypond[verbatim,quote,ragged-right]
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).
399 @cindex kottasorok pozíciója
401 Az ossia a kottasor fölött is elhelyezkedhet:
403 @lilypond[verbatim,quote,ragged-right]
404 \new Staff = "main" {
411 alignAboveContext = #"main" }
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).
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.
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
436 @cindex zárójeltípusok
437 @cindex zárójelek egymásba ágyazása
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
444 @multitable @columnfractions .3 .7
445 @headitem Zárójelfajta
447 @item @code{@{ .. @}}
448 @tab Egymás után megszólaló hangokat tartalmaz
450 @tab Egy akkord hangjait tartalmazza
451 @item @code{<< .. >>}
452 @tab Egyszerre megszólaló zenei kifejezéseket tartalmaz
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
458 @tab Egy kézi gerenda kezdetét és végét jelöli
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.
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
473 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
474 { g8\( a b[ c b\) a] }
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.
483 @lilypond[quote,verbatim,fragment,ragged-right]
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.\)
493 @node A szólamok zenét tartalmaznak
494 @section A szólamok zenét tartalmaznak
495 @translationof Voices contain music
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.
504 * Hangzatos szólamok::
505 * Szólamok kézi létrehozása::
506 * Szólamok és vokális zene::
509 @node Hangzatos szólamok
510 @subsection Hangzatos szólamok
511 @translationof I'm hearing Voices
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
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
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.
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:
545 @lilypond[quote,verbatim,fragment,ragged-right,relative=1]
547 <d g>4 <d fis> <d a'> <d g>
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
562 Let us see how this is done in LilyPond input syntax.
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
577 Here's how we split the chords above into two voices and add both
578 the passing note and a slur:
580 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
582 % Voice "1" Voice "2"
583 << { g4 fis8( g) a4 g } \\ { d4 d d d } >>
586 Notice how the stems of the second voice now point down.
588 Here's another simple example:
590 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
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 } >>
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:
604 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
620 @cindex voices, naming
621 @cindex voices crossing brackets
622 @cindex slurs crossing brackets
623 @cindex ties crossing brackest
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
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.
633 @lilypond[quote,verbatim,fragment]
634 \new Staff \relative c' {
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 } >>
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
657 @lilypond[quote,verbatim]
658 \new Staff \relative c' {
677 { c8 b16 a b8 g ~ g2 }
687 @funindex \voiceOneStyle
688 @funindex \voiceTwoStyle
689 @funindex \voiceThreeStyle
690 @funindex \voiceFourStyle
691 @funindex \voiceNeutralStyle
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
703 See @ref{Visibility and color of objects} and
704 @ref{Using variables for tweaks}.
706 @cindex polyphony and relative note entry
707 @cindex relative note entry and polyphony
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
715 \relative c' @{ noteA << < noteB noteC > \\ noteD >> noteE @}
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
723 @code{noteE} is relative to @code{noteD}, not @code{noteA}.
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:
730 \relative c' @{ noteA ... @}
732 \relative c'' @{ < noteB noteC > ... @}
734 \relative g' @{ noteD ... @}
736 \relative c' @{ noteE ... @}
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
748 @c The following should appear as music without code
749 @lilypond[quote,ragged-right]
750 \new Staff \relative c'' {
759 % Ignore these for now - they are explained in Ch 4
760 \once \override NoteColumn.force-hshift = #0
762 \once \override NoteColumn.force-hshift = #0.5
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
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
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'' {
805 \\ % No Voice three (we want stems down)
808 % Ignore these for now - they are explained in Ch 4
809 \once \override NoteColumn.force-hshift = #0
811 \once \override NoteColumn.force-hshift = #0.5
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:
825 @lilypond[quote,verbatim,fragment,ragged-right]
826 \new Staff \relative c'' {
829 { c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { <ees c>2 des2 }
836 @cindex voices and stem directions
837 @cindex stem directions and voices
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{\\}.
848 @lilypond[quote,verbatim,fragment,ragged-right]
849 \new Staff \relative c'' {
855 \\ % Omit Voice three
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}.
880 Notation Reference: @ruser{Multiple voices}.
883 @node Szólamok kézi létrehozása
884 @subsection Szólamok kézi létrehozása
885 @translationof Explicitly instantiating voices
892 @funindex \voiceThree
899 @cindex voice contexts, creating
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.
908 Specifically, the construct @code{<< \\ >>} which we used in
909 the previous section:
914 << @{ e4 f g a @} \\ @{ c,4 d e f @} >>
924 \new Voice = "1" @{ \voiceOne \relative c' @{ e4 f g a @} @}
925 \new Voice = "2" @{ \voiceTwo \relative c' @{ c4 d e f @} @}
929 Both of the above would produce
931 @c The following example should not display the code
932 @lilypond[ragged-right,quote]
934 \new Voice = "1" { \voiceOne \relative c' { e4 f g a } }
935 \new Voice = "2" { \voiceTwo \relative c' { c4 d e f } }
939 @cindex voices, reverting to single
940 @cindex reverting to a single voice
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.
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:
955 @lilypond[quote,ragged-right,verbatim]
957 % Default behavior or behavior after \oneVoice
958 c d8~ d e4( f g a) b-> c
962 @lilypond[quote,ragged-right,verbatim]
965 c d8~ d e4( f g a) b-> c
967 c, d8~ d e4( f g a) b-> c
971 @lilypond[quote,ragged-right,verbatim]
974 c d8~ d e4( f g a) b-> c
976 c, d8~ d e4( f g a) b-> c
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.
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.
992 @lilypond[quote,ragged-right,verbatim]
993 \new Staff \relative c' {
995 % The following notes are monophonic
997 % Start simultaneous section of three voices
999 % Continue the main voice in parallel
1000 { g4 f e | d2 e2) | }
1001 % Initiate second voice
1003 % Set stems, etc., down
1005 r8 e4 d c8~ | c8 b16 a b8 g~ g2 |
1007 % Initiate third voice
1009 % Set stems, etc, up
1017 @cindex nesting music expressions
1018 @cindex nesting simultaneous constructs
1019 @cindex nesting voices
1020 @cindex voices, temporary
1021 @cindex voices, nesting
1023 More deeply nested polyphony constructs are possible, and if a
1024 voice appears only briefly this might be a more natural way to
1027 @lilypond[quote,ragged-right,verbatim]
1028 \new Staff \relative c' {
1031 { g4 f e | d2 e2) | }
1036 { c8 b16 a b8 g~ g2 }
1047 @cindex spacing notes
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,
1056 @lilypond[quote,ragged-right,verbatim]
1057 \new Staff \relative c' <<
1058 % Initiate first voice
1061 c16^( d e f g4 f e | d2 e2) |
1063 % Initiate second voice
1065 % Set stems, etc, down
1067 s4 r8 e4 d c8~ | c8 b16 a b8 g~ g2 |
1069 % Initiate third voice
1071 % Set stems, etc, up
1078 @subsubheading Note columns
1081 @cindex note collisions
1082 @cindex collisions, notes
1083 @cindex shift commands
1090 @funindex \shiftOnnn
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.
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.
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}.
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.
1126 Notation Reference: @ruser{Multiple voices}.
1129 @node Szólamok és vokális zene
1130 @subsection Szólamok és vokális zene
1131 @translationof Voices and vocals
1133 Vocal music presents a special difficulty: we need to combine two
1134 expressions -- notes and lyrics.
1136 @funindex \new Lyrics
1140 @cindex Lyrics context, creating
1141 @cindex lyrics, linking to voice
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
1148 the lyrics to the notes with @code{\lyricsto@{@}}, using the
1149 name assigned to the Voice.
1151 @lilypond[quote,verbatim,fragment]
1153 \new Voice = "one" \relative c'' {
1156 c4 b8. a16 g4. f8 e4 d c2
1158 \new Lyrics \lyricsto "one" {
1159 No more let sins and sor -- rows grow.
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
1169 @cindex lyrics and beaming
1170 @cindex beaming and lyrics
1171 @funindex \autoBeamOff
1172 @funindex autoBeamOff
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.
1180 @funindex \new ChoirStaff
1181 @funindex ChoirStaff
1182 @funindex \lyricmode
1184 @cindex vocal score structure
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
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, | }
1209 \new Voice = "SopOne" {
1213 \new Lyrics \lyricsto "SopOne" {
1218 \new Voice = "SopTwo" {
1222 \new Lyrics \lyricsto "SopTwo" {
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.
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
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}.
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 | }
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 }
1277 \new Voice = "Tenor" { \voiceOne \TimeKey \TenorMusic }
1278 \new Voice = "Bass" { \voiceTwo \BassMusic }
1284 @cindex verse and refrain
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!
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:
1302 @lilypond[quote,verbatim,ragged-right]
1303 versenotes = \relative c'' {
1309 versewords = \lyricmode {
1310 One two three four five six
1315 \new Voice = "verse" {
1318 \new Lyrics \lyricsto verse {
1326 That gives the verse line.
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.
1338 \new Lyrics \lyricsto verse @{
1342 \new Voice = "refrainB" @{
1345 \new Lyrics \lyricsto "refrainB" @{
1352 Here's the final result with two staves in the chorus showing
1353 how the parallel section is positioned within the verse Voice:
1355 @lilypond[quote,verbatim, ragged-right]
1356 versenotes = \relative c'' {
1362 refrainnotesA = \relative c'' {
1366 refrainnotesB = \relative c {
1371 versewords = \lyricmode {
1372 One two three four five six
1374 refrainwordsA = \lyricmode {
1377 refrainwordsB = \lyricmode {
1383 \new Voice = "verse" {
1387 \new Lyrics \lyricsto "verse" {
1391 \new Voice = "refrainB" {
1394 \new Lyrics \lyricsto "refrainB" {
1400 \new Lyrics \lyricsto "verse" {
1408 @cindex book, example of using
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
1418 @lilypond[quote,verbatim,ragged-right]
1419 versenotes = \relative c'' {
1425 refrainnotesA = \relative c'' {
1429 refrainnotesB = \relative c {
1434 versewords = \lyricmode {
1435 One two three four five six
1437 refrainwordsA = \lyricmode {
1440 refrainwordsB = \lyricmode {
1445 \new Voice = "verse" {
1448 \new Lyrics \lyricsto "verse" {
1457 \new Voice = "refrainA" {
1460 \new Lyrics \lyricsto "refrainA" {
1465 \new Voice = "refrainB" {
1468 \new Lyrics \lyricsto "refrainB" {
1478 Notation Reference: @ruser{Vocal music}.
1481 @node Kontextusok és ábrázolók
1482 @section Kontextusok és ábrázolók
1483 @translationof Contexts and engravers
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.
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::
1500 @node A kontextus fogalma
1501 @subsection A kontextus fogalma
1502 @translationof Contexts explained
1504 @cindex contexts explained
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
1511 @lilypond[quote,verbatim,relative=2,fragment]
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.
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}
1534 @sourceimage{context-example,5cm,,}
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.
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.
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.
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.
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}.
1572 Notation Reference: @ruser{A kontextus fogalma}.
1575 @node Kontextusok létrehozása
1576 @subsection Kontextusok létrehozása
1577 @translationof Creating contexts
1582 @cindex new contexts
1583 @cindex creating contexts
1584 @cindex contexts, creating
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.
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
1599 \new @var{type} @var{music-expression}
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.
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}.)
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:
1623 @lilypond[quote,verbatim,ragged-right]
1624 \score { % start of single compound music expression
1625 << % start of simultaneous staves section
1627 \new Staff { % create RH staff
1630 \new Voice { % create voice for RH notes
1631 \relative c'' { % start of RH notes
1637 \new Staff << % create LH staff; needs two simultaneous voices
1640 \new Voice { % create LH voice one
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
1649 \relative g { % start of LH voice two notes
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
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.)
1672 @cindex contexts, naming
1673 @cindex naming contexts
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,
1679 \new @var{type} = @var{id} @var{music-expression}
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}.
1694 Notation Reference: @ruser{Kontextusok létrehozása}.
1697 @node Az ábrázoló fogalma
1698 @subsection Az ábrázoló fogalma
1699 @translationof Engravers explained
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
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.
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.
1720 The @code{Note_heads_engraver} and @code{Stem_engraver} live
1721 in every @code{Voice} context, the lowest level context of all.
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.
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.
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.
1741 @multitable @columnfractions .3 .7
1744 @item Accidental_engraver
1745 @tab Makes accidentals, cautionary and suggested accidentals
1750 @item Completion_heads_engraver
1751 @tab Splits notes which cross bar lines
1752 @c The old Dynamic_engraver is deprecated. -jm
1753 @item New_dynamic_engraver
1754 @tab Creates hairpins and dynamic texts
1755 @item Forbid_line_break_engraver
1756 @tab Prevents line breaks if a musical element is still active
1758 @tab Creates the key signature
1759 @item Metronome_mark_engraver
1760 @tab Engraves metronome marking
1761 @item Note_heads_engraver
1762 @tab Engraves note heads
1765 @item Staff_symbol_engraver
1766 @tab Engraves the five (by default) lines of the staff
1768 @tab Creates stems and single-stem tremolos
1769 @item Time_signature_engraver
1770 @tab Creates time signatures
1775 We shall see later how the output of LilyPond can be changed
1776 by modifying the action of Engravers.
1780 Internals reference: @rinternals{Engravers and Performers}.
1783 @node Kontextusok tulajdonságainak módosítása
1784 @subsection Kontextusok tulajdonságainak módosítása
1785 @translationof Modifying context properties
1787 @cindex context properties
1788 @cindex context properties, modifying
1789 @cindex modifying context properties
1795 Contexts are responsible for holding the values of a number of
1796 context @emph{properties}. Many of them can be changed to
1797 influence the interpretation of the input and so change the
1798 appearance of the output. They are changed by the
1799 @code{\set} command. This takes the form
1802 \set @emph{ContextName}.@emph{propertyName} = #@emph{value}
1805 Where the @emph{ContextName} is usually @code{Score},
1806 @code{Staff} or @code{Voice}. It may be omitted,
1807 in which case the current context (typically @code{Voice}) is assumed.
1809 The names of context properties consist of words joined
1810 together with no hyphens or underscores, all except the
1811 first having a capital letter. Here are a few examples
1812 of some commonly used ones. There are many more.
1814 @c attempt to force this onto a new page
1816 @multitable @columnfractions .25 .15 .45 .15
1817 @headitem propertyName
1823 @tab If true, set extra natural signs before accidentals
1824 @tab @code{#t}, @code{#f}
1825 @item currentBarNumber
1827 @tab Set the current bar number
1831 @tab If true, print slurs both above and below notes
1832 @tab @code{#t}, @code{#f}
1833 @item instrumentName
1835 @tab Set the name to be placed at the start of the staff
1836 @tab @code{"Cello I"}
1839 @tab Increase or decrease the font size
1843 @tab Set the text to print before the start of a verse
1848 where a Boolean is either True (@code{#t}) or False (@code{#f}),
1849 an Integer is a positive whole number, a Real is a positive
1850 or negative decimal number, and text is enclosed in double
1851 apostrophes. Note the occurrence of hash signs,
1852 (@code{#}), in two different places -- as part of the Boolean
1853 value before the @code{t} or @code{f}, and before @emph{value}
1854 in the @code{\set} statement. So when a Boolean is being
1855 entered you need to code two hash signs, e.g., @code{##t}.
1857 @cindex properties operating in contexts
1858 @cindex setting properties within contexts
1860 Before we can set any of these properties we need to know
1861 in which context they operate. Sometimes this is obvious,
1862 but occasionally it can be tricky. If the wrong context
1863 is specified, no error message is produced, but the expected
1864 action will not take place. For example, the
1865 @code{instrumentName} clearly lives in the @code{Staff} context, since
1866 it is the staff that is to be named.
1867 In this example the first staff is labeled, but not the second,
1868 because we omitted the context name.
1870 @lilypond[quote,verbatim,ragged-right]
1872 \new Staff \relative c'' {
1873 \set Staff.instrumentName = #"Soprano"
1876 \new Staff \relative c' {
1877 \set instrumentName = #"Alto" % Wrong!
1883 Remember the default context name is @code{Voice}, so the second
1884 @code{\set} command set the property @code{instrumentName} in the
1885 @code{Voice} context to @qq{Alto}, but as LilyPond does not look
1886 for any such property in the @code{Voice} context, no
1887 further action took place. This is not an error, and no error
1888 message is logged in the log file.
1890 Similarly, if the property name is mis-spelt no error message is
1891 produced, and clearly the expected action cannot be performed. In
1892 fact, you can set any (fictitious) @q{property} using any name you
1893 like in any context that exists by using the @code{\set} command. But
1894 if the name is not known to LilyPond it will not cause any action to
1895 be taken. Some text editors with special support for LilyPond input
1896 files document property names with bullets when you hover them with
1897 the mouse, like JEdit with LilyPondTool, or highlight unknown property
1898 names differently, like ConTEXT. If you do not use an editor with
1899 such features, it is recommended to check the property name in the
1900 Internals Reference: see @rinternals{Tunable context properties}, or
1901 @rinternals{Contexts}.
1903 The @code{instrumentName} property will take effect only
1904 if it is set in the @code{Staff} context, but
1905 some properties can be set in more than one context.
1906 For example, the property @code{extraNatural} is by
1907 default set to ##t (true) for all staves.
1908 If it is set to ##f (false) in one particular @code{Staff}
1909 context it applies just to the accidentals on that staff.
1910 If it is set to false in the @code{Score} context
1911 it applies to all staves.
1913 So this turns off extra naturals in one staff:
1915 @lilypond[quote,verbatim,ragged-right]
1917 \new Staff \relative c'' {
1920 \new Staff \relative c'' {
1921 \set Staff.extraNatural = ##f
1928 and this turns them off in all staves:
1930 @lilypond[quote,verbatim,ragged-right]
1932 \new Staff \relative c'' {
1935 \new Staff \relative c'' {
1936 \set Score.extraNatural = ##f
1942 As another example, if @code{clefTransposition} is set in
1943 the @code{Score} context this immediately changes the value
1944 of the octavation in all current staves and sets a new default
1945 value which will be applied to all staves.
1947 The opposite command, @code{\unset}, effectively removes the
1948 property from the context, which causes most properties to
1949 revert to their default value. Usually @code{\unset} is not
1950 required as a new @code{\set} command will achieve what is
1953 The @code{\set} and @code{\unset} commands can appear anywhere
1954 in the input file and will take effect from the time they are
1955 encountered until the end of the score or until the property is
1956 @code{\set} or @code{\unset} again. Let's try changing the
1957 font size, which affects the size of the note heads (among
1958 other things) several times. The change is from the default
1959 value, not the most recently set value.
1961 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
1963 % make note heads smaller
1966 % make note heads larger
1967 \set fontSize = #2.5
1969 % return to default size
1974 We have now seen how to set the values of several different types of
1975 property. Note that integers and numbers are always preceded by a
1976 hash sign, @code{#}, while a true or false value is specified by
1977 @code{##t} and @code{##f}, with two hash signs. A text property
1978 should be enclosed in double quotation signs, as above, although we
1979 shall see later that text can actually be specified in a much more
1980 general way by using the very powerful @code{\markup} command.
1982 @subsubheading Setting context properties with @code{\with}
1986 @cindex context properties, setting with \with
1988 The default value of context properties may be set at the time the
1989 context is created. Sometimes this is a clearer way of setting a
1990 property value if it is to remain fixed for the duration of
1991 the context. When a context is created with a @code{\new}
1992 command it may be followed immediately by a @code{\with @{ .. @}}
1993 block in which the default property values are set. For example,
1994 if we wish to suppress the printing of extra naturals for the
1995 duration of a staff we would write:
1998 \new Staff \with @{ extraNatural = ##f @}
2004 @lilypond[quote,verbatim,ragged-right]
2010 \new Staff \with { extraNatural = ##f }
2017 Or, if the property override is to be applied to all staves
2018 within the score, it may be appended to an explicit
2019 @code{\new Score} command, like this:
2021 @lilypond[quote,verbatim,ragged-right]
2023 \new Score \with { extraNatural = ##f } <<
2038 Properties set in this way may still be changed dynamically using
2039 @code{\set} and returned to the default value set in the
2040 @code{\with} block with @code{\unset}.
2042 @cindex fontSize, default and setting
2044 So if the @code{fontSize} property is set in a @code{\with} clause
2045 it sets the default value of the font size. If it is later changed
2046 with @code{\set}, this new default value may be restored with the
2047 @code{\unset fontSize} command.
2049 @subsubheading Setting context properties with @code{\context}
2051 @cindex context properties, setting with \context
2055 The values of context properties may be set in @emph{all} contexts
2056 of a particular type, such as all @code{Staff} contexts, with a single
2057 command. The context type is identified by using its
2058 type name, like @code{Staff}, prefixed by a back-slash: @code{\Staff}.
2059 The statement which sets the property value is the same as that in a
2060 @code{\with} block, introduced above. It is placed in a
2061 @code{\context} block within a @code{\layout} block. Each
2062 @code{\context} block will affect all contexts of the type specified
2063 throughout the @code{\score} or @code{\book} block in which the
2064 @code{\layout} block appears. Here is a example to show the format:
2066 @lilypond[verbatim,quote]
2083 Context properties set in this way may be overridden for particular
2084 instances of contexts by statements in a @code{\with} block, and by
2085 @code{\set} commands embedded in music statements.
2090 @ruser{Changing context default settings}.
2091 @ruser{The set command}.
2093 Internals Reference:
2094 @rinternals{Contexts},
2095 @rinternals{Tunable context properties}.
2098 @node Ábrázolók hozzáadása és eltávolítása
2099 @subsection Ábrázolók hozzáadása és eltávolítása
2100 @translationof Adding and removing engravers
2102 @cindex engravers, adding
2103 @cindex adding engravers
2104 @cindex engravers, removing
2105 @cindex removing engravers
2112 We have seen that contexts each contain several engravers, each
2113 of which is responsible for producing a particular part of the
2114 output, like bar lines, staves, note heads, stems, etc. If an
2115 engraver is removed from a context, it can no longer produce its
2116 output. This is a crude way of modifying the output, but it
2117 can sometimes be useful.
2119 @subsubheading Changing a single context
2121 To remove an engraver from a single context we use the
2122 @code{\with} command placed immediately after the context creation
2123 command, as in the previous section.
2125 As an illustration, let's repeat an example from the previous section
2126 with the staff lines removed. Remember that the staff lines are
2127 produced by the @code{Staff_symbol_engraver}.
2129 @lilypond[quote,verbatim,ragged-right]
2131 \remove "Staff_symbol_engraver"
2135 \set fontSize = #-4 % make note heads smaller
2137 \set fontSize = #2.5 % make note heads larger
2139 \unset fontSize % return to default size
2144 @cindex ambitus engraver
2146 Engravers can also be added to individual contexts.
2147 The command to do this is
2149 @code{\consists @var{Engraver_name}},
2152 placed inside a @code{\with} block. Some vocal scores have an ambitus
2153 placed at the beginning of a staff to indicate the range of notes in
2154 that staff -- see @rglos{ambitus}. The ambitus is produced by the
2155 @code{Ambitus_engraver}, which is not normally included in any
2156 context. If we add it to the @code{Voice} context, it calculates the
2157 range from that voice only:
2159 @lilypond[quote,verbatim,ragged-right]
2162 \consists "Ambitus_engraver"
2177 but if we add the ambitus engraver to the
2178 @code{Staff} context, it calculates the range from all
2179 the notes in all the voices on that staff:
2181 @lilypond[quote,verbatim,ragged-right]
2183 \consists "Ambitus_engraver"
2199 @subsubheading Changing all contexts of the same type
2204 The examples above show how to remove or add engravers to
2205 individual contexts. It is also possible to remove or add
2206 engravers to every context of a specific type by placing the
2207 commands in the appropriate context in a @code{\layout}
2208 block. For example, if we wanted to show an ambitus for every
2209 staff in a four-staff score, we could write
2211 @lilypond[quote,verbatim,ragged-right]
2240 \consists "Ambitus_engraver"
2247 The values of context properties may also be set
2248 for all contexts of a particular type by including the
2249 @code{\set} command in a @code{\context} block in the
2254 Notation Reference: @ruser{Modifying context plug-ins},
2255 @ruser{Changing context default settings}.
2258 @node A sablonok kibővítése
2259 @section A sablonok kibővítése
2260 @translationof Extending the templates
2262 You've read the tutorial, you know how to write music, you
2263 understand the fundamental concepts. But how can you
2264 get the staves that you want? Well, you can find lots of
2265 templates (see @ref{Templates}) which may give you a start.
2266 But what if you want something that isn't covered there? Read on.
2269 * Szoprán és cselló::
2270 * Négyszólamú vegyeskar::
2271 * Kotta létrehozása az alapoktól::
2272 * Kevesebb gépelés változókkal és függvényekkel::
2273 * Partitúra és szólamkották::
2276 @node Szoprán és cselló
2277 @subsection Szoprán és cselló
2278 @translationof Soprano and cello
2280 @cindex template, modifying
2281 @cindex modifying templates
2283 Start off with the template that seems closest to what you want to
2284 end up with. Let's say that you want to write something for
2285 soprano and cello. In this case, we would start with the
2286 @q{Notes and lyrics} template (for the soprano part).
2289 \version @w{"@version{}"}
2290 melody = \relative c' @{
2297 text = \lyricmode @{
2303 \new Voice = "one" @{
2307 \new Lyrics \lyricsto "one" \text
2314 Now we want to add a cello part. Let's look at the @q{Notes only} example:
2317 \version @w{"@version{}"}
2318 melody = \relative c' @{
2332 We don't need two @code{\version} commands. We'll need the
2333 @code{melody} section. We don't want two @code{\score} sections
2334 -- if we had two @code{\score}s, we'd get the two parts separately.
2335 We want them together, as a duet. Within the @code{\score}
2336 section, we don't need two @code{\layout} or @code{\midi}.
2338 If we simply cut and paste the @code{melody} section, we would
2339 end up with two @code{melody} definitions. This would not generate
2340 an error, but the second one would be used for both melodies.
2341 So let's rename them to make them distinct. We'll call the
2342 section for the soprano @code{sopranoMusic} and the section for
2343 the cello @code{celloMusic}. While we're doing this, let's rename
2344 @code{text} to be @code{sopranoLyrics}. Remember to rename both
2345 instances of all these names -- both the initial definition (the
2346 @code{melody = \relative c' @{ } part) and the name's use (in the
2347 @code{\score} section).
2349 While we're doing this, let's change the cello part's staff --
2350 celli normally use bass clef. We'll also give the cello some
2354 \version @w{"@version{}"}
2355 sopranoMusic = \relative c' @{
2362 sopranoLyrics = \lyricmode @{
2366 celloMusic = \relative c @{
2375 \new Voice = "one" @{
2379 \new Lyrics \lyricsto "one" \sopranoLyrics
2386 This is looking promising, but the cello part won't appear in the
2387 score -- we haven't used it in the @code{\score} section. If we
2388 want the cello part to appear under the soprano part, we need to add
2391 \new Staff \celloMusic
2395 underneath the soprano stuff. We also need to add @code{<<} and
2396 @code{>>} around the music -- that tells LilyPond that there's
2397 more than one thing (in this case, two @code{Staves}) happening
2398 at once. The @code{\score} looks like this now:
2400 @c Indentation in this example is deliberately poor
2405 \new Voice = "one" @{
2409 \new Lyrics \lyricsto "one" \sopranoLyrics
2411 \new Staff \celloMusic
2419 This looks a bit messy; the indentation is messed up now. That is
2420 easily fixed. Here's the complete soprano and cello template.
2422 @lilypond[quote,verbatim,ragged-right,addversion]
2423 sopranoMusic = \relative c' {
2430 sopranoLyrics = \lyricmode {
2434 celloMusic = \relative c {
2444 \new Voice = "one" {
2448 \new Lyrics \lyricsto "one" \sopranoLyrics
2450 \new Staff \celloMusic
2459 The starting templates can be found in the @q{Templates} appendix,
2460 see @ref{Single staff}.
2463 @node Négyszólamú vegyeskar
2464 @subsection Négyszólamú vegyeskar
2465 @translationof Four-part SATB vocal score
2467 @cindex template, SATB
2468 @cindex SATB template
2470 Most vocal scores of music written for four-part mixed choir
2471 with orchestral accompaniment such as Mendelssohn's Elijah or
2472 Handel's Messiah have the choral music and words on four
2473 staves, one for each of SATB, with a piano reduction of the
2474 orchestral accompaniment underneath. Here's an example
2475 from Handel's Messiah:
2477 @c The following should appear as music without code
2478 @lilypond[quote,ragged-right]
2479 global = { \key d \major \time 4/4 }
2480 sopranoMusic = \relative c'' {
2482 r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2484 sopranoWords = \lyricmode {
2485 Wor -- thy is the lamb that was slain
2487 altoMusic = \relative a' {
2489 r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
2491 altoWords = \sopranoWords
2492 tenorMusic = \relative c' {
2494 r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2496 tenorWords = \sopranoWords
2497 bassMusic = \relative c' {
2499 r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2501 bassWords = \sopranoWords
2502 upper = \relative a' {
2505 r4 <a d fis>2 <a e' a>4
2506 <d fis d'>4. <d fis d'>8 <a d a'>2
2507 <g cis g'>4 <a d fis> <a cis e>2
2509 lower = \relative c, {
2512 <d d'>4 <d d'>2 <cis cis'>4
2513 <b b'>4. <b' b'>8 <fis fis'>2
2514 <e e'>4 <d d'> <a' a'>2
2518 << % combine ChoirStaff and PianoStaff in parallel
2520 \new Staff = "sopranos" <<
2521 \set Staff.instrumentName = #"Soprano"
2522 \new Voice = "sopranos" {
2527 \new Lyrics \lyricsto "sopranos" {
2530 \new Staff = "altos" <<
2531 \set Staff.instrumentName = #"Alto"
2532 \new Voice = "altos" {
2537 \new Lyrics \lyricsto "altos" { \altoWords }
2538 \new Staff = "tenors" <<
2539 \set Staff.instrumentName = #"Tenor"
2540 \new Voice = "tenors" {
2545 \new Lyrics \lyricsto "tenors" { \tenorWords }
2546 \new Staff = "basses" <<
2547 \set Staff.instrumentName = #"Bass"
2548 \new Voice = "basses" {
2553 \new Lyrics \lyricsto "basses" {
2558 \set PianoStaff.instrumentName = #"Piano"
2559 \new Staff = "upper" \upper
2560 \new Staff = "lower" \lower
2566 None of the templates provides this layout exactly. The nearest is
2567 @q{SATB vocal score and automatic piano reduction} -- see @ref{Vocal
2568 ensembles} -- but we need to change the layout and add a piano
2569 accompaniment which is not derived automatically from the vocal parts.
2570 The variables holding the music and words for the vocal parts are
2571 fine, but we shall need to add variables for the piano reduction.
2573 The order in which the contexts appear in the ChoirStaff of the
2574 template do not correspond with the order in the vocal score shown
2575 above. We need to rearrange them so there are four staves with the
2576 words written directly underneath the notes for each part. All the
2577 voices should be @code{\voiceOne}, which is the default, so the
2578 @code{\voiceXXX} commands should be removed. We also need to specify
2579 the tenor clef for the tenors. The way in which lyrics are specified
2580 in the template has not yet been encountered so we need to use the
2581 method with which we are familiar. We should also add the names of
2584 Doing this gives for our ChoirStaff:
2588 \new Staff = "sopranos" <<
2589 \set Staff.instrumentName = #"Soprano"
2590 \new Voice = "sopranos" @{
2595 \new Lyrics \lyricsto "sopranos" @{
2598 \new Staff = "altos" <<
2599 \set Staff.instrumentName = #"Alto"
2600 \new Voice = "altos" @{
2605 \new Lyrics \lyricsto "altos" @{
2608 \new Staff = "tenors" <<
2609 \set Staff.instrumentName = #"Tenor"
2610 \new Voice = "tenors" @{
2615 \new Lyrics \lyricsto "tenors" @{
2618 \new Staff = "basses" <<
2619 \set Staff.instrumentName = #"Bass"
2620 \new Voice = "basses" @{
2625 \new Lyrics \lyricsto "basses" @{
2631 Next we must work out the piano part. This is
2632 easy - we just pull out the piano part from the
2633 @q{Solo piano} template:
2637 \set PianoStaff.instrumentName = #"Piano "
2638 \new Staff = "upper" \upper
2639 \new Staff = "lower" \lower
2643 and add the variable definitions for @code{upper}
2646 The ChoirStaff and PianoStaff must be combined
2647 using angle brackets as we want them to be
2648 stacked one above the other:
2651 << % combine ChoirStaff and PianoStaff one above the other
2653 \new Staff = "sopranos" <<
2654 \new Voice = "sopranos" @{
2659 \new Lyrics \lyricsto "sopranos" @{
2662 \new Staff = "altos" <<
2663 \new Voice = "altos" @{
2668 \new Lyrics \lyricsto "altos" @{
2671 \new Staff = "tenors" <<
2672 \clef "G_8" % tenor clef
2673 \new Voice = "tenors" @{
2678 \new Lyrics \lyricsto "tenors" @{
2681 \new Staff = "basses" <<
2683 \new Voice = "basses" @{
2688 \new Lyrics \lyricsto "basses" @{
2694 \set PianoStaff.instrumentName = #"Piano"
2695 \new Staff = "upper" \upper
2696 \new Staff = "lower" \lower
2701 Combining all these together and adding the music
2702 for the three bars of the example above gives:
2704 @lilypond[quote,verbatim,ragged-right,addversion]
2709 sopranoMusic = \relative c'' {
2711 r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2713 sopranoWords = \lyricmode {
2714 Wor -- thy is the lamb that was slain
2716 altoMusic = \relative a' {
2718 r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
2720 altoWords = \sopranoWords
2721 tenorMusic = \relative c' {
2723 r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2725 tenorWords = \sopranoWords
2726 bassMusic = \relative c' {
2728 r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2730 bassWords = \sopranoWords
2731 upper = \relative a' {
2734 r4 <a d fis>2 <a e' a>4
2735 <d fis d'>4. <d fis d'>8 <a d a'>2
2736 <g cis g'>4 <a d fis> <a cis e>2
2738 lower = \relative c, {
2741 <d d'>4 <d d'>2 <cis cis'>4
2742 <b b'>4. <b' b'>8 <fis fis'>2
2743 <e e'>4 <d d'> <a' a'>2
2747 << % combine ChoirStaff and PianoStaff in parallel
2749 \new Staff = "sopranos" <<
2750 \set Staff.instrumentName = #"Soprano"
2751 \new Voice = "sopranos" {
2756 \new Lyrics \lyricsto "sopranos" {
2759 \new Staff = "altos" <<
2760 \set Staff.instrumentName = #"Alto"
2761 \new Voice = "altos" {
2766 \new Lyrics \lyricsto "altos" {
2769 \new Staff = "tenors" <<
2770 \set Staff.instrumentName = #"Tenor"
2771 \new Voice = "tenors" {
2776 \new Lyrics \lyricsto "tenors" {
2779 \new Staff = "basses" <<
2780 \set Staff.instrumentName = #"Bass"
2781 \new Voice = "basses" {
2786 \new Lyrics \lyricsto "basses" {
2792 \set PianoStaff.instrumentName = #"Piano "
2793 \new Staff = "upper" \upper
2794 \new Staff = "lower" \lower
2801 @node Kotta létrehozása az alapoktól
2802 @subsection Kotta létrehozása az alapoktól
2803 @translationof Building a score from scratch
2805 @cindex template, writing your own
2806 @cindex example of writing a score
2807 @cindex writing a score, example
2808 @cindex score, example of writing
2810 After gaining some facility with writing LilyPond code, you
2811 may find that it is easier to build a score from scratch
2812 rather than modifying one of the templates. You can also
2813 develop your own style this way to suit the sort of music you
2814 like. Let's see how to put together the score for an organ
2815 prelude as an example.
2817 We begin with a header section. Here go the title, name
2818 of composer, etc, then come any variable definitions, and
2819 finally the score block. Let's start with these in outline
2820 and fill in the details later.
2822 We'll use the first two bars of Bach's prelude
2823 based on @emph{Jesu, meine Freude} which is written for two
2824 manuals and pedal organ. You can see these two bars of music
2825 at the bottom of this section. The top manual part has two voices,
2826 the lower and pedal organ one each. So we need four
2827 music definitions and one to define the time signature
2831 \version @w{"@version{}"}
2833 title = "Jesu, meine Freude"
2834 composer = "J S Bach"
2840 ManualOneVoiceOneMusic = @{ s1 @}
2841 ManualOneVoiceTwoMusic = @{ s1 @}
2842 ManualTwoMusic = @{ s1 @}
2843 PedalOrganMusic = @{ s1 @}
2849 For now we've just used a spacer note, @code{s1},
2850 instead of the real music. We'll add that later.
2852 Next let's see what should go in the score block.
2853 We simply mirror the staff structure we want.
2854 Organ music is usually written on three staves,
2855 one for each manual and one for the pedals. The
2856 manual staves should be bracketed together, so we
2857 need to use a PianoStaff for them. The first
2858 manual part needs two voices and the second manual
2863 \new Staff = "ManualOne" <<
2865 \ManualOneVoiceOneMusic
2868 \ManualOneVoiceTwoMusic
2870 >> % end ManualOne Staff context
2871 \new Staff = "ManualTwo" <<
2875 >> % end ManualTwo Staff context
2876 >> % end PianoStaff context
2879 Next we need to add a staff for the pedal organ.
2880 This goes underneath the PianoStaff, but it must
2881 be simultaneous with it, so we need angle brackets
2882 around the two. Missing these out would generate
2883 an error in the log file. It's a common mistake
2884 which you'll make sooner or later! Try copying
2885 the final example at the end of this section,
2886 remove these angle brackets, and compile it to
2887 see what errors it generates.
2890 << % PianoStaff and Pedal Staff must be simultaneous
2892 \new Staff = "ManualOne" <<
2894 \ManualOneVoiceOneMusic
2897 \ManualOneVoiceTwoMusic
2899 >> % end ManualOne Staff context
2900 \new Staff = "ManualTwo" <<
2904 >> % end ManualTwo Staff context
2905 >> % end PianoStaff context
2906 \new Staff = "PedalOrgan" <<
2914 It is not necessary to use the simultaneous construct
2915 @code{<< .. >>} for the manual two staff and the pedal organ staff,
2916 since they contain only one music expression, but it does no harm,
2917 and always using angle brackets after @code{\new Staff} is a good
2918 habit to cultivate in case there are multiple voices. The opposite
2919 is true for Voices: these should habitually be followed by braces
2920 @code{@{ .. @}} in case your music is coded in several variables
2921 which need to run consecutively.
2923 Let's add this structure to the score block, and adjust the indenting.
2924 We also add the appropriate clefs, ensure stems, ties and slurs in
2925 each voice on the upper staff point to the right direction with
2926 @code{\voiceOne} and @code{\voiceTwo}, and enter the time signature
2927 and key to each staff using our predefined variable, @code{\TimeKey}.
2931 << % PianoStaff and Pedal Staff must be simultaneous
2933 \new Staff = "ManualOne" <<
2934 \TimeKey % set time signature and key
2938 \ManualOneVoiceOneMusic
2942 \ManualOneVoiceTwoMusic
2944 >> % end ManualOne Staff context
2945 \new Staff = "ManualTwo" <<
2951 >> % end ManualTwo Staff context
2952 >> % end PianoStaff context
2953 \new Staff = "PedalOrgan" <<
2959 >> % end PedalOrgan Staff
2961 @} % end Score context
2964 That completes the structure. Any three-staff organ music
2965 will have a similar structure, although the number of voices
2966 may vary. All that remains now
2967 is to add the music, and combine all the parts together.
2969 @lilypond[quote,verbatim,ragged-right,addversion]
2971 title = "Jesu, meine Freude"
2972 composer = "J S Bach"
2978 ManualOneVoiceOneMusic = \relative g' {
2982 ManualOneVoiceTwoMusic = \relative c' {
2983 ees16 d ees8~ ees16 f ees d c8 d~ d c~
2984 c c4 b8 c8. g16 c b c d
2986 ManualTwoMusic = \relative c' {
2987 c16 b c8~ c16 b c g a8 g~ g16 g aes ees
2988 f ees f d g aes g f ees d e8~ ees16 f ees d
2990 PedalOrganMusic = \relative c {
2991 r8 c16 d ees d ees8~ ees16 a, b g c b c8
2992 r16 g ees f g f g8 c,2
2996 << % PianoStaff and Pedal Staff must be simultaneous
2998 \new Staff = "ManualOne" <<
2999 \TimeKey % set time signature and key
3003 \ManualOneVoiceOneMusic
3007 \ManualOneVoiceTwoMusic
3009 >> % end ManualOne Staff context
3010 \new Staff = "ManualTwo" <<
3016 >> % end ManualTwo Staff context
3017 >> % end PianoStaff context
3018 \new Staff = "PedalOrgan" <<
3024 >> % end PedalOrgan Staff context
3026 } % end Score context
3030 @node Kevesebb gépelés változókkal és függvényekkel
3031 @subsection Kevesebb gépelés változókkal és függvényekkel
3032 @translationof Saving typing with variables and functions
3037 By this point, you've seen this kind of thing:
3039 @lilypond[quote,verbatim,ragged-right]
3040 hornNotes = \relative c'' { c4 b dis c }
3048 You may even realize that this could be useful in minimalist music:
3050 @lilypond[quote,verbatim,ragged-right]
3051 fragmentA = \relative c'' { a4 a8. b16 }
3052 fragmentB = \relative c'' { a8. gis16 ees4 }
3053 violin = \new Staff {
3066 However, you can also use these variables (also known as
3067 macros, or user-defined commands) for tweaks:
3069 @c TODO Avoid padtext - not needed with skylining
3070 @lilypond[quote,verbatim,ragged-right]
3071 dolce = \markup { \italic \bold dolce }
3072 padText = { \once \override TextScript.padding = #5.0 }
3073 fthenp=_\markup { \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p }
3074 violin = \relative c'' {
3076 c4._\dolce b8 a8 g a b
3078 c4.^"hi there!" d8 e' f g d
3079 c,4.\fthenp b8 c4 c-.
3086 \layout { ragged-right=##t }
3090 These variables are obviously useful for saving
3091 typing. But they're worth considering even if you
3092 only use them once -- they reduce complexity. Let's
3093 look at the previous example without any
3094 variables. It's a lot harder to read, especially
3098 violin = \relative c'' @{
3100 c4._\markup @{ \italic \bold dolce @} b8 a8 g a b
3101 \once \override TextScript.padding = #5.0
3102 c4.^"hi there!" d8 e' f g d
3103 c,4.\markup @{ \dynamic f \italic \small @{ 2nd @}
3104 \hspace #0.1 \dynamic p @}
3110 @c TODO Replace the following with a better example -td
3111 @c Skylining handles this correctly without padText
3113 So far we've seen static substitution -- when LilyPond
3114 sees @code{\padText}, it replaces it with the stuff that
3115 we've defined it to be (ie the stuff to the right of
3118 LilyPond can handle non-static substitution, too (you
3119 can think of these as functions).
3121 @lilypond[quote,verbatim,ragged-right]
3123 #(define-music-function (parser location padding) (number?)
3125 \once \override TextScript.padding = #padding
3129 c4^"piu mosso" b a b
3131 c4^"piu mosso" d e f
3133 c4^"piu mosso" fis a g
3137 Using variables is also a good way to reduce work if the
3138 LilyPond input syntax changes (see
3139 @rprogram{Updating files with convert-ly}). If
3140 you have a single definition (such as @code{\dolce}) for all your
3141 input files (see @ref{Style sheets}), then if the syntax changes, you
3142 only need to update your single @code{\dolce} definition,
3143 instead of making changes throughout every @file{.ly} file.
3146 @node Partitúra és szólamkották
3147 @subsection Partitúra és szólamkották
3148 @translationof Scores and parts
3150 In orchestral music, all notes are printed twice. Once in a part for
3151 the musicians, and once in a full score for the conductor. Variables can
3152 be used to avoid double work. The music is entered once, and stored in
3153 a variable. The contents of that variable is then used to generate
3154 both the part and the full score.
3156 It is convenient to define the notes in a special file. For example,
3157 suppose that the file @file{horn-music.ly} contains the following part
3158 of a horn/@/bassoon duo
3161 hornNotes = \relative c @{
3168 Then, an individual part is made by putting the following in a file
3171 \include "horn-music.ly"
3173 instrument = "Horn in F"
3177 \transpose f c' \hornNotes
3184 \include "horn-music.ly"
3188 substitutes the contents of @file{horn-music.ly} at this position in
3189 the file, so @code{hornNotes} is defined afterwards. The command
3190 @code{\transpose f@tie{}c'} indicates that the argument, being
3191 @code{\hornNotes}, should be transposed by a fifth upwards. Sounding
3192 @code{f} is denoted by notated @code{c'}, which corresponds with the
3193 tuning of a normal French Horn in@tie{}F. The transposition can be seen
3194 in the following output
3196 @lilypond[quote,ragged-right]
3197 \transpose f c' \relative c {
3203 In ensemble pieces, one of the voices often does not play for many
3204 measures. This is denoted by a special rest, the multi-measure
3205 rest. It is entered with a capital @code{R} followed by a duration
3206 (@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
3207 etc.). By multiplying the
3208 duration, longer rests can be constructed. For example, this rest
3209 takes 3@tie{}measures in 2/4 time
3215 When printing the part, multi-rests
3216 must be condensed. This is done by setting a run-time variable
3219 \set Score.skipBars = ##t
3223 This command sets the property @code{skipBars} in the
3224 @code{Score} context to true (@code{##t}). Prepending the rest and
3225 this option to the music above, leads to the following result
3227 @lilypond[quote,ragged-right]
3228 \transpose f c' \relative c {
3230 \set Score.skipBars = ##t
3237 The score is made by combining all of the music together. Assuming
3238 that the other voice is in @code{bassoonNotes} in the file
3239 @file{bassoon-music.ly}, a score is made with
3242 \include "bassoon-music.ly"
3243 \include "horn-music.ly"
3246 \new Staff \hornNotes
3247 \new Staff \bassoonNotes
3254 @lilypond[quote,ragged-right]
3263 r4 d,8 f | gis4 c | b bes |
3264 a8 e f4 | g d | gis f |