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 07:37:55 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 7/12/2018 5:08 AM, Torsten Hämmerle wrote:
SoundsFromSound wrote
One question though:

When you write -

/Unfortunately, \voiceOne and \voiceTwo expands in lots and lots of 
single events setting various properties. That way, the stem directions 
and rest positions won't be neutral in the resulting single voice 
extracts.As it is not possible to distinguish between \voiceOne and 
singular deliberate \override or \set commands, I just decided to filter 
out any OverrideProperty orSetProperty event).


/What negative side effects could result from these 'single events'? 
Just curious what I should be on the lookout for when using keepVoice. 
You mean I may have to flip a few things or move markings around?
Yes, exactly. The point is: you can't tell whether an explicit stem
direction has been set by \voiceOne or \stemUp.


By "unfortunalty", I mean that this cleansing also filters out \override
statements that have been deliberately inserted - they will get lost, too.
A \stemUp command, for instance, will look like this (using \displayMusic)



In the current (simple) version, there is no such distinction yet and if you
don't want to lose all the cosmetic overrides, you might keep the
'OverrideProperty events and use tags (\tag) for \voiceOne and \voiceTwo.
These tags could be easily inserted using search and replace.

All the best,
Torsten



Torsten,

Thank you for explaining that perfectly. I follow you.

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?

%%%%%%%%%%
\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 "")))
           (and
            (or (string=? contextid voicename)
                (string=? contextid ""))
            (not (eq? eventname 'OverrideProperty))
            (not (eq? eventname 'PropertySet))
            )))))

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"
    { \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" } \keepVoice "fluone"
\flutes
    \new Staff \with { instrumentName = #"Flute 2" } \keepVoice "flutwo"
\flutes
  >>
}
%%%%%%%%%%

\paper {
  top-margin = 15\mm
  left-margin = 15\mm
  right-margin = 15\mm
  bottom-margin = 15\mm
}

reply via email to

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