lilypond-user
[Top][All Lists]
Advanced

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

Re: In octaves


From: Jonathan Kulp
Subject: Re: In octaves
Date: Mon, 28 Apr 2008 07:43:47 -0500
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

Bravo Jay!! It works flawlessly!! The commas and single quotes work perfectly in the \relative blocks and the cautionary accidentals also work properly now. Thanks so much for your persistence on this as I don't have the programming wherewithal to do it myself. This is an *awesome* tool. Thanks!!! :-)

Jon

Jay Anderson wrote:
Let me know how it works!

A couple more changes:

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

#(define (octavize-chord elements t)
 (cond ((null? elements) elements)
       ((eq? (ly:music-property (car elements) 'name) 'NoteEvent)
         (cons (car elements)
               (cons (octave-up (car elements) t)
                     (octavize-chord (cdr elements) t))))
       (else (cons (car elements) (octavize-chord (cdr elements ) t)))))

#(define (octavize music t)
 (let* ((es (ly:music-property music 'elements))
        (e (ly:music-property music 'element))
        (name (ly:music-property music 'name)))
   (cond ((eq? name 'EventChord)
          (ly:music-set-property! music 'elements (octavize-chord es t)))
         ((pair? es)
          (for-each (lambda(x) (octavize x t)) es))
         ((ly:music? e)
          (octavize e))))
 music)

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

Now you can do silly things like: \relative c'{ \octaves #2 {c d e f'
g,,} } and it will make the new note two octaves up. I'm not sure why
you'd want that, but it seemed easy enough to do (and takes slightly
less code).

-----Jay


--
Jonathan Kulp
http://www.jonathankulp.com




reply via email to

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