lilypond-user
[Top][All Lists]
Advanced

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

Re: "Automatic octaves" snippet is broken in 2.15(.36)


From: Thomas Morley
Subject: Re: "Automatic octaves" snippet is broken in 2.15(.36)
Date: Tue, 17 Jul 2012 22:30:35 +0200

2012/7/17 James Harkins <address@hidden>:
> http://lsr.dsi.unimi.it/LSR/Item?id=445
>
> "Adding automatic octaves to a melody" no longer works (at least in 2.15.36). 
> LP throws no errors and successfully produces a PDF, but it renders the notes 
> exactly as written in the original music expression, without the extra 
> octaves. I tried in my own file, and I also tried rendering the exact code 
> from the snippet (which includes an example). In both, the octaves were 
> missing.
>
> How should the code be updated for a newer lilypond?
>
> hjh

See,
http://lists.gnu.org/archive/html/lilypond-user/2012-03/msg00114.html
code by David Kastrup
(typo corrected)

\version "2.15.39"

#(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 (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)))

\makeOctaves #1 \relative c' { <c e>4 c }



HTH,
  Harm



reply via email to

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