|
From: | Jonathan Kulp |
Subject: | Re: broken octaves |
Date: | Fri, 25 Jul 2008 12:36:44 -0500 |
User-agent: | Thunderbird 2.0.0.14 (Macintosh/20080421) |
Jon Dominic Neumann wrote:
Hi Stefan, are you sure you want c c' d d' ... instead of c c' d, d' e, e'? You could write a scheme function for that. I´ll try it, but I´m not too experienced in such things. Dominic 2008/7/25 Stefan Thomas <address@hidden>:Dear Lilypond-users, I have in mind an input like: \relative { \brokenoctaves {c d e f g }} and the desired output is: \relative { c c' d d' e e' f f' g g' } Can this be done automatically?
-- Jonathan Kulp http://www.jonathankulp.com %%% This is a macro that allows you to create octaves with a command #(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))\relative { c d e \octaves #-1 { f g c }} % this is an example of the macro in practice
[Prev in Thread] | Current Thread | [Next in Thread] |