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: Ben
Subject: Re: Easiest way to call one voice (for parts)?
Date: Thu, 12 Jul 2018 08:37:33 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 7/12/2018 8:03 AM, Torsten Hämmerle wrote:
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.

Wow. You're right. That is very simple, and works like a charm!


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:

Brilliant.



%%%%%%%%%%
\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



This will end up saving me countless hours or work Torsten, thank you.


Just one final curiosity question:

Say you were engraving a full orchestra piece, where many instruments had 1,2 or 3 parts (i.e. flute 1,2,3, trumpet 1,2, etc).

Would you set up each instrument part (1,2,3) separately as variables and then part combine them on a staff in the score

or

would you compose them on one staff/variable, "inline" where you just create 'voices' as you go along.
(assuming that there is a decent amount of independence between the parts of the same instrument.)

Would that encourage one approach over the other, or would you always do it the same way even if the parts (1,2,3) were 99% identical in the score of the same instrument?

Have a great day! :)



reply via email to

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