Hello,

I have recently found a way of having notes change context into a different 
voice. This might be useful when you want to do things like condensing three 
voices into two voices in a piano score. This is basically done by adding a 
Notes-Context to the Voice-Context, which allows us the change the voice.

In the appended file there is a chorale condensed to a piano score using this 
way. Note how in measure 5 the alto voice switches to the tenor voice.

This might matter, because it allows us to differentiate stronger what the 
actual music is versus how it is notated, i.e. we can differentiate between 
lilyponds notated voices and the voices that are actually in the music.

I hope some of you can profit from this, and if you like you can also put this 
on LSR. I’m apparently far to stupid to do this, I cannot even properly 
register a user.

Regards,
Valentin
\version "2.20.0"

\layout {
  \context {
    \Voice
    \accepts "Notes"
  }
  \context {
    \TabVoice
    \accepts "Notes"
  }
  \context {
    \name "Notes"
    \type "Engraver_group"
  }
}

global = {
  \time 3/4 \key g\major \tempo 4=72
}

vOne = \relative g' {
  \repeat volta #2 {
    g4 g d' | b4. a8 g4 |
    fis e d | e fis g |  a2. | g
  }
  d'4 d d | e2. | b4 c d | d4. c8 b4 | a2. |
  d,4 e fis | g a b | a2. | g
}

vTwo =  \new Notes \relative d' {
  \repeat volta #2 {
    d4 e a | g fis e | d c b |
    c c b | 
    \tag #'piano { \change Voice = "topA" }
    d2.
    b
  }
  \tag #'piano { \change Voice = "topB" }
  b'4 a b c2. | g4 g a |
  g g g | fis2. |
  g,4
  \tag #'nonvoice c2
  \tag #'voice {c4 c} |
  b4 fis' g-\tag #'nonvoice ~|
  g2-\tag #'voice ( fis4-\tag #'voice) | g2.
}

vThree = \new Notes \relative b {
  \repeat volta #2 {
    b4 b d | d d b |
    b g g | g a g |
    g2(  fis4) | g2.
  }
  g'4 d g | g2. |
  d4 c fis | d e d | d2. |
  \tag #'piano {
    \change Voice = "bottomA"
    \voiceOne
  }
  \tag #'nonvoice g,2 \tag #'voice { g4 g }
  a4 | g 
  \tag #'nonvoice {d'2~ } \tag #'voice {d4 d4}
  | 2. | b
}

bass = \relative g {
  \repeat volta #2 {
    g4 e fis | g d e | b c g |
    c a e' | d2. | g,
  }
  g'4 fis g | c,2. | g'4 e d |
  b c g | d'2. |
  \tag #'piano { \voiceTwo }
  b4 c a | e' d g | d2. | g,
  \bar "|."
}

lyrA = \lyricmode {
  \set stanza = "1."
  Lo -- be den Her -- ren, den mäch -- ti -- gen Kö -- nig der Eh -- ren,
}

lyrB = \lyricmode {
  mei -- ne ge -- lie -- be -- te See -- le, das iſt mein Be -- geh -- ren;
  
  kom -- met zu -- hauf, Pſal -- ter und Har -- fe, wacht auf,
  laſ -- ſet den Lob -- ge -- ſang hö -- ren.
}

keepAliveWhile=#(define-music-function (m) (ly:music?)
                  (let* ((mlen (moment->fraction (ly:music-length m))))
                    (make-music
                      'SkipEvent
                      'duration
                      (ly:make-duration 0 0 (car mlen) (cdr mlen)))))


\score {
  \header {
    piece = "1. Lobe den Herren, den mächtigen König"
    poet  = "Joachim Neander"
  }
  <<
    \new ChoirStaff <<
      \new Staff << \new Voice = "psop" {\voiceOne \global \clef "treble" \removeWithTag #'(piano nonvoice) \vOne }
                    \new Voice {\voiceTwo \global \clef "treble" \removeWithTag #'(piano nonvoice) \vTwo }
      >>
      \new Lyrics \with {\override VerticalAxisGroup.staff-affinity = #CENTER } \lyricsto "psop" \lyrA \new Lyrics \with {\override VerticalAxisGroup.staff-affinity = #CENTER } \lyricsto "psop" \lyrB
      \new Staff << { \global \clef "bass" \removeWithTag #'(piano nonvoice) \vThree } \\
                    { \global \clef "bass" \removeWithTag #'(piano nonvoice) \bass }
      >>
    >>
    \new PianoStaff <<
      \new Staff {
        \global
        <<
          \new Voice = "topA" {
            \voiceOne
            \removeWithTag #'(voice) \vOne
          }
          \new Voice = "topB" {
            \voiceTwo
            << \removeWithTag #'(voice) \vTwo \removeWithTag #'(voice) \vThree >>
          }
        >>
      }
      \new Staff {
        \clef "bass" \global
        <<
          \new Voice = "bottomA" { \keepAliveWhile \bass }
          \new Voice = "bottomB" {
            \removeWithTag #'(voice) \bass
          }
        >>
      }
    >>
  >>
  \layout { }
}

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to