lilypond-user
[Top][All Lists]
Advanced

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

Re: makeOctaves (LSR 445) 2.15 (ugly quick fix)


From: David Kastrup
Subject: Re: makeOctaves (LSR 445) 2.15 (ugly quick fix)
Date: Mon, 05 Mar 2012 16:12:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Jan-Peter Voigt <address@hidden> writes:

> Hello list,
>
> I made a quick fix for the makeOctaves function from
> http://lsr.dsi.unimi.it/LSR/Item?id=445
> Since 2.15.x notes may appear as single NoteEvents *not* wrapped in an
> EventChord, I added a check for 'NoteEvent and did a map on EventChord
> elements.
> This is an ugly solution, because EventChords are octaved twice.
>
> But it works for the moment.
> If my googling was wrong and there is a better solution around, a hint
> is appreciated.
>
> Cheers, Jan-Peter
>
> --snip--
> \version "2.15.31"

#(define (with-octave-up m octave)
        (let* ((old-pitch (ly:music-property m 'pitch))
               (new-note (ly:music-deep-copy m))
               (new-pitch (ly:make-pitch
                   (+ octave (ly:pitch-octave old-pitch))
                   (ly:pitch-notename old-pitch)
                   (ly:pitch-alteration old-pitch))))
              (set! (ly:music-property new-note 'pitch) new-pitch)
              (list m new-note)))

#(define (octavize music t)
   (map-some-music
     (lambda (m)
       (cond ((music-is-of-type? m 'event-chord)
                (set! (ly:music-property m 'elements)
                      (append-map!
                          (lambda (n)
                            (if (ly:music-is-of-type n 'note-event)
                                (with-octave-up n t)
                                (list n)))
                          (ly:music-property m 'elements)))
                m)
             ((music-is-of-type? m 'note-event)
                (make-event-chord (with-octave-up m t)))
             (else #f)))
      music))


> #(define-public makeOctaves (define-music-function (parser location
> arg mus) (integer? ly:music?)
     (octavize mus arg))

The music-map is already done within octavize.


-- 
David Kastrup




reply via email to

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