David Kastrup <d...@gnu.org> writes:

> Werner LEMBERG <w...@gnu.org> writes:
>
>>> Inspired by
>>> <https://music.stackexchange.com/questions/132340/lilypond-different-clefs-for-each-voice-on-one-staff>
>>> 
>>> Should we be offering something like that?
>>
>> What exactly do you mean with 'offering'?
>
> Provide it as core functionality called with dedicated commands.
>
>> Having this functionality is certainly useful for Piano music.
>> However, it's quite rare, and an LSR snippet should be sufficient
>> (possibly integrated into LilyPond's documentation).
>
> I see that you have shown an example that repeats the clef for every
> measure.  If that's the convention, the approach in my code is not
> likely helpful.

Correction: it is easy to make it do that.

\version "2.24.2"
\language "italiano"

\header {
  tagline = ##f
}

\layout {
  \context {
    \Staff
    \accepts PseudoClefStaff
  }
  \context {
    \name PseudoClefStaff
    \type Engraver_group
    \alias Staff
    \accepts Voice
    \consists Clef_engraver
    \override Clef.font-size = #-4
    \override Clef.break-align-symbol = #'cue-clef
    \override Clef.break-visibility = #end-of-line-invisible
  }
}

\midi {
  \context {
    \Staff
    \accepts PseudoClefStaff
  }
  \context {
    \name PseudoClefStaff
    \type Performer_group
    \alias Staff
    \accepts Voice
  }
}

pseudoClef =
#(define-music-function (offset clef-type) ((number?) string?)
  #{ \new PseudoClefStaff = "pseudo" \with { firstClef = ##f } { }
     \change Staff = "pseudo"
     #(if offset #{ \override Staff.Clef.Y-offset = #offset #})
     \clef #clef-type
   #})

% Any ideas for an automated endPseudoClef?

\score {
    \new Staff = "lower" {
        \key re \minor
        \numericTimeSignature
        \time 3/4
        \clef bass
        \relative do' {
          \voices 1,""
            <<
                {
                    s2. r4 r8. \clef treble
                    \tuplet 3/2 16 { sol'32 (la sib }
                    do8.) do16--
                    do16-- sib sol la
                    sol8. 
                    \omit TupletBracket
                    \tuplet 3/2 16 { fa32 (sol la }
                    sib8.) sib16
                  } \\
                {
                  re,,,8.-- re16-- re2--~ 2.~
                  \pseudoClef #-3 "bass"
                  \voiceTwo
                  2.~ \break 2.~2.
                  \oneVoice
                  \change Staff = "lower" % change back to standard staff
                }
            >>
        }
    }
}

-- 
David Kastrup

Reply via email to