lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easiest way to call one voice (for parts)?


From: Torsten Hämmerle
Subject: Re: Easiest way to call one voice (for parts)?
Date: Thu, 12 Jul 2018 05:03:26 -0700 (MST)

SoundsFromSound wrote
> With that in mind, can you show me below how I could make use of the tag 
> I attempted to test and get the red color to function correctly in the 
> score?
> Is that what you mean, or use tags differently than I did here?


No, what I meant is much simpler, i.e. needing minimum effort by
automatically replacing 
    \voiceOne by \tag rem \voiceOne
and
    \voiceTwo by \tag rem \voiceTwo

This can be done automatically by using search & replace functionality in
any editor.

All you need to do then is to use \removeWithTag rem to remove all these
\voiceOne and \voiceTwo commands from the original combined part definition
\flutes.


Then we don't need to filter out all the 'OverrideProperty and 'SetProperty
events and you manual \overrides will remain in action:


%%%%%%%%%%
\version "2.19.81"

#(define (keep-voice voicename)
   "Keep voice voicename and () and remove OverrideProperty events"
   (if (string? voicename)
       (lambda (m)
         (let* ((eventname (ly:music-property m 'name))
                (contextid (ly:music-property m 'context-id "")))
           (or (string=? contextid voicename)
               (string=? contextid ""))
           ))))

keepVoice =
#(define-music-function (voicename music)
   (string? ly:music?)
   (_i "Keep elements of @var{music} that belong to voice @var{voicenam}
or an unnamed voice. Remove @var{OverrideProperty} and @var{SetProperty}
events.")
   (music-filter
    (keep-voice voicename)
    music))


% Original example code for testing

flutes = \relative c'' {
  <<
    \new Voice = "fluone"
    { \tag rem \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
    \\
    \new Voice = "flutwo"
    { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
  >>

  \tag #'partonlytag {
    \once \override NoteHead.color = #red
  }
  c1 d e f g
  <<
    \new Voice = "fluone"
    { \voiceOne r8 r16 g e8. f16 g8[ c,] f e16 d }
    \\
    \new Voice = "flutwo"
    { \voiceTwo d16 c d8~ d16 b c8~ c16 b c8~ c16 b8. }
  >>
  c1 d e f g
}


\new Staff = "flutes"
\with {
  instrumentName = #"Flute 1 & 2"
  shortInstrumentName = #"Fl. "
}

{   \flutes  }

\score {

  \new StaffGroup <<
    \new Staff \with { instrumentName = #"Flute 1" }
      \removeWithTag rem \keepVoice "fluone" \flutes
    \new Staff \with { instrumentName = #"Flute 2" }
      \removeWithTag rem \keepVoice "flutwo" \flutes
  >>
}
%%%%%%%%%%

That way, your color override (and any other override) will survive the
filtering.
One could even think of incorporating the tag rem removal into the custom
filter, but this doesn't make much of a difference and I wanted to use
standard means where applicable.

HTH,
Torsten



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]