[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Subtracting 128th notes
From: |
Lukas-Fabian Moser |
Subject: |
Re: Subtracting 128th notes |
Date: |
Thu, 31 Mar 2022 22:10:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
Hi Stuart,
Am 31.03.22 um 16:30 schrieb Stuart Simon:
LilyPond Users:
I'm running into a scenario where it would be useful to subtract three
128th notes from a longer note's duration while having the longer note
still appear as a single note in the printed score. This is useful
when I have a printed score with three grace notes that I want to be
played on the beat rather than before it, but the grace notes are
understood differently from both the acciaccatura and the
stereotypical "eighth-note with grace upper neighbor plus two
sixteenths equals four sixteenths" type of appoggiatura commonly found
in Classical-era music. Please do not stop reading this when I tell
you that this may be a feature request, for it may also be a simple
exercise in finding the right duration scale factor.
When the longer note is a whole note, the case is very simple. The
duration is 1 * (1 - 3/128) = 1 * 125/128.
When the longer note is a half note, the case is more complicated. In
my mind, the duration should be 2 * 61/64, but I don't know if that
is correct.
Similarly, when the longer note is a quarter note, the duration should
be 4 * 29/32.
One more example, this one using a dotted duration. The duration of a
dotted quarter note is 3/8 of a measure, so the duration should be 4.
* ((1/128)/(3/8)) = 4. * 1/48.
I still don't know if I am correct or not, but if I am, then it would
ease my mind a bit.
You could let Lily do the math for you (if I understand your problem
correctly):
\version "2.22.0"
reduce-duration =
#(define-scheme-function (minuend subtrahend) (ly:duration? ly:duration?)
(ly:make-duration
(ly:duration-log minuend)
(ly:duration-dot-count minuend)
(* (ly:duration-scale minuend)
(- 1 (ly:moment-main (ly:moment-div (ly:duration-length subtrahend)
(ly:duration-length
minuend)))))))
{
a$(reduce-duration #{ 1 #} #{ 128*3 #}) e'128 e' e'
\time 2/4
a$(reduce-duration #{ 2 #} #{ 4. #}) e'4.
\time 3/8
a$(reduce-duration #{ 4. #} #{ 8. #}) e'8 e'16
}
I'm pretty sure there's a much better way to do this and to get a more
conventient syntax.
The problem with my approach is the following: In principle, we can just
write
\reduce-duration 1 128*3
but the problem is that this returns a "naked" duration, which Lily is
not willing to combine with the pitch written before it. For this, you
need to call the function in scheme mode with $, but then it's not so
easy to write durations - hence back to LilyPond mode with #{ ... #}.
Lukas