lilypond-user
[Top][All Lists]
Advanced

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

Re: \makeOctaves broken?


From: Jay Anderson
Subject: Re: \makeOctaves broken?
Date: Wed, 18 Apr 2012 19:23:32 -0700

On Wed, Apr 18, 2012 at 4:44 PM, Urs Liska <address@hidden> wrote:
> I was quite happy to find the function \makeOctaves in the LSR.
>
> But now it seems to be broken - there is no error message, but the function
> doesn't do anything (2.15.36).
> As I don't know _anything_ about Scheme I can't do more than ask if anybody
> has an idea what has changed with LilyPond so that this function is now
> broken?

David Kastrup did a quick fix a few months
back:http://lists.gnu.org/archive/html/lilypond-user/2012-03/msg00114.html

I just tried it and it had a few problems:
- it didn't work within a relative section. It only worked within
relative sections before.
- Slurs and dynamics attached to single notes are lost during the
conversion to chords.

Below fixes the relative problem, but I haven't spent enough time on
it to figure out the second problem. That will take a little bit more
time to understand the internal structure changes which I don't have
at the moment. Perhaps you can take a look and make it work.

-----Jay

\version "2.15.35"

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

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

\relative c'
{
  \time 3/8
  \key gis \minor
  \makeOctaves #1  { dis8(\f e dis')~ dis8.( cis16 b8 }
  \makeOctaves #-1 { ais' gis dis) cis( dis <dis gis'>)\p }
}



reply via email to

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