lilypond-user
[Top][All Lists]
Advanced

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

Re: Relative rhythms across bars for time changes?


From: Alasdair McAndrew
Subject: Re: Relative rhythms across bars for time changes?
Date: Sun, 19 Nov 2023 02:18:44 +1100

Thanks, Michael - that's a really nice solution.

I wonder if it would be possible to create such a function which automatically puts the = sign over the barline, and the notes to its right and left.

Alasdair

On Sun, 19 Nov 2023, 1:41 am Michael Werner, <reznaeous@gmail.com> wrote:
Hi Alasdair,

On Fri, Nov 17, 2023 at 9:28 AM Alasdair McAndrew <amca01@gmail.com> wrote:
I'm typesetting some 16th century music which has a lot of time changes.  And I'd like to add equivalences of notes across bar-lines, to indicate for example, that a quarter note in one bar is equal in time to a half note in the next bar.

The sort of notation I want is in this snippet:


However, I want that equals sign to be aligned with the barline.  I have two questions: (a) how can I do this? and (b) is there an easier way than the markup given in the snippet?

In the time-honored tradition of "There's More Than One Way To Do It ™", here's another option:

\version "2.25.10"

tempoChange =
#(define-music-function (alignValue firstNote secondNote) (number? ly:duration? ly:duration?)
   #{
     \tweak self-alignment-X #alignValue \textEndMark \markup {
       \concat {
         (
         \fontsize #-3 \general-align #Y #DOWN \note { #firstNote } #UP
         " = "
         \fontsize #-3 \general-align #Y #DOWN \note { #secondNote } #UP
         )
     } }
   #} )

music = \relative c'' {
  c4 c c c | d d d d \tempoChange 0 4 2 | b a a b | d d d d | \break
  d d d e | f f f f | a f e d | e e e e \tempoChange -0.15 2 8. | \break
  e e a g | f f f f | e d d d | b b b b
  \fine
}

\new Staff {
  \new Voice {
    \music
  }
}

producing:

image.png

It's still using the code from the snippet you referenced (slightly modified), but wrapped into a function. This way you can tuck the function definition away somewhere (such as the top of your source file or off in a separate include file, whatever works best for you) so that the function code itself is out of the way, but can still be used with a single function call.

The first argument to the function call is an alignment value - 0 is center, positive moves it left and negative moves it right.. The way the code works, if the two notes are of the same size (such as a quarter note and a half note) then the markup will be centered with an alignment value of 0. But if one of the notes is larger (such as in the second example) then the entire thing shifts over a bit. That's why in the second example the first argument is -0.15 - that's just enough to put the markup centered again.

The second and third arguments are simply note durations. This function can only handle single notes, so no triplets or anything like that.

One other thing to note - this function uses the \textEndMark function. There's also a \textMark function. The two work similarly, with the exception of how they handle line breaks. The one I'm using here (\textEndMark) puts the markup at the end of the system before the break. The other one (\textMark) puts the markup at the beginning of the system after the line break. So depending on which way you want things handled you may or may not need to change which of the two you use.
--
Michael


reply via email to

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