lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Current octave in relative mode


From: antlists
Subject: Re: Current octave in relative mode
Date: Sat, 16 May 2020 23:13:04 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

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.

Cheers,
Wol

On 15/05/2020 11:01, Klaus Blum wrote:
Hi,

I have a function that uses a music expression twice.
My problem is:
In relative mode, this expression can lead into a different octave. Then
the second application of the music expression starts from that new octave.
(See the last two invocations of "\highlight" in the example below)

Is there something I can do INSIDE my function to prevent this? E.g.
storing and re-applying the current octave? Thanks for any hint.  :)

I think you can use this inside your function. I explicitly didn't want to because this phrase appears in at least two different octaves so I wanted to apply the pitch outside it instead.

Cheers,
Wol



reply via email to

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