From Fedora Project Wiki

< User:Crantila‎ | FSC

Revision as of 04:58, 30 June 2010 by Crantila (talk | contribs) (completed prose addition)

Working on a Piano Score

!! These are the subtitles that I'd like to use for all the LY case studies, if I can !!

Scenario: At a used music store, you encounter a 60-year-old, hand-engraved copy of a Schubert Impromptu, but it's been badly damaged by a flood. The store's owner says that, if you can use the score, you can keep it for free. The score is barely legible, so you decide to prepare a copy with a computer notation program.

I'm using Schubert's Impromptu Op.90 (D.899) Nr.4, in A-flat major. Published by Edition Peters: 10463, ed. Walter Niemann. We'll be setting the A section (from the beginning to the Trio).

When following this tutorial, it is recommended that the reader follows along, creating their replica of this tutorial's PDF.

Starting the Score

  1. Open Frescobaldi with a new document.
  2. Start the "Setup New Score" tool, by clicking 'LilyPond > Setup New Score' in the menu.
  3. Fill in the following fields on the "Titles and Headers" tab:
    • Title: Impromptu
    • Compuser: Schubert, Franz
    • Opus: Opus 90/4
  4. Switch to the "Parts" tab:
    1. From the "Available parts" list, select "Keyboard instruments"
    2. Select "Piano"
    3. Click "Add"
    4. On the right-hand side of the window, it's possible to add multiple voices from the start. We won't be using this feature, because most of the score is not polyphonic. It is especially convenient in fugues.
  5. Switch to the "Score settings" tab, and adjust the following settings:
    • Key signature: As Major
    • Time signature: 3/4
    • Tempo indication: Allegretto
    • Remove default tagline: checked
    • Adjust other settings as desired - it is recommended to keep the default pitch name language.

Adjusting Frescobaldi's Output

These steps are useful in establishing a consistent input style for LilyPond. The things suggested here are also useful for getting used to working with large scores, which can be a challenge in any text editor. Thankfully, careful (and consistent!) code organization goes a long way in helping you to quickly find your way around your files. Setting up files the right way to begin with makes this much easier in the end.

When you first setup the score, Frescobaldi will have created many sections for you by default. The program avoids making too many stylistic choices for you, which allows you to create your own style. It also sets up the default sections in a logical way:

version
header
widely-used settings like tempoMark and "global"
individual parts
score formatting

The specific ordering will become more obvious to you as you get used to LilyPond.

