Hi Lukas,

Thanks so much for this further refinement!

You're right that it isn't really a hack (though that term was not at all meant 
as a criticsm!) and more of a workaround to make LilyPond do something that's 
entirely legitimate from a musical point of view.

Ideally, the tremolo function in LilyPond would be revised along roughly the 
following lines:

\repeat tremolo { (duration), (beam value), (musical arguments) }

So for example:

\repeat tremolo { (1), (32), (g c, d) }

would yield a three-note tremolo with three beams and a duration of one whole 
note / semibreve / 4/4.

This would pre-empt any clash between tremolo duration and time signature.

Best wishes,

Jan

From: Lukas-Fabian Moser <[email protected]> On Behalf Of 
Lukas-Fabian Moser
Sent: dinsdag 16 maart 2021 21:33
To: Dijkhuizen, J.F. van <[email protected]>; Carl Sorensen 
<[email protected]>; [email protected]
Subject: Re: Three-note tremolo in 4/4


Hi Jan,

But it only works if there's no clash with the time signature. So you can have 
three arguments in a 3/4 or 3/2 or 6/8 but not in a 4/4. Conversely, you can 
have four tremolo pitches in a 4/4 but not 3 -- at least not without the kind 
of hack devised by Lukas in the first response to my email.

And then again, to do so without generating warnings from LP, I suppose you 
would indeed have to modify tremolo properties on a more fundamental level. 
That's currently beyond my LP knowledge, however.

I think we needn't worry too much about that warning: It states that some 
calculation of stem lengths (which make sense for the "c32 g f" expression if 
taken without the \repeat tremolo) yields an unlikely value. I don't understand 
the internals at the moment, and I agree that it would be nice to have a 
solution that does not trigger warnings, but I wouldn't mind just suppressing 
the warning.

Thanks to Aaron Hill, there's even a nice way to suppress the right amount (3) 
of expected instances of that warning (taken from 
https://lists.gnu.org/archive/html/lilypond-user/2019-09/msg00326.html). So, 
what about:

\version "2.22.0"

#(define ly:expect-warning-times
   (lambda args
     (for-each (lambda _ (apply ly:expect-warning (cdr args)))
               (iota (car args)))))

\new Staff \relative {
  a'4 b c d
  \omit Dots
  \once\override Beam.positions = #'(2 . 1)
  #(ly:expect-warning-times 3 "weird stem size, check for narrow beams")
  \repeat tremolo 16 { { c32*2/3 g f } }
  \undo\omit Dots
  a4 b c d
}

I'm not even convinced that I would call this solution a "hack" (of course it's 
no use arguing about that term):

- It is the correct music (try exchanging "tremolo" by "unfold"!).
- The dots that I had to suppress manually actually make sense: 16 groups of 
notes consisting of three 32's each do amount to 3*16/32 = 3/2 of a whole 
measure, after all. So, what we generate is a 1.*2/3, and I don't mind having 
to tell LilyPond explicitly to engrave this by just omitting the dot.
- But I concede that LilyPond's default positioning of the beams isn't good 
enough. That might qualify as a bug, and the fact that manually supplying the 
placement triggers a warning doesn't help things - and of course having to 
suppress a warning is a bit hack-ish... :-)

I think what I want to say is that none of this involves, for example, 
deviating from the actual semantics of entered music ("hijacking staccato dots 
and turning them into flower-symbols"), or explicitly abusing side-effects of 
commands, etc. Instead, we write the actual music we want to hear and force-set 
only those layout parameters that LilyPond isn't at the moment ready to supply 
automagically.

Lukas

Reply via email to