LilyPond snippets: Simultaneous notes

# Simultaneous notes

Simultaneous notes

## Zusätzliche Stimmen, um Zusammenstöße zu vermeiden

Ein einigen Fällen von sehr komplexer polyphoner Musik sind zusätzliche Stimmen notwendig, um Zusammenstöße zwischen den Noten zu vermeiden. Wenn mehr als vier parallele Stimmen benötigt werden, können zusätzliche Stimmen definiert werden, indem eine Variable mit der Funktion `context-spec-music` definiert wird.

    voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)

    \relative c'' {
      \time 3/4
      \key d \minor
      \partial 2
      <<
        \new Voice  {
          \voiceOne
          a4. a8
          e'4 e4. e8
          f4 d4. c8
        }
        \new Voice {
          \voiceTwo
          d,2
          d4 cis2
          d4 bes2
        }
        \new Voice {
          \voiceThree
          f'2
          bes4 a2
          a4 s2
        }
        \new Voice {
          \voiceFive
          s2
          g4 g2
          f4 f2
        }
      >>
    }

## Changing a single note’s size in a chord

Individual note heads in a chord can be modified with the `\tweak` command inside a chord, by altering the `font-size` property.

Inside the chord (within the brackets `< >`), before the note to be altered, place the `\tweak` command, followed by `font-size` and define the proper size like `#-2` (a tiny note head).

    \relative c' {
      <\tweak font-size #+2 c e g c
       \tweak font-size #-2 e>1
       ^\markup { A tiny e }_\markup { A big c }
    }

## PartCombine-Text ändern

Wenn Stimmen automatisch kombiniert werden, kann der Text, der für Solo- und Unisono-Stellen ausgegeben wird, geändert werden:

    \new Staff <<
      \set Staff.soloText = #"girl"
      \set Staff.soloIIText = #"boy"
      \set Staff.aDueText = #"together"
      \partCombine
        \relative c'' {
          g4 g r r
          a2 g
        }
        \relative c'' {
          r4 r a( b)
          a2 g
        }
    >>

## Clusters

Clusters are a device to denote that a complete range of notes is to be played.

    fragment = \relative c' {
      c4 f <e d'>4
      <g a>8 <e a> a4 c2 <d b>4
      e2 c
    }

    <<
      \new Staff \fragment
      \new Staff \makeClusters \fragment
    >>

## Zwei Stimmen auf einem System kombinieren

Die Funktion, die Stimmen kombiniert (also der `\partCombine`-Befehl) ermöglicht die Kombination unterschiedlicher Stimmen auf einem System. Textanweisungen wie "solo" oder "a2" werden automatisch hinzugefügt. Wenn man sie entfernen will, muss man die Eigenschaft `printPartCombineTexts` auf falsch setzen. Für Klavierauszüge muss natürlich kein "solo"/"a2" usw. hinzugefügt werden, man sollte sie also ausschalten. Wenn aber Solo-Stellen in einem Klavierauszug oder einer Chorpartitur angezeigt werden, ist es besser, normale Polyphonie zu verwenden, weil so die Solostellen angezeigt werden, auch wenn der Text des Stimmenkombinierers ausgeschaltet ist.

Der Schnipsel zeigt drei Möglichkeiten, Stimmen auf einem System zu kombinieren: Standardpolyphonie, `\partCombine` ohne Text und `\partCombine` mit Text.

    %% Combining pedal notes with clef changes

    musicUp = \relative c'' {
      \time 4/4
      a4 c4.( g8) a4 |
      g4 e' g,( a8 b) |
      c b a2.
    }

    musicDown = \relative c'' {
      g4 e4.( d8) c4 |
      r2 g'4( f8 e) |
      d2 \stemDown a
    }

    \score {
        <<
        \new Staff \with { instrumentName = "Standard polyphony" }

          << \musicUp \\ \musicDown >>

        \new Staff \with {
          instrumentName = "PartCombine without text"
          printPartCombineTexts = ##f
        }

        \partCombine \musicUp \musicDown

        \new Staff \with { instrumentName = "PartCombine with text" }
          \partCombine \musicUp \musicDown
        >>
      \layout {
        indent = 6.0\cm
        \context {
          \Score
          \override SystemStartBar.collapse-height = #30
        }
      }
    }

## Displaying complex chords

Here is a way to display a chord where the same note is played twice with different accidentals.

    fixA = {
      \once \override Stem.length = #11
    }

    fixB = {
      \once \override NoteHead.X-offset = #1.7
      \once \override Stem.length = #7
      \once \override Stem.rotation = #'(45 0 0)
      \once \override Stem.extra-offset = #'(-0.1 . -0.2)
      \once \override Flag.style = #'no-flag
      \once \override Accidental.extra-offset = #'(4 . -.1)
    }

    \relative c' {
      << { \fixA <b d!>8 } \\ { \voiceThree \fixB dis } >> s
    }

## Horizontale Verschiebung von Noten erzwingen