Here are some of the things that I do before inputting notes:

  • Use section-dividers (like %%%%%%%% NOTES %%%%%%%% for individual parts) to demarcate sections.
  • Use different levels of dividers (like %%%% RIGHT HAND %%%% for the right hand) to show sub-sections
  • Add blank lines between large sections, to separate them more obviously
  • Begin braces on new lines (as
    \header
    {
      title = "Impromptu"
      ...
    }
    instead of on the same line (as
    \header {
    
     title = "Impromptu"
     ...
    
    }
    This is simply a matter of personal taste, resulting from prior experience with C and C-like programming languages.
  • Familiarize myself with the sections and commands created by Frescobaldi, getting a sense of what the section/command does (even if I don't understand what each specific command does). This makes it easier to sort out problems and customization down the road. Sometimes, when the setup is quite complex, I make comments about what seems to be going on.
  • At this point, I also added the "Dynamics Context" commands, as described below in the "Piano Dynamics" section

Inputting

Piano scores present some unique challenges with LilyPond, but they're easy to overcome with some careful thought. This tutorial will avoid step-by-step instructions on how to input particular notes, instead focussing on those unique piano challenges presented in this particular composition. The LilyPond "Notation Reference" provides a section dedicated to keyboard and piano music. Most of the situations described there are not present or discussed in this score, which gives this tutorial unique material.

Order of Inputting

Choosing the right order to input your scores can make things much easier to troubleshoot. Here are some suggestions:

  1. Input music in small sections at a time. Two, four, or eight measures is usually a good size, but it depends on the size of the composition, the size of its sections, and the form of the music. It doesn't make sense to input a passage of 9 whole-notes in stages of two measures, but two measures may be too long for passages composed primarily of 128th-notes.
  2. Input one staff at a time, then check its accuracy using Frescobaldi's preview function (press the "LilyPond" button on the toolbar)
    • Input the pitch and rhythms first, then slurs, articulations, ties, and fingerings. It's easier to correct errors with pitch and rhythm (and register!) before the extra markings are added.
    • To help make sixteenth-note passages easier to read, you can use double- or triple-spaces to separate beats. Such passages often feature repeated patterns; before copy-and-pasting, make sure that the pattern repetition is truly exact!
  3. When you progress to a new four-measure section (or two- or six-, etc.), input the less difficult staff first (if there is one). This way, you will have a better visual reference when verifying the more difficult part. It's easier to see differences if your score looks closer to the original.
  4. The same idea applies for multi-measure polyphonic passages in the same staff: input the easier part first, so you have a visual reference.
  5. To help ensure that you don't get lost, write measure numbers in the source file every five measures or so. See the example source file to see how this is done. Even if you don't want to have measure numbers in the final score, it can be helpful to include them during inputting and error-checking.
  6. Save the dynamics and pedal markings for last! Sometimes, they can help you to keep your place in the score while double-checking that it's correct, but I don't usually put them in with the rest of the notes, for reasons described below in the "Piano Dynamics" section.

Most importantly, remember that these are just suggestions! The order in which you do things should change depending on what suits you best. Different kinds of scores will require different strategies.

Chords

There are two ways to input chords, but one will be used much more often.

This style of chord notation is more common: <as ces>4-_ Notice how only the pitches are notated inside the < > brackets, and everything else attached to the end. There is one exception to this: fingering should be indicated on the pitch associated with that finger: <as-1 ces-3>4-_ Not only does this help you to sort out what was probably intended, but it allows LilyPond to stack the fingering in the right order. When using "relative" entry mode, it is the lowest note of the chord that is taken into consideration when placing the next note.

This style of chord notation is less common: <<as4-> ces>> Notice how everything must be notated inside the << >> brackets. This can make it more difficult to read the chord in the source file, but it also allows much greater flexibility: only some chord members can have ties; certain chord members can last for longer than others; certain chord members can "break out" into or out of polyphonic passages. This notation is rarely needed, but you may be inclined to over-use it if you are trying to exactly copy the look of a hand-engraved score. Like the "times" command for tuplets, this is one of LilyPond's deceptively powerful techniques. When using "relative" entry mode, it is the last note of the chord that is taken into consideration when placing the next note.

Fingering

LilyPond allows you to indicate fingering by attaching the digit number to a note as an articulation mark: a16-5 will show a "5" as a fingering mark. As with all other articulation marks indicated in this way, you can use ^ or _ to instruct LilyPond to put the mark above or below the note, respectively. It is usually better to let LilyPond decide for itself by using a -.

When entering chords, it is recommended that you enter the fingering with the note to which it is attached, like <as-1 ces-4>4-_. It is possible to enter this as <as ces>4-1-4->, but this not only looks confusing, it may confuse LilyPond as to which digit is intended for which note.

Because the extra digits look like they indicate note-lengths, it is recommended to mark them consistently. For this same reason, it is also recommended that fingering marks be added to source files only after the pitch and rhythm have been double-checked. The source file included with this tutorial puts fingering marks after any other articulation and length marking.

Cautionary Accidentals

Musical Definition:

This score makes some use of cautionary accidentals. These are accidentals which don't change the pitches to be played, but rather are used as a precaution against forgetting that they are there. This usually happens when an accidental in the written key signature is changed for a significant number of measures, and then suddenly changes back. The cautionary accidental would be applied when the standard key signature returns, to remind the musician of the key signature.

LilyPond Notation: These are notated in LilyPond with an exclamation mark placed before the note-value: ces!16

Changing the Style of Crescendo

Sometimes the composer or editor prefers to use the words "crescendo" or its abbreviation, "cresc.", instead of the angled-line < style of crescendo. In LilyPond these are handled by the same source-file notation (\< to start and \! to end explicitly). However, if you want to use text and a "spanner" (dotted or dashed line, for example) instead of the < sign, you need to tell LilyPond. This can be accomplished with the following command: \crescTextCresc.

After changing to this style of crescendo, you can revert to the standard < style with the following command: \crescHairpin.

The \dimTextDim and \dimHairpin commands do the same for a diminuendo.

Polyphonic Sections in Homophonic Music

Sometimes, especially in piano music, a passage of some measures will require polyphonic (multi-Voice) notation in LilyPond, even though most of the music does not. In this case, you would use the following format:

<<
  {
    % upper voice notes go here
  } \\
  {
    % lower voice notes go here
  }
>>

This is used a few times in both hands in the example score file.

When writing these sections in "relative" entry mode, it is a good idea to use the "octave-check" mechanism, at least at the beginning of the lower voice. This is because, when judging the relative starting pitch of the first note of the lower voice, LilyPond judges from the last note of the upper voice - not the last note before the polyphonic section began.

Octave-Change Spanners ("8ve" Signs, "Ottava Brackets")

Musical Definition:

In order to most conveniently notate over large ranges, composers and editors sometimes use text spanners to indicate that a passage should be played one or two octaves higher or lower than written. This allows the notes to stay mostly within the staff lines, thereby decreasing the number of ledger lines required.

LilyPond Notation:

The \ottava command is used to notate all five states of transposition:

  • 15va (play two octaves higher than written) is engaged with \ottava #2
  • 8va (play one octave higher than written) is engaged with \ottava #1
  • loco (play in the octave written) is engaged with \ottava #0, which also cancels another sign.
  • 8vb (play one octave lower than written) is engaged with \ottava #-1
  • 15vb (play two octaves lower than written) is engaged with \ottava #-2

Troubleshooting Errors

It can be difficult to troubleshoot inputting errors, especially when you find them days or weeks after originally inputting that section of a score. The best way to fix errors is to input scores in a way that doesn't allow them in the first place. As they say, "an ounce of prevention is worth a pound of cure," which means "if you input your LilyPond files carefully, then you will encounter fewer problems." Such practices as proper spacing, and regular use of the octave- and bar-check features will deal with many common problems.

However, when searching for an error in your score, Frescobaldi does offer some features to help you find it:

  • If you have written something in the text-input window that is obviously incorrect, then Frescobaldi will sometimes catch your mistake and underline and highlight the erroneous code in red. This is most useful for catching typographical errors ("typos").
  • If LilyPond encounters a processing error, it will show up in the "LilyPond Log" window below the text-input window. You can click on the blue, underlined text to move the text-selection caret to the error.
  • If you can see an error in the PDF preview, but you can't find it in the source file, you can click on the problematic note or object in the PDF preview, and Frescobaldi will automatically move the text-selection caret to that object.

Piano Dynamics

Keyboard instruments use a unique notation when it comes to dynamics. Most instruments use only one staff per player, so the dynamics are, by convention, notated underneath that staff. Keyboard instruments usually use two staves (organs and complex piano music may use three). Because the dynamics are usually meant to apply to both staves, they are usually notated between the two staves. This is similar to notation beneath the upper staff, but in truth, piano dynamics tend to be placed in the middle between the staves - entering the dynamics as belonging to the upper staff, in LilyPond, will not produce that effect.

There is a way to notate dynamics between two staves in LilyPond, and it involves a little bit of thought to get it right. It also requires the addition of a significant number of commands, and the creation of a new context.

This process looks difficult, and may seem daunting. It's not necessary to understand all of the commands in the "PianoDynamics" Context in order to use the context, so there is no need to worry!

Preparing the "PianoDynamics" Context

It is probably easier to add these commands before inputting most of the score, but there is no reason why this context cannot be added to any score at any time.

Follow these steps to create a "PianoDynamics" Context:

  1. Between the left and right staves of the PianoStaff, add "\new PianoDynamics = "dynamics" \dynamics". For the Schubert score, this looks like:
      \new PianoStaff \with
        {
          instrumentName = "Piano"
        }
      <<
        \new Staff = "right" \right
        \new PianoDynamics = "dynamics" \dynamics
        \new Staff = "left" { \clef bass \left }
      >>
  2. To the layout section, add the following:
    % Everything below here is for the piano dynamics.
        % Define "PianoDynamics" context.
        \context 
        {
          \type "Engraver_group"
          \name PianoDynamics
          \alias Voice
          \consists "Output_property_engraver"
          \consists "Script_engraver"
          \consists "New_dynamic_engraver"
          \consists "Dynamic_align_engraver"
          \consists "Text_engraver"
          \consists "Skip_event_swallow_translator"
          \consists "Axis_group_engraver"
          
          \override DynamicLineSpanner #'Y-offset = #0
          \override TextScript #'font-size = #2
          \override TextScript #'font-shape = #'italic
          \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
        }
        
        % Modify "PianoStaff" context to accept Dynamics context.
        \context
        {
          \PianoStaff
          \accepts PianoDynamics
        }
        % End of PianoDynamics code.
    This creates a "PianoDynamics" context, and modifies the "PianoStaff" context so that it will accept a "PianoDynamics" context.
  3. Before the "\score" section, add a section called "dynamics," like this:
    dynamics =
    {
      % Dynamics go here.
      
    }
    This is where you will input the dynamics.

Inputting the Dynamics

Now you can input the dynamic markings. These are inputted with a special note called a "spacer," that uses the letter "s" rather than a note name. You can also use rests (both partial- and multi-measure, r and R), but dynamic markings cannot be assigned to them.

For example, if you want a piano marking on the first beat, and a diminuendo from the third to the fourth beat, you could write this: s4\p r s\> s\!, or this: s2\p s4\> s\!

That's all there is to it! Think of the dynamics part as an invisible, pitch-free line between the two staves, for the sole purpose of dynamics (and other expression markings).