in the hope of separating MIDI notes that don't have identical timing.
That is, if my input is
   << { a1 } \\ { b2 <c d>2 } >>

it would be nice to be able to separate it out into three separate outputs
for separate MIDI channels, like:
  { a1 }
  { b2 c2 }
  { r2 d2 }


Not hardly tested but this should work :

%%%%%%%%%%%%%%%%%%%
\version "2.24.1"

\include "chordsAndVoices.ly"

noteAloneToRest = #(define-music-function (music)(ly:music?)
  (map-some-music
    (lambda(evt)
      (case (name-of evt)  ;; see chordsAndVoices.ly
        ((EventChord) evt) ;; not #f => stop iteration
        ((NoteEvent)       ;; note to rest
(make-music 'RestEvent 'duration (ly:music-property evt 'duration '())))
        (else #f)))        ;; continue iteration
    music))


music = << { a1 } \\ { b2 <c' d'>2 } >>

midiI = \extractVoice #1 \music
midiII = \extractVoice #2 \extractNote #1 \music
midiIII = \extractVoice #2 \extractNote #2 \noteAloneToRest \music

\score { <<
  \new Staff  { \midiI }           % { a1 }
  \new Staff  { \midiII }          % { b2 c2 }
  \new Staff  { \midiIII }         % { r2 d2 }

% \midi
}

%%%%%%%%%%%%


--
Gilles

Reply via email to