antlists <antli...@youngman.org.uk> writes: > On 15/05/2020 12:28, antlists wrote: >> There's a function Han Wen wrote for me years ago, that's made its >> way in to standard lilypond. It's probably mentioned in the docu >> about relative mode. Something along the lines of >> c1 \highlight { c8 d e f g f e d } >> \setAbsoluteOctave ... >> c1 \highlight { c8 d e f g a b c } >> Don't quote me on the function name though ... (I needed it for >> Pennsylvania 6-5-0-0-0 > > Found it ... > > \version "2.8.2" > > resetOctave = > #(define-music-function > (parser location reference-note) > (ly:music?) > > (let* > ((notes (ly:music-property reference-note 'elements)) > (pitch (ly:music-property (car notes) 'pitch)) > > ) > > (set! (ly:music-property reference-note 'elements) '()) > (set! (ly:music-property reference-note > 'to-relative-callback) > (lambda (music last-pitch) > pitch)) > > reference-note > )) > > pennsylvania = \context Voice = pennsylvania { > \override NoteHead #'style = #'cross > r2_\markup{ shout } f8. f16 f8. f16 f4 f f8. f16 r4 > } > > pennsylvaniaLyrics = \lyricmode { \small { Penn syl van ia six five > thou sand } } > > voiceTromboneI = \relative c' { > > r2 ef4.-- ef8-> ~ ef1 r2 r4 bf8.->( ef16-.) r2 r4 ef,8. af,16-> ~ | > af2 c-- df-- d-- ef-- df-- c-- bf-- | > \repeat "volta" 2 { R1*6 } \alternative { { \resetOctave f > \pennsylvania } { \pennsylvania } } > bf8-. cf4-> bf8-> ~ bf4 bf8.-- af16-. r8 af4.---. r2 > bf8-. cf4-- bf8-> ~ bf4 bf8.-- af16-> ~ | > >> Cheers, >> Wol >> > Okay, this is just the start of the file so it won't compile as is :-) > but you can see it defines the function resetOctave. I don't > particularly remember how it works, but you also see how it's used > further down. iirc it eats the first note after it - the f - and > treats it as an absolute pitch of zero length so the subsequent phrase > is at the right pitch regardless of what went in front of it. > > As I say, I think this function or something similar has made its way > into lilypond proper.
What advantage over the solution using make-relative that I posted do you see here? -- David Kastrup