lilypond-user
[Top][All Lists]
Advanced

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

Re: splitting chords entered as <<c e g>>^"with stuff" \etc


From: Gilles THIBAULT
Subject: Re: splitting chords entered as <<c e g>>^"with stuff" \etc
Date: Sun, 18 Jan 2009 22:58:43 +0100


<c c'> <d d'> <e e'> <f f'> goes to
c d e f c' d' e' f'

I don't know if it will help but i did for me something like that :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(define (has-duration? music)
(ly:duration? (ly:music-property music 'duration)))

#(define (not-has-duration? music)
(not (has-duration? music)))

keepsOnlyFirstNote = #(define-music-function (parser location music) (ly:music?)
(music-map
 (lambda (evt)
  (if (eq? 'EventChord (ly:music-property evt 'name))
     (let ((elts (ly:music-property evt 'elements)))
      (if (has-duration? (car elts))
           (ly:music-set-property! evt 'elements (cons
                (car elts)
                (filter not-has-duration? (cdr elts)))))))
 evt)
music))

deleteFirstNote = #(define-music-function (parser location music) (ly:music?)
(music-map
 (lambda (evt)
  (if (eq? 'EventChord (ly:music-property evt 'name))
     (let ((elts (ly:music-property evt 'elements)))
          (if (has-duration? (car elts))
               (ly:music-set-property! evt 'elements  (cdr elts)))))
 evt)
music))


music =\relative {
<c e>4-> <d f>( <b g'>) <c e>-. g2 c2
}

\markup { Music with chords }
\new Staff \music
\markup { Music splitted in 2 staffs }
<<
  \new Staff \deleteFirstNote \music
  \new Staff \keepsOnlyFirstNote \music
 >>
%%%%%%%%%%%%%%%%%%%%%%%%%%

Gilles




reply via email to

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