<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- header_tag --> <html lang="en"> <head> <title>Building a score from scratch - 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.de.html#Top"> <link rel="up" href="Extending-the-templates.de.html#Extending-the-templates" title="Extending the templates"> <link rel="prev" href="Four_002dpart-SATB-vocal-score.de.html#Four_002dpart-SATB-vocal-score" title="Four-part SATB vocal score"> <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="Building-a-score-from-scratch"></a> Previous: <a rel="previous" accesskey="p" href="Four_002dpart-SATB-vocal-score.de.html#Four_002dpart-SATB-vocal-score">Four-part SATB vocal score</a>, Up: <a rel="up" accesskey="u" href="Extending-the-templates.de.html#Extending-the-templates">Extending the templates</a> <hr> </div> <h4 class="subsection">3.4.3 Building a score from scratch</h4> <p><a name="index-template_002c-writing-your-own-326"></a> After gaining some facility with writing LilyPond code, you may find that it is easier to build a score from scratch rather than modifying one of the templates. You can also develop your own style this way to suit the sort of music you like. Let's see how to put together the score for an organ prelude as an example. <p>We begin with a header section. Here go the title, name of composer, etc, then come any variable definitions, and finally the score block. Let's start with these in outline and fill in the details later. <p>We'll use the first two bars of Bach's prelude based on <em>Jesu, meine Freude</em> which is written for two manuals and pedal organ. You can see these two bars of music at the bottom of this section. The top manual part has two voices, the lower and pedal organ one each. So we need four music definitions and one to define the time signature and key: <pre class="example">\version "2.11.57"<!-- /@w --> \header { title = "Jesu, meine Freude" composer = "J S Bach" } TimeKey = { \time 4/4 \key c \minor } ManualOneVoiceOneMusic = {s1} ManualOneVoiceTwoMusic = {s1} ManualTwoMusic = {s1} PedalOrganMusic = {s1} \score { } </pre> <p>For now we've just used a spacer note, <code>s1</code>, instead of the real music. We'll add that later. <p>Next let's see what should go in the score block. We simply mirror the staff structure we want. Organ music is usually written on three staves, one for each manual and one for the pedals. The manual staves should be bracketed together, so we need to use a PianoStaff for them. The first manual part needs two voices and the second manual part just one. <pre class="example"> \new PianoStaff << \new Staff = "ManualOne" << \new Voice { \ManualOneVoiceOneMusic } \new Voice { \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context </pre> <p>Next we need to add a staff for the pedal organ. This goes underneath the PianoStaff, but it must be simultaneous with it, so we need angle brackets around the two. Missing these out would generate an error in the log file. It's a common mistake which you'll make sooner or later! Try copying the final example at the end of this section, remove these angle brackets, and compile it to see what errors it generates. <pre class="example"><< % PianoStaff and Pedal Staff must be simultaneous \new PianoStaff << \new Staff = "ManualOne" << \new Voice { \ManualOneVoiceOneMusic } \new Voice { \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context \new Staff = "PedalOrgan" << \new Voice { \PedalOrganMusic } >> >> </pre> <p>It is not necessary to use the simultaneous construct <code><< .. >></code> for the manual two staff and the pedal organ staff, since they contain only one music expression, but it does no harm, and always using angle brackets after <code>\new Staff</code> is a good habit to cultivate in case there are multiple voices. The opposite is true for Voices: these should habitually be followed by braces <code>{ .. }</code> in case your music is coded in several variables which need to run consecutively. <p>Let's add this structure to the score block, and adjust the indenting. We also add the appropriate clefs, ensure stems, ties and slurs in each voice on the upper staff point to the right direction with <code>\voiceOne</code> and <code>\voiceTwo</code>, and enter the time signature and key to each staff using our predefined variable, <code>\TimeKey</code>. <pre class="example">\score { << % PianoStaff and Pedal Staff must be simultaneous \new PianoStaff << \new Staff = "ManualOne" << \TimeKey % set time signature and key \clef "treble" \new Voice { \voiceOne \ManualOneVoiceOneMusic } \new Voice { \voiceTwo \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \TimeKey \clef "bass" \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context \new Staff = "PedalOrgan" << \TimeKey \clef "bass" \new Voice { \PedalOrganMusic } >> % end PedalOrgan Staff >> } % end Score context </pre> <p>That completes the structure. Any three-staff organ music will have a similar structure, although the number of voices may vary. All that remains now is to add the music, and combine all the parts together. <blockquote> <pre class="example"> \version "2.11.57"<!-- /@w --> </pre> <pre class="verbatim"> \header { title = "Jesu, meine Freude" composer = "J S Bach" } TimeKey = { \time 4/4 \key c \minor } ManualOneVoiceOneMusic = \relative g' { g4 g f ees | d2 c2 | } ManualOneVoiceTwoMusic = \relative c' { ees16 d ees8~ ees16 f ees d c8 d~ d c~ | c c4 b8 c8. g16 c b c d | } ManualTwoMusic = \relative c' { c16 b c8~ c16 b c g a8 g~ g16 g aes ees | f ees f d g aes g f ees d e8~ ees16 f ees d | } PedalOrganMusic = \relative c { r8 c16 d ees d ees8~ ees16 a, b g c b c8 | r16 g ees f g f g8 c,2 | } \score { << % PianoStaff and Pedal Staff must be simultaneous \new PianoStaff << \new Staff = "ManualOne" << \TimeKey % set time signature and key \clef "treble" \new Voice { \voiceOne \ManualOneVoiceOneMusic } \new Voice { \voiceTwo \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \TimeKey \clef "bass" \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context \new Staff = "PedalOrgan" << \TimeKey \clef "bass" \new Voice { \PedalOrganMusic } >> % end PedalOrgan Staff context >> } % end Score context </pre> <p> <a href="../e8/lily-21503415.ly"> <img align="middle" border="0" src="../e8/lily-21503415.png" alt="[image of music]"> </a> </p> </blockquote> <!-- *- coding: utf-8; mode: texinfo; -*- --> <!-- This file is part of lilypond-learning.tely --> <!-- \version "2.11.51" --> <!-- footer_tag --><br><hr> <div class="node"> <p> Previous: <a rel="previous" accesskey="p" href="Four_002dpart-SATB-vocal-score.de.html#Four_002dpart-SATB-vocal-score">Four-part SATB vocal score</a>, Up: <a rel="up" accesskey="u" href="Extending-the-templates.de.html#Extending-the-templates">Extending the templates</a> </div> <div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;"> <p> <font size="-1"> Diese Seite ist für LilyPond-2.11.57 (Entwicklungszweig). <br> <address> Fehler bitte an <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> melden. </address> <br> Ihre <a href="http://lilypond.org/web/devel/participating/documentation-adding">Vorschläge für die Dokumentation</a> sind willkommen. </font> </p> </div> <P> Andere Sprachen: <a href="Building-a-score-from-scratch.fr.html">français</a>, <a href="Building-a-score-from-scratch.es.html">español</a>. <BR> </P> </BODY></html>