Wenn es zu Zusammenstößen kommt, kann mit folgender Lösung eine andere Position manuell eingestellt werden. Die Einheiten hier sind Notenlinienzwischenräume.

    \relative c' <<
      {
        <d g>2 <d g>
      }
      \\
      {
        <b f'>2
        \once \override NoteColumn.force-hshift = #1.7
        <b f'>2
      }
    >>

## Making an object invisible with the ’transparent property

Setting the `transparent` property will cause an object to be printed in „invisible ink“: the object is not printed, but all its other behavior is retained. The object still takes up space, it takes part in collisions, and slurs, ties and beams can be attached to it.

This snippet demonstrates how to connect different voices using ties. Normally, ties only connect two notes in the same voice. By introducing a tie in a different voice, and blanking the first up-stem in that voice, the tie appears to cross voices.

    \relative {
      \time 2/4
      <<
        {
          \once \hide Stem
          \once \override Stem.length = #8
          b'8 ~ 8\noBeam
          \once \hide Stem
          \once \override Stem.length = #8
          g8 ~ 8\noBeam
        }
        \\
        {
          b8 g g e
        }
      >>
    }

## Moving dotted notes in polyphony

When a dotted note in the upper voice is moved to avoid a collision with a note in another voice, the default is to move the upper note to the right. This behaviour can be over-ridden by using the `prefer-dotted-right` property of `NoteCollision`.

    \new Staff \relative c' <<
      {
        f2. f4
        \override Staff.NoteCollision.prefer-dotted-right = ##f
        f2. f4
        \override Staff.NoteCollision.prefer-dotted-right = ##t
        f2. f4
      }
      \\
      { e4 e e e e e e e e e e e }
    >>

## Suppressing warnings for clashing note columns

If notes from two voices with stems in the same direction are placed at the same position, and both voices have no shift or the same shift specified, the error message ‘`warning: ignoring too many clashing note columns`’ will appear when compiling the LilyPond file. This message can be suppressed by setting the `'ignore-collision` property of the `NoteColumn` object to `#t`. Please note that this does not just suppress warnings but stops LilyPond trying to resolve collisions at all and so may have unintended results unless used with care.

    ignore = \override NoteColumn.ignore-collision = ##t

    \relative c' {
      \new Staff <<
        \new Voice { \ignore \stemDown f2 g }
        \new Voice { c2 \stemDown c, }
      >>
    }

## Two \partCombine pairs on one staff

The `\partCombine` function takes two music expressions each containing a part, and distributes them among four `Voice`s named „two“ „one“ „solo“ and „chords“ depending on when and how the parts merged into a common voice. The voices output from `\partCombine` can have their layout properties adjusted in the usual way. Here we define extensions of `\partCombine` to make it easier to put four voices on a staff.

    soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
    alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
    tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
    bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

    \new Staff <<
      \key b\minor
      \clef alto
      \partial 4
      \transpose b b'
      \partCombineUp \soprano \alto
      \partCombineDown \tenor \bass
    >>

    \layout {
      \context {
        \Staff
        \accepts "VoiceBox"
      }
      \context {
        \name "VoiceBox"
        \type "Engraver_group"
        \defaultchild "Voice"
        \accepts "Voice"
        \accepts "NullVoice"
      }
    }

    customPartCombineUp =
    #(define-music-function (partOne partTwo)
      (ly:music? ly:music?)
    "Take the music in @var{partOne} and @var{partTwo} and return
    a @code{VoiceBox} named @q{Up} containing @code{Voice}s
    that contain @var{partOne} and @var{partTwo} merged into one
    voice where feasible.  This variant sets the default voicing
    in the output to use upward stems."
    #{
      \new VoiceBox = "Up" <<
        \context Voice = "one" { \voiceOne }
        \context Voice = "two" { \voiceThree }
        \context Voice = "shared" { \voiceOne }
        \context Voice = "solo" { \voiceOne }
        \context NullVoice = "null" {}
        \partCombine #partOne #partTwo
      >>
    #})

    customPartCombineDown = #
    (define-music-function (partOne partTwo)
      (ly:music? ly:music?)
    "Take the music in @var{partOne} and @var{partTwo} and return
    a @code{VoiceBox} named @q{Down} containing @code{Voice}s
    that contain @var{partOne} and @var{partTwo} merged into one
    voice where feasible.  This variant sets the default voicing
    in the output to use downward stems."
    #{
      \new VoiceBox = "Down" <<
        \set VoiceBox.soloText = #"Solo III"
        \set VoiceBox.soloIIText = #"Solo IV"
        \context Voice ="one" { \voiceFour }
        \context Voice ="two" { \voiceTwo }
        \context Voice ="shared" { \voiceFour }
        \context Voice ="solo" { \voiceFour }
        \context NullVoice = "null" {}
        \partCombine #partOne #partTwo
      >>
    #})

    soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
    alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
    tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
    bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

    \new Staff <<
      \key b\minor
      \clef alto
      \partial 4
      \transpose b b'
      \customPartCombineUp \soprano \alto
      \customPartCombineDown \tenor \bass
    >>

#### LilyPond – Snippets v2.22.2 (stabiler Zweig).