[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TimeSignature with note in denominator
From: |
Kieren MacMillan |
Subject: |
Re: TimeSignature with note in denominator |
Date: |
Sat, 13 Nov 2021 10:06:26 -0500 |
Hi Lukas,
> It's probable that I'm missing a point (since I only skimmed the discussion
> so far), but:
>
> Currently, \time is defined (in ly/music-functions-init.ly) with the signature
>
> #(define-music-function (beat-structure fraction)
> ((number-list? '()) fraction?)
>
> Now the predicate fraction? is defined (in scm/c++.scm) as
>
> (define-public (fraction? x)
> (and (pair? x)
> (index? (car x)) (index? (cdr x))))
>
> to wit, a pair of non-negative exact integers.
>
> Now the lexer turns 3/4 into such a pair: See lily/lexer.ll, by virtue of the
> lines
>
> N [0-9]
> FRACTION {N}+\/{N}+
>
> which translate as "a fraction consists of one or more digits, followed by /,
> followed by one or more digits"; and the call to the procedure scan_fraction;
> just search for it in lexer.ll. (I'm deliberately giving you more information
> than you probably need, to help you navigate the source and see how
> everything fits together.)
Thank you for that — it’s very helpful!
> It's no problem at all to make \time accept more general pairs: Just replace
> fraction? by (e.g.) pair? in the definition of \time, or define a suitable
> predicate of your own accepting only the "right" kind of pairs.
I did that (see earlier posts):
time =
#(define-music-function (beat-structure fraction)
((number-list? '()) pair?)
(_i "Set @var{fraction} as time signature, with optional
number list @var{beat-structure} before it.")
(make-music 'TimeSignatureMusic
'numerator (car fraction)
'denominator (cdr fraction)
'beat-structure beat-structure))
This worked exactly as I hoped. The problem I ran into at that point was
figuring out how to turn a string "4." into a note duration, in order to output
it as the denominator of the time signature — and then the thread apparently
went off the rails…
> of your three examples, only the first one (\time 3/4.) definitely would
> require changes to the lexer/parser.
Changes that David K appears not to favour.
> I think it would be desirable to be able to enter durations in LilyPond
> syntax, in order to, for example, be able to enter complicated constructs
> like "8.~8" from Werner's example.
Agreed.
> But if you want to include LilyPond syntax in an explicit pair argument, you
> need #{ #} which certainly works but makes for horrible syntax
Also agreed. =)
> Wouldn't it be easier to define an independent \kierenTime function that
> expects an integer (index?) numerator and a music (ly:music?) denominator?
See my “stylesheet” comment earlier in the thread: in a perfect world, a user
should be able to take any existing score and simply add
\override Score.TimeSignature.style = #'note-denom
and the output would be “as expected” — with a new function, a
search-and-replace (with possible “fancy” manipulation of the arguments) is
required every time the user wants to switch between styles. I personally
consider that inelegant, or at the very least suboptimal, especially when
Lilypond offers such a generous “global” context modification mechanism.
All that being said: The tide of resistance to finding the optimal
implementation is evident, so I think I’ll just give up and add a new function
in order to move the patch/feature forward.
Thanks,
Kieren.
________________________________
Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: kieren@kierenmacmillan.info
- Re: TimeSignature with note in denominator, (continued)
- Re: TimeSignature with note in denominator, Aaron Hill, 2021/11/12
- Re: TimeSignature with note in denominator, Kieren MacMillan, 2021/11/12
- Re: TimeSignature with note in denominator, Aaron Hill, 2021/11/13
- Re: TimeSignature with note in denominator, Kieren MacMillan, 2021/11/13
- Re: TimeSignature with note in denominator, Aaron Hill, 2021/11/13
- Re: TimeSignature with note in denominator, David Kastrup, 2021/11/13
- Re: TimeSignature with note in denominator, Aaron Hill, 2021/11/13
- Re: TimeSignature with note in denominator, Kieren MacMillan, 2021/11/13
- Re: TimeSignature with note in denominator, David Kastrup, 2021/11/13
- Re: TimeSignature with note in denominator, Lukas-Fabian Moser, 2021/11/13
- Re: TimeSignature with note in denominator,
Kieren MacMillan <=
- Re: TimeSignature with note in denominator, Lukas-Fabian Moser, 2021/11/13
- Re: TimeSignature with note in denominator, Kieren MacMillan, 2021/11/13
- Re: TimeSignature with note in denominator, Lukas-Fabian Moser, 2021/11/13
- Re: TimeSignature with note in denominator, Kieren MacMillan, 2021/11/13
- Re: TimeSignature with note in denominator, Lukas-Fabian Moser, 2021/11/13
- Re: TimeSignature with note in denominator, Aaron Hill, 2021/11/13
- Re: TimeSignature with note in denominator, Aaron Hill, 2021/11/13
- Re: TimeSignature with note in denominator, David Kastrup, 2021/11/13
- Re: TimeSignature with note in denominator, Kieren MacMillan, 2021/11/13
- Re: TimeSignature with note in denominator, David Kastrup, 2021/11/13