lilypond-user
[Top][All Lists]
Advanced

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

Re: Splitting voices


From: Jean Abou Samra
Subject: Re: Splitting voices
Date: Sun, 20 Nov 2022 00:30:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1

Le 20/11/2022 à 00:02, Luca Fascione a écrit :
Hi all,
I have some 2 voice music coming from musicxml like this

<a' c>4 <g b>8. <d g\2>16 ~ ~ <d g>2.

and I'd like to split it into 2 voices instead:

<<
\new Voice ... { ... a4 g8. d16~ d2. ... }
\new Voice ... { ... c4 b8. g16~ g2. ... }
>>

is there any software / trick that I could use?
(I use Frescobaldi, but I couldn't find a transformation for this purpose)


There are a number of snippets floating around for that IIRC, basically variations on the theme

\version "2.22.2"

#(use-modules (ice-9 receive))

selectNote =
#(define-music-function (index music) (index? ly:music?)
   (music-map
    (lambda (m)
      (if (music-is-of-type? m 'event-chord)
          (let ((elts (ly:music-property m 'elements)))
            (receive (rhythmic arts)
              (partition (music-type-predicate 'rhythmic-event)
                         elts)
              (if (< (1- index)
                     (length rhythmic))
                  (let* ((elt (list-ref elts (1- index)))
                         (elt-arts (ly:music-property elt 'articulations)))
                    (set! (ly:music-property elt 'articulations)
                          (append elt-arts (map ly:music-deep-copy arts)))
                    elt)
                  #{ #})))
          m))
    music))

mus = \relative {
  <a' c>4 <g b>8. <d g\2>16~ <d g>2.
}

\new Staff <<
  \new Voice {
    \voiceOne
    \selectNote 2 \mus
  }
  \new Voice {
    \voiceTwo
    \selectNote 1 \mus
  }
>>


Best,
Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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