Is there an existing function/snipped that will adjust the octave of
music to within a given range of notes? For example, I have a melody
played by many instruments in a score, but some instruments can't
reach the higher notes, so those notes must be shifted to a lower
octave; I'd like to avoid copying & rewriting that part (and
quoteDuring has become just as messy).
Here is a function that seems to work but i am not sure that it will produce
nices melodies ...
%%%%%%%%%%%%%%%%%%%
#(define (check-pitch limit-pitch p)
(if (ly:pitch<? p limit-pitch )
p
(begin
(set! p (ly:make-pitch
(1- (ly:pitch-octave p))
(ly:pitch-notename p)
(ly:pitch-alteration p)))
(check-pitch limit-pitch p))))
checkPitch = #(define-music-function (parser location note
music )(ly:music? ly:music?)
(let* (
(elts (ly:music-property note 'elements))
(limit-pitch (ly:music-property (car elts) 'pitch)))
(if (ly:pitch? limit-pitch)
(music-map
(lambda (evt)
(let ((p (ly:music-property evt 'pitch)))
(if (ly:pitch? p)
(ly:music-set-property! evt 'pitch
(check-pitch limit-pitch p)))
evt))
music)
music)))
music = \relative {
c4 d e f g a b c
d \mark "limit note" e f g a b c d
e f g f e d c b
a g f e d c b a
g f e d c1}
\score {<<
\new Staff \music
\new Staff \checkPitch d'' \music >>}
%%%%%%%%%%%%%%%%%%%%%%%%
Gilles
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user