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 @item New_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
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
1764 @item Staff_symbol_engraver
1765 @tab Engraves the five (by default) lines of the staff
1767 @tab Creates stems and single-stem tremolos
1768 @item Time_signature_engraver
1769 @tab Creates time signatures
1774 We shall see later how the output of LilyPond can be changed
1775 by modifying the action of Engravers.
1779 Internals reference: @rinternals{Engravers and Performers}.
1782 @node Kontextusok tulajdonságainak módosítása
1783 @subsection Kontextusok tulajdonságainak módosítása
1784 @translationof Modifying context properties
1786 @cindex context properties
1787 @cindex context properties, modifying
1788 @cindex modifying context properties
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
1801 \set @emph{ContextName}.@emph{propertyName} = #@emph{value}
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.
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.
1813 @c attempt to force this onto a new page
1815 @multitable @columnfractions .25 .15 .45 .15
1816 @headitem propertyName
1822 @tab If true, set extra natural signs before accidentals
1823 @tab @code{#t}, @code{#f}
1824 @item currentBarNumber
1826 @tab Set the current bar number
1830 @tab If true, print slurs both above and below notes
1831 @tab @code{#t}, @code{#f}
1832 @item instrumentName
1834 @tab Set the name to be placed at the start of the staff
1835 @tab @code{"Cello I"}
1838 @tab Increase or decrease the font size
1842 @tab Set the text to print before the start of a verse
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}.
1856 @cindex properties operating in contexts
1857 @cindex setting properties within contexts
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.
1869 @lilypond[quote,verbatim,ragged-right]
1871 \new Staff \relative c'' {
1872 \set Staff.instrumentName = #"Soprano"
1875 \new Staff \relative c' {
1876 \set instrumentName = #"Alto" % Wrong!
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.
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}.
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.
1912 So this turns off extra naturals in one staff:
1914 @lilypond[quote,verbatim,ragged-right]
1916 \new Staff \relative c'' {
1919 \new Staff \relative c'' {
1920 \set Staff.extraNatural = ##f
1927 and this turns them off in all staves:
1929 @lilypond[quote,verbatim,ragged-right]
1931 \new Staff \relative c'' {
1934 \new Staff \relative c'' {
1935 \set Score.extraNatural = ##f
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.
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
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.
1960 @lilypond[quote,verbatim,ragged-right,relative=1,fragment]
1962 % make note heads smaller
1965 % make note heads larger
1966 \set fontSize = #2.5
1968 % return to default size
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.
1981 @subsubheading Setting context properties with @code{\with}
1985 @cindex context properties, setting with \with
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:
1997 \new Staff \with @{ extraNatural = ##f @}
2003 @lilypond[quote,verbatim,ragged-right]
2009 \new Staff \with { extraNatural = ##f }
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:
2020 @lilypond[quote,verbatim,ragged-right]
2022 \new Score \with { extraNatural = ##f } <<
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}.
2041 @cindex fontSize, default and setting
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.
2048 @subsubheading Setting context properties with @code{\context}
2050 @cindex context properties, setting with \context
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:
2065 @lilypond[verbatim,quote]
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.
2089 @ruser{Changing context default settings}.
2090 @ruser{The set command}.
2092 Internals Reference:
2093 @rinternals{Contexts},
2094 @rinternals{Tunable context properties}.
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
2101 @cindex engravers, adding
2102 @cindex adding engravers
2103 @cindex engravers, removing
2104 @cindex removing engravers
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.
2118 @subsubheading Changing a single context
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.
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}.
2128 @lilypond[quote,verbatim,ragged-right]
2130 \remove "Staff_symbol_engraver"
2134 \set fontSize = #-4 % make note heads smaller
2136 \set fontSize = #2.5 % make note heads larger
2138 \unset fontSize % return to default size
2143 @cindex ambitus engraver
2145 Engravers can also be added to individual contexts.
2146 The command to do this is
2148 @code{\consists @var{Engraver_name}},
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:
2158 @lilypond[quote,verbatim,ragged-right]
2161 \consists "Ambitus_engraver"
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:
2180 @lilypond[quote,verbatim,ragged-right]
2182 \consists "Ambitus_engraver"
2198 @subsubheading Changing all contexts of the same type
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
2210 @lilypond[quote,verbatim,ragged-right]
2239 \consists "Ambitus_engraver"
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
2253 Notation Reference: @ruser{Modifying context plug-ins},
2254 @ruser{Changing context default settings}.
2257 @node A sablonok kibővítése
2258 @section A sablonok kibővítése
2259 @translationof Extending the templates
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.
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::
2275 @node Szoprán és cselló
2276 @subsection Szoprán és cselló
2277 @translationof Soprano and cello
2279 @cindex template, modifying
2280 @cindex modifying templates
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).
2288 \version @w{"@version{}"}
2289 melody = \relative c' @{
2296 text = \lyricmode @{
2302 \new Voice = "one" @{
2306 \new Lyrics \lyricsto "one" \text
2313 Now we want to add a cello part. Let's look at the @q{Notes only} example:
2316 \version @w{"@version{}"}
2317 melody = \relative c' @{
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}.
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).
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
2353 \version @w{"@version{}"}
2354 sopranoMusic = \relative c' @{
2361 sopranoLyrics = \lyricmode @{
2365 celloMusic = \relative c @{
2374 \new Voice = "one" @{
2378 \new Lyrics \lyricsto "one" \sopranoLyrics
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
2390 \new Staff \celloMusic
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:
2399 @c Indentation in this example is deliberately poor
2404 \new Voice = "one" @{
2408 \new Lyrics \lyricsto "one" \sopranoLyrics
2410 \new Staff \celloMusic
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.
2421 @lilypond[quote,verbatim,ragged-right,addversion]
2422 sopranoMusic = \relative c' {
2429 sopranoLyrics = \lyricmode {
2433 celloMusic = \relative c {
2443 \new Voice = "one" {
2447 \new Lyrics \lyricsto "one" \sopranoLyrics
2449 \new Staff \celloMusic
2458 The starting templates can be found in the @q{Templates} appendix,
2459 see @ref{Single staff}.
2462 @node Négyszólamú vegyeskar
2463 @subsection Négyszólamú vegyeskar
2464 @translationof Four-part SATB vocal score
2466 @cindex template, SATB
2467 @cindex SATB template
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:
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'' {
2481 r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2483 sopranoWords = \lyricmode {
2484 Wor -- thy is the lamb that was slain
2486 altoMusic = \relative a' {
2488 r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
2490 altoWords = \sopranoWords
2491 tenorMusic = \relative c' {
2493 r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2495 tenorWords = \sopranoWords
2496 bassMusic = \relative c' {
2498 r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2500 bassWords = \sopranoWords
2501 upper = \relative a' {
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
2508 lower = \relative c, {
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
2517 << % combine ChoirStaff and PianoStaff in parallel
2519 \new Staff = "sopranos" <<
2520 \set Staff.instrumentName = #"Soprano"
2521 \new Voice = "sopranos" {
2526 \new Lyrics \lyricsto "sopranos" {
2529 \new Staff = "altos" <<
2530 \set Staff.instrumentName = #"Alto"
2531 \new Voice = "altos" {
2536 \new Lyrics \lyricsto "altos" { \altoWords }
2537 \new Staff = "tenors" <<
2538 \set Staff.instrumentName = #"Tenor"
2539 \new Voice = "tenors" {
2544 \new Lyrics \lyricsto "tenors" { \tenorWords }
2545 \new Staff = "basses" <<
2546 \set Staff.instrumentName = #"Bass"
2547 \new Voice = "basses" {
2552 \new Lyrics \lyricsto "basses" {
2557 \set PianoStaff.instrumentName = #"Piano"
2558 \new Staff = "upper" \upper
2559 \new Staff = "lower" \lower
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.
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
2583 Doing this gives for our ChoirStaff:
2587 \new Staff = "sopranos" <<
2588 \set Staff.instrumentName = #"Soprano"
2589 \new Voice = "sopranos" @{
2594 \new Lyrics \lyricsto "sopranos" @{
2597 \new Staff = "altos" <<
2598 \set Staff.instrumentName = #"Alto"
2599 \new Voice = "altos" @{
2604 \new Lyrics \lyricsto "altos" @{
2607 \new Staff = "tenors" <<
2608 \set Staff.instrumentName = #"Tenor"
2609 \new Voice = "tenors" @{
2614 \new Lyrics \lyricsto "tenors" @{
2617 \new Staff = "basses" <<
2618 \set Staff.instrumentName = #"Bass"
2619 \new Voice = "basses" @{
2624 \new Lyrics \lyricsto "basses" @{
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:
2636 \set PianoStaff.instrumentName = #"Piano "
2637 \new Staff = "upper" \upper
2638 \new Staff = "lower" \lower
2642 and add the variable definitions for @code{upper}
2645 The ChoirStaff and PianoStaff must be combined
2646 using angle brackets as we want them to be
2647 stacked one above the other:
2650 << % combine ChoirStaff and PianoStaff one above the other
2652 \new Staff = "sopranos" <<
2653 \new Voice = "sopranos" @{
2658 \new Lyrics \lyricsto "sopranos" @{
2661 \new Staff = "altos" <<
2662 \new Voice = "altos" @{
2667 \new Lyrics \lyricsto "altos" @{
2670 \new Staff = "tenors" <<
2671 \clef "G_8" % tenor clef
2672 \new Voice = "tenors" @{
2677 \new Lyrics \lyricsto "tenors" @{
2680 \new Staff = "basses" <<
2682 \new Voice = "basses" @{
2687 \new Lyrics \lyricsto "basses" @{
2693 \set PianoStaff.instrumentName = #"Piano"
2694 \new Staff = "upper" \upper
2695 \new Staff = "lower" \lower
2700 Combining all these together and adding the music
2701 for the three bars of the example above gives:
2703 @lilypond[quote,verbatim,ragged-right,addversion]
2708 sopranoMusic = \relative c'' {
2710 r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
2712 sopranoWords = \lyricmode {
2713 Wor -- thy is the lamb that was slain
2715 altoMusic = \relative a' {
2717 r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
2719 altoWords = \sopranoWords
2720 tenorMusic = \relative c' {
2722 r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
2724 tenorWords = \sopranoWords
2725 bassMusic = \relative c' {
2727 r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
2729 bassWords = \sopranoWords
2730 upper = \relative a' {
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
2737 lower = \relative c, {
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
2746 << % combine ChoirStaff and PianoStaff in parallel
2748 \new Staff = "sopranos" <<
2749 \set Staff.instrumentName = #"Soprano"
2750 \new Voice = "sopranos" {
2755 \new Lyrics \lyricsto "sopranos" {
2758 \new Staff = "altos" <<
2759 \set Staff.instrumentName = #"Alto"
2760 \new Voice = "altos" {
2765 \new Lyrics \lyricsto "altos" {
2768 \new Staff = "tenors" <<
2769 \set Staff.instrumentName = #"Tenor"
2770 \new Voice = "tenors" {
2775 \new Lyrics \lyricsto "tenors" {
2778 \new Staff = "basses" <<
2779 \set Staff.instrumentName = #"Bass"
2780 \new Voice = "basses" {
2785 \new Lyrics \lyricsto "basses" {
2791 \set PianoStaff.instrumentName = #"Piano "
2792 \new Staff = "upper" \upper
2793 \new Staff = "lower" \lower
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
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
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.
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.
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
2830 \version @w{"@version{}"}
2832 title = "Jesu, meine Freude"
2833 composer = "J S Bach"
2839 ManualOneVoiceOneMusic = @{ s1 @}
2840 ManualOneVoiceTwoMusic = @{ s1 @}
2841 ManualTwoMusic = @{ s1 @}
2842 PedalOrganMusic = @{ s1 @}
2848 For now we've just used a spacer note, @code{s1},
2849 instead of the real music. We'll add that later.
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
2862 \new Staff = "ManualOne" <<
2864 \ManualOneVoiceOneMusic
2867 \ManualOneVoiceTwoMusic
2869 >> % end ManualOne Staff context
2870 \new Staff = "ManualTwo" <<
2874 >> % end ManualTwo Staff context
2875 >> % end PianoStaff context
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.
2889 << % PianoStaff and Pedal Staff must be simultaneous
2891 \new Staff = "ManualOne" <<
2893 \ManualOneVoiceOneMusic
2896 \ManualOneVoiceTwoMusic
2898 >> % end ManualOne Staff context
2899 \new Staff = "ManualTwo" <<
2903 >> % end ManualTwo Staff context
2904 >> % end PianoStaff context
2905 \new Staff = "PedalOrgan" <<
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.
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}.
2930 << % PianoStaff and Pedal Staff must be simultaneous
2932 \new Staff = "ManualOne" <<
2933 \TimeKey % set time signature and key
2937 \ManualOneVoiceOneMusic
2941 \ManualOneVoiceTwoMusic
2943 >> % end ManualOne Staff context
2944 \new Staff = "ManualTwo" <<
2950 >> % end ManualTwo Staff context
2951 >> % end PianoStaff context
2952 \new Staff = "PedalOrgan" <<
2958 >> % end PedalOrgan Staff
2960 @} % end Score context
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.
2968 @lilypond[quote,verbatim,ragged-right,addversion]
2970 title = "Jesu, meine Freude"
2971 composer = "J S Bach"
2977 ManualOneVoiceOneMusic = \relative g' {
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
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
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
2995 << % PianoStaff and Pedal Staff must be simultaneous
2997 \new Staff = "ManualOne" <<
2998 \TimeKey % set time signature and key
3002 \ManualOneVoiceOneMusic
3006 \ManualOneVoiceTwoMusic
3008 >> % end ManualOne Staff context
3009 \new Staff = "ManualTwo" <<
3015 >> % end ManualTwo Staff context
3016 >> % end PianoStaff context
3017 \new Staff = "PedalOrgan" <<
3023 >> % end PedalOrgan Staff context
3025 } % end Score context
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
3036 By this point, you've seen this kind of thing:
3038 @lilypond[quote,verbatim,ragged-right]
3039 hornNotes = \relative c'' { c4 b dis c }
3047 You may even realize that this could be useful in minimalist music:
3049 @lilypond[quote,verbatim,ragged-right]
3050 fragmentA = \relative c'' { a4 a8. b16 }
3051 fragmentB = \relative c'' { a8. gis16 ees4 }
3052 violin = \new Staff {
3065 However, you can also use these variables (also known as
3066 macros, or user-defined commands) for tweaks:
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'' {
3075 c4._\dolce b8 a8 g a b
3077 c4.^"hi there!" d8 e' f g d
3078 c,4.\fthenp b8 c4 c-.
3085 \layout { ragged-right=##t }
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
3097 violin = \relative c'' @{
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 @}
3109 @c TODO Replace the following with a better example -td
3110 @c Skylining handles this correctly without padText
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
3117 LilyPond can handle non-static substitution, too (you
3118 can think of these as functions).
3120 @lilypond[quote,verbatim,ragged-right]
3122 #(define-music-function (parser location padding) (number?)
3124 \once \override TextScript.padding = #padding
3128 c4^"piu mosso" b a b
3130 c4^"piu mosso" d e f
3132 c4^"piu mosso" fis a g
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.
3145 @node Partitúra és szólamkották
3146 @subsection Partitúra és szólamkották
3147 @translationof Scores and parts
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.
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
3160 hornNotes = \relative c @{
3167 Then, an individual part is made by putting the following in a file
3170 \include "horn-music.ly"
3172 instrument = "Horn in F"
3176 \transpose f c' \hornNotes
3183 \include "horn-music.ly"
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
3195 @lilypond[quote,ragged-right]
3196 \transpose f c' \relative c {
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
3214 When printing the part, multi-rests
3215 must be condensed. This is done by setting a run-time variable
3218 \set Score.skipBars = ##t
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
3226 @lilypond[quote,ragged-right]
3227 \transpose f c' \relative c {
3229 \set Score.skipBars = ##t
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
3241 \include "bassoon-music.ly"
3242 \include "horn-music.ly"
3245 \new Staff \hornNotes
3246 \new Staff \bassoonNotes
3253 @lilypond[quote,ragged-right]
3262 r4 d,8 f | gis4 c | b bes |
3263 a8 e f4 | g d | gis f |