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: Sun, 27 Apr 2008 22:34:38 -0500
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

Hey guys,

Just discovered another issue with the octaves command and wondered whether you could see an easy way out of it. When I use a cautionary accidental inside one of these octaves blocks, it only prints the accidental on the lower note of the 8ve pair. Any way to get it to show the accidental on both notes of the pair? Best,

Jon

Valentin Villenave wrote:

Hi Jonathan, here's the function I proposed earlier. it takes a number
as an argument: if you want to add upper octaves, specify #1, if you
want lower octaves, type #-1. Its very dirty and it suffers from the
same bug (i.e. it's probably a bad idea to use it inside a \relative
block when you have to use commas and single quotes), but hopefully
someone will clean the code and address the issue.

#(define (octave-up m t)
          (make-music 'NoteEvent
            'duration (ly:music-property m 'duration)
            'pitch (ly:make-pitch (+ t (ly:pitch-octave
(ly:music-property m 'pitch)))
                        (ly:pitch-notename (ly:music-property m 'pitch))
                        (ly:pitch-alteration (ly:music-property m 'pitch)))))

#(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?)
 (if (> arg 0) (octavize mus 1) (octavize mus -1)))

 \relative { c d e \octaves #-1 { f g c }}


Cheers,
Valentin


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

Attachment: octaveprob.ly
Description: Text document

Attachment: octaveprob.pdf
Description: Adobe PDF document


reply via email to

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