Wols Lists <antlists <at> youngman.org.uk> writes: > On 21/05/15 07:36, k-ohara5a5a <at> oco.net wrote: > > I'm proposing to push a \fixed c' {} that always takes a reference > > pitch, as in the current patch. > So the behaviour is different from \relative, which doesn't have to > have a reference pitch.
Before version 2.18, \relative{} defaulted to relative c'{} but that was deprecated with version 2.12. Since version 2.18 \relative{} defaults to \relative f{}, which acts the same as taking the starting octave from the first pitch \relative {c''4 c g' g} == \relative c'' {c4 c g' g} I have seen two different suggestions for what default behavior to use if the reference pitch after \fixed is omitted. Neither default seems obvious to me, so I'm proposing we use \fixed with an explicit pitch until it becomes clear that one usage is natural and useful enough to be default. 1) Something like the old \relative {} -> relative c' {} > If \fixed takes an optional (defaults to c') reference pitch then the > underlying code will be the same. Earlier versions of the proposed patch did this, but defaulting to c not c' 2) Something like the new \relative {c'' ...} -> relative c'' {c ...} <tdanielsmusic <at> googlemail.com> writes: > I'd prefer the syntax and options to parallel those of > \relative. That is, an optional prefix pitch to indicate > the starting octave, and taking the starting octave from > the first contained note if the prefix is omitted. We could implement this, but unlike \relative where each octave mark increments the octave of the previous pitch, there is no simple way to start the machinery of \fixed so that the octave shift is determined by the first pitch it acts upon. We need code to explicitly find the first pitch and extract its octave. ------ absolute = #(define-music-function (parser location pitch music) ((ly:pitch?) ly:music?) (_i "Shift the octave of each pitch in @code{music} according to the ocatve marks @code{pitch}. If @code{pitch} is ommitted, use the octave marks from the first pitch found in @code{music} to shift the octave of all the pitches in @code{music} except the first. The result is absolute music, wrapped as @samp{RelativeOctaveMusic} to hide it from surrounding @code{\\relative} and @code{\\absolute} commands.") (define (extract-octave-from-first-pitch m) (if (eq? (ly:music-property m 'name) 'RelativeOctaveMusic) #f (or (let ((p (ly:music-property m 'pitch))) (and (ly:pitch? p) (let ((octave-marks (1+ (ly:pitch-octave p)))) ;;Reverse-shift the first pitch, ;; so later we can shift back with all the others (ly:music-transpose m (ly:make-pitch (- octave-marks) 0 0)) octave-marks))) (let ((e (ly:music-property m 'element))) (and (ly:music? e) (extract-octave-from-first-pitch e))) (let loop ((elts (ly:music-property m 'elements))) (and (pair? elts) (or (extract-octave-from-first-pitch (car elts)) (loop (cdr elts)))))))) (let ((octave-marks (or (and pitch (1+ (ly:pitch-octave pitch))) (extract-octave-from-first-pitch music) 0))) (display octave-marks) (newline) (cond ((not (= 0 octave-marks)) (ly:music-transpose music (ly:make-pitch octave-marks 0 0)) ;;In order to leave unchanged the notes in any enclosed ;; \absolute or \fixed or \relative, make a cancelling shift (map (lambda (m) (ly:music-transpose m (ly:make-pitch (- octave-marks) 0 0))) (extract-named-music music 'RelativeOctaveMusic))))) (make-music 'RelativeOctaveMusic 'element music)) _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel