Awesome, thanks Jean!
L
On Sun, 20 Nov 2022, 00:30 Jean Abou Samra, <[email protected]> wrote:
> 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
>
>