<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- header_tag --> <html lang="en"> <head> <title>I'm hearing Voices - GNU LilyPond Learning Manual</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="description" content="GNU LilyPond Learning Manual"> <meta name="generator" content="makeinfo 4.11"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Voices-contain-music.html#Voices-contain-music" title="Voices contain music"> <link rel="next" href="Explicitly-instantiating-voices.html#Explicitly-instantiating-voices" title="Explicitly instantiating voices"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1999--2007 by the authors Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } hr { border:0; height:1; color: #000000; background-color: #000000; } /* hr { border: none; height: 1px; color: #666666; background-color: #666666; } body { border-left: 1px solid #666666; border-right: 1px solid #666666; color: #332d28; margin-right: auto; margin-left: auto; width: 60em; list-style-type: square; font-family: Arial,Helvetica,sans-serif; padding-right: 1em; padding-left: 1em; } a { border-bottom: 1px dashed #344242; text-decoration: none; color: #344242; } a:link { text-decoration: none; } a:visited { border-bottom: 1px dashed #666666; color: #666666; } a:active { border-bottom: 1px solid #00cccc; color: #00cccc; } a:hover { border-bottom: 1px solid #1d7b85; color: #1d7b85; } blockquote { border: 1px solid #cccccc; padding: 3px; width: 40em; } .node { border-left: 1px solid #666666; margin: -0.5em 0px 1em; padding: 2px 1px 0px; font-style: italic; } .node a { border: none; text-decoration: underline; font-style: normal; font-weight: bold; } .verbatim { font-family: "Courier New",Courier,monospace; } .unnumberedsubsubsec { font-size: large; color: #1d7b85; } .subsubheading { font-size: large; color: #3b220d; } .contents { border: 1px dashed #339999; margin: 3px 2em; list-style-type: square; padding-right: 1em; width: 40em; background-color: #fcfff9; } .contents a { border-bottom: 1px dashed #423d34; text-decoration: none; color: #423d34; } .contents a:visited { border-bottom: 1px dashed #666666; color: #666666; } .contents a:active { border-bottom: 1px solid #f0d86d; color: #f0d86d; } .contents a:hover { border-bottom: 1px solid #3b220d; color: #3b220d; } .menu { border-left: 1px dashed #339999; margin: 3px 2em 1em; list-style-type: square; padding-left: 1.4em; width: 40em; } .unnumbered { } h2 { font-size: x-large; color: #1d7b85; } */ --></style> </head> <BODY BGCOLOR=WHITE TEXT=BLACK> <div class="node"> <p> <a name="I'm-hearing-Voices"></a> <a name="I_0027m-hearing-Voices"></a> Next: <a rel="next" accesskey="n" href="Explicitly-instantiating-voices.html#Explicitly-instantiating-voices">Explicitly instantiating voices</a>, Up: <a rel="up" accesskey="u" href="Voices-contain-music.html#Voices-contain-music">Voices contain music</a> <hr> </div> <h4 class="subsection">3.2.1 I'm hearing Voices</h4> <p><a name="index-polyphony-210"></a><a name="index-layers-211"></a><a name="index-multiple-voices-212"></a><a name="index-Voice-context-213"></a><a name="index-context_002c-Voice-214"></a><a name="index-simultaneous-music-215"></a><a name="index-concurrent-music-216"></a> The lowest, most fundamental or innermost layers in a LilyPond score are called ‘Voice contexts’ or just ‘Voices’ for short. Voices are sometimes called ‘layers’ in other notation packages. <p>In fact, a Voice layer or context is the only one which can contain music. If a Voice context is not explicitly declared one is created automatically, as we saw at the beginning of this chapter. Some instruments such as an Oboe can play only one note at a time. Music written for such instruments is monophonic and requires just a single voice. Instruments which can play more than one note at a time like the piano will often require multiple voices to encode the different concurrent notes and rhythms they are capable of playing. <p>A single voice can contain many notes in a chord, of course, so when exactly are multiple voices needed? Look first at this example of four chords: <blockquote> <pre class="verbatim"> \key g \major <d g>4 <d fis> <d a'> <d g> </pre> <p> <a href="../09/lily-6fcb223b.ly"> <img align="middle" border="0" src="../09/lily-6fcb223b.png" alt="[image of music]"> </a> </p> </blockquote> <p>This can be expressed using just the single angle bracket chord symbols, <code>< ... ></code>, and for this just a single voice is needed. But suppose the F-sharp were actually an eighth-note followed by an eighth-note G, a passing note on the way to the A? Now we have two notes which start at the same time but have different durations: the quarter-note D and the eighth-note F-sharp. How are these to be coded? They cannot be written as a chord because all the notes in a chord must have the same duration. And they cannot be written as two sequential notes as they need to start at the same time. This is when two voices are required. <p>Let us see how this is done in LilyPond input syntax. <p><a name="index-g_t_003c_003c-_005c_005c-_003e_003e-217"></a><a name="index-g_t_003c_003c-_005c_005c-_003e_003e-218"></a> <a name="index-g_t_005c_005c-219"></a><a name="index-g_t_005c_005c-220"></a> <p>The easiest way to enter fragments with more than one voice on a staff is to enter each voice as a sequence (with <code>{...}</code>), and combine them simultaneously with angle brackets, <code><<...>></code>. The fragments must also be separated with double backward slashes, <code>\\</code>, to place them in separate voices. Without these, the notes would be entered into a single voice, which would usually cause errors. This technique is particularly suited to pieces of music which are largely monophonic with occasional short sections of polyphony. <p>Here's how we split the chords above into two voices and add both the passing note and a slur: <blockquote> <pre class="verbatim"> \key g \major % Voice "1" Voice "2" << { g4 fis8( g) a4 g } \\ { d4 d d d } >> | </pre> <p> <a href="../e9/lily-fc68f51d.ly"> <img align="middle" border="0" src="../e9/lily-fc68f51d.png" alt="[image of music]"> </a> </p> </blockquote> <p>Notice how the stems of the second voice now point down. <p>Here's another simple example: <blockquote> <pre class="verbatim"> \key d \minor % Voice "1" Voice "2" << { r4 g g4. a8 } \\ { d,2 d4 g } >> | << { bes4 bes c bes } \\ { g4 g g8( a) g4 } >> | << { a2. r4 } \\ { fis2. s4 } >> | </pre> <p> <a href="../7c/lily-4fcb1f1c.ly"> <img align="middle" border="0" src="../7c/lily-4fcb1f1c.png" alt="[image of music]"> </a> </p> </blockquote> <p>It is not necessary to use a separate <code><< \\ >></code> construct for each bar. For music with few notes in each bar this layout can help the legibility of the code, but if there are many notes in each bar it may be better to split out each voice separately, like this: <blockquote> <pre class="verbatim"> \key d \minor << { % Voice "1" r4 g g4. a8 | bes4 bes c bes | a2. r4 | } \\ { % Voice "2" d,2 d4 g | g4 g g8( a) g4 | fis2. s4 | } >> </pre> <p> <a href="../ef/lily-f20de748.ly"> <img align="middle" border="0" src="../ef/lily-f20de748.png" alt="[image of music]"> </a> </p> </blockquote> <p>This example has just two voices, but the same construct may be used to encode three or more voices by adding more back-slash separators. <p>The Voice contexts bear the names <code>"1"</code>, <code>"2"</code>, etc. In each of these contexts, the vertical direction of slurs, stems, ties, dynamics etc., is set appropriately. <blockquote> <pre class="verbatim"> \new Staff \relative c' { % Main voice c16 d e f % Voice "1" Voice "2" Voice "3" << { g4 f e } \\ { r8 e4 d c8 ~ } >> | << { d2 e2 } \\ { c8 b16 a b8 g ~ g2 } \\ { s4 b4 c2 } >> | } </pre> <p> <a href="../cc/lily-4454bed8.ly"> <img align="middle" border="0" src="../cc/lily-4454bed8.png" alt="[image of music]"> </a> </p> </blockquote> <p>These voices are all separate from the main voice that contains the notes just outside the <code><< .. >></code> construct. Let's call this the <em>simultaneous construct</em>. Slurs and ties may only connect notes within the same voice, so slurs and ties cannot go into or out of a simultaneous construct. Conversely, parallel voices from separate simultaneous constructs on the same staff are the same voice. Other voice-related properties also carry across simultaneous constructs. Here is the same example, with different colors and note heads for each voice. Note that changes in one voice do not affect other voices, but they do persist in the same voice later. Note also that tied notes may be split across the same voices in two constructs, shown here in the blue triangle voice. <blockquote> <pre class="verbatim"> \new Staff \relative c' { % Main voice c16 d e f << % Bar 1 { \voiceOneStyle g4 f e } \\ { \voiceTwoStyle r8 e4 d c8 ~ } >> << % Bar 2 % Voice 1 continues { d2 e2 } \\ % Voice 2 continues { c8 b16 a b8 g ~ g2 } \\ { \voiceThreeStyle s4 b4 c2 } >> } </pre> <p> <a href="../63/lily-6cfa1069.ly"> <img align="middle" border="0" src="../63/lily-6cfa1069.png" alt="[image of music]"> </a> </p> </blockquote> <p><a name="index-g_t_005cvoiceOneStyle-221"></a><a name="index-g_t_005cvoiceOneStyle-222"></a> <a name="index-g_t_005cvoiceTwoStyle-223"></a><a name="index-g_t_005cvoiceTwoStyle-224"></a> <a name="index-g_t_005cvoiceThreeStyle-225"></a><a name="index-g_t_005cvoiceThreeStyle-226"></a> <a name="index-g_t_005cvoiceFourStyle-227"></a><a name="index-g_t_005cvoiceFourStyle-228"></a> <a name="index-g_t_005cvoiceNeutralStyle-229"></a><a name="index-g_t_005cvoiceNeutralStyle-230"></a> <p>The commands <code>\voiceXXXStyle</code> are mainly intended for use in educational documents such as this one. They modify the color of the note head, the stem and the beams, and the style of the note head, so that the voices may be easily distinguished. Voice one is set to red diamonds, voice two to blue triangles, voice three to green crossed circles, and voice four (not used here) to magenta crosses; <code>\voiceNeutralStyle</code> (also not used here) reverts the style back to the default. We shall see later how commands like these may be created by the user. See <a href="Visibility-and-color-of-objects.html#Visibility-and-color-of-objects">Visibility and color of objects</a> and <a href="Using-variables-for-tweaks.html#Using-variables-for-tweaks">Using variables for tweaks</a>. <p>Polyphony does not change the relationship of notes within a <code>\relative { }</code> block. Each note is still calculated relative to the note immediately preceding it, or to the first note of the preceding chord. So in <pre class="example">\relative c' { noteA << < noteB noteC > \\ noteD >> noteE } </pre> <p class="noindent"><code>noteB</code> is relative to <code>noteA</code> <br> <code>noteC</code> is relative to <code>noteB</code>, not <code>noteA</code>; <br> <code>noteD</code> is relative to <code>noteB</code>, not <code>noteA</code> or <code>noteC</code>; <br> <code>noteE</code> is relative to <code>noteD</code>, not <code>noteA</code>. <p>An alternative way, which may be clearer if the notes in the voices are widely separated, is to place a <code>\relative</code> command at the start of each voice: <pre class="example">\relative c' { noteA ... } << \relative c'' { < noteB noteC > ... } \\ \relative g' { noteD ... } >> \relative c' { noteE ... } </pre> <p>Let us finally analyze the voices in a more complex piece of music. Here are the notes from the first two bars of the second of Chopin's Deux Nocturnes, Op 32. This example will be used at later stages in this and the next chapter to illustrate several techniques for producing notation, so please ignore for now anything in the underlying code which looks mysterious and concentrate just on the music and the voices – the complications will all be explained in later sections. <!-- The following should appear as music without code --> <blockquote> <p> <a href="../fb/lily-72bff95f.ly"> <img align="middle" border="0" src="../fb/lily-72bff95f.png" alt="[image of music]"> </a> </p> </blockquote> <p>The direction of the stems is often used to indicate the continuity of two simultaneous melodic lines. Here the stems of the highest notes are all pointing up and the stems of the lower notes are all pointing down. This is the first indication that more than one voice is required. <p>But the real need for multiple voices arises when notes which start at the same time have different durations. Look at the notes which start at beat three in the first bar. The A-flat is a dotted quarter note, the F is a quarter note and the D-flat is a half note. These cannot be written as a chord as all the notes in a chord must have the same duration. Neither can they be written as sequential notes, as they must start at the same time. This section of the bar requires three voices, and the normal practice would be to write the whole bar as three voices, as shown below, where we have used different note heads and colors for the three voices. Again, the code behind this example will be explained later, so ignore anything you do not understand. <!-- The following should appear as music without code --> <!-- The three voice styles should be defined in -init --> <blockquote> <p> <a href="../d6/lily-40900b8d.ly"> <img align="middle" border="0" src="../d6/lily-40900b8d.png" alt="[image of music]"> </a> </p> </blockquote> <p>Let us try to encode this music from scratch. As we shall see, this encounters some difficulties. We begin as we have learnt, using the <code><< \\ >></code> construct to enter the music of the first bar in three voices: <blockquote> <pre class="verbatim"> \new Staff \relative c'' { \key aes \major << { c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { <ees c>2 des2 } >> <c ees aes c>1 } </pre> <p> <a href="../16/lily-980a6f7c.ly"> <img align="middle" border="0" src="../16/lily-980a6f7c.png" alt="[image of music]"> </a> </p> </blockquote> <p><a name="index-stem-down-231"></a><a name="index-stem-up-232"></a> The stem directions are automatically assigned with the odd-numbered voices taking upward stems and the even-numbered voices downward ones. The stems for voices 1 and 2 are right, but the stems in voice 3 should go down in this particular piece of music. We can correct this simply by missing out voice three and placing the music in voice four: <blockquote> <pre class="verbatim"> \new Staff \relative c'' { \key aes \major << % Voice one { c2 aes4. bes8 } \\ % Voice two { aes2 f4 fes } \\ % Omit Voice three \\ % Voice four { <ees c>2 des2 } >> | <c ees aes c>1 | } </pre> <p> <a href="../6e/lily-6e3ceb63.ly"> <img align="middle" border="0" src="../6e/lily-6e3ceb63.png" alt="[image of music]"> </a> </p> </blockquote> <p class="noindent">We see that this fixes the stem direction, but exposes a problem sometimes encountered with multiple voices – the stems of the notes in one voice can collide with the note heads in other voices. In laying out the notes, LilyPond allows the notes or chords from two voices to occupy the same vertical note column provided the stems are in opposite directions, but the notes from the third and fourth voices are displaced, if necessary, to avoid the note heads colliding. This usually works well, but in this example the notes of the lowest voice are clearly not well placed by default. LilyPond provides several ways to adjust the horizontal placing of notes. We are not quite ready yet to see how to correct this, so we shall leave this problem until a later section — see the <code>force-hshift</code> property in <a href="Fixing-overlapping-notation.html#Fixing-overlapping-notation">Fixing overlapping notation</a>. <p class="noindent"> <h5 class="subsubheading">See also</h5> <p class="indent"> <p>Notation Reference: <a name="index-Multiple-voices-233"></a><a href="../lilypond/Multiple-voices.html#Multiple-voices">Multiple voices</a>. <!-- footer_tag --><br><hr> <div class="node"> <p> <a name="I_0027m-hearing-Voices"></a> Next: <a rel="next" accesskey="n" href="Explicitly-instantiating-voices.html#Explicitly-instantiating-voices">Explicitly instantiating voices</a>, Up: <a rel="up" accesskey="u" href="Voices-contain-music.html#Voices-contain-music">Voices contain music</a> </div> <div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;"> <p> <font size="-1"> This page is for LilyPond-2.11.57 (development-branch). <br> <address> Report errors to <a href="http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs">http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs</a>. </address> <br> Your <a href="http://lilypond.org/web/devel/participating/documentation-adding">suggestions for the documentation</a> are welcome. </font> </p> </div> <P> Other languages: <a href="I_0027m-hearing-Voices.fr.html">français</a>, <a href="I_0027m-hearing-Voices.es.html">español</a>. <BR> </P> </BODY></html>