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: Wed, 11 Jul 2018 13:45:49 -0700 (MST)

Hi Ben,

The easiest way would probably be to apply some kind of filter, extracting
the relevant music.

In the example, we have some kind of "manually created \partcombine" that
lacks certain information. It is not at all clear whether the single notes
in the non-parallel music should be played by Flute 1, Flute 2, or both.
Just for the fun of it, let's consider we'd like to keep everything that
belongs one specific voice name or has no voice name (the non-polyphonic
parts).


Something like 
  \keepVoice "fluone" \flutes
or
  \keepVoice "flutwo" \flutes
should extract just one of the Voices contained in \flutes (or the unnamed
Voice that is supposed to be valid for both Instruments).


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 (at least I don't know how to
accomplish this), I just decided to filter out any OverrideProperty or
SetProperty event).


An experimental (over-simplified) prototype could look like this (at least
as a basis to start from and to play around with):

%%%%%%%%%%
\version "2.19.82"

#(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. }
  >>
  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
  >>
}
%%%%%%%%%%


In addition to the original combined Flute 1 & 2 stave, there is an
automatically extracted mini score containing two separate staves created by
using \keepVoice "<voice name>" \flutes

<http://lilypond.1069038.n5.nabble.com/file/t3887/keepVoice-filter.png> 

All the best,
Torsten





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



reply via email to

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