Paolo Prete <[email protected]> writes:
> Hello,
>
> I don't understand how to use a fraction as a parameter for a scheme
> function. More specifically, this gives me an error:
>
> %%%%%%%%%%%%
>
> proportionalNotationDur = #(define-music-function (parser location frac)
> (scheme?) #{ \set
> Score.proportionalNotationDuration = #(ly:make-moment frac) #})
> {
> \proportionalNotationDur 1/16
> c' c' c' c'
> }
>
> %%%%%%%%%%%%
>
> How can I fix it?
> Thanks!
A fraction is a number _pair_ (because \time 4/4 is different from \time
2/2), not rational number. For ly:make-moment, you need to convert to a
rational number or two integers. The predicate should really, really,
really cater to the correct type: scheme? is just asking for trouble.
Personally, I'd rather use a duration in order to write 16 instead of
1/16 and 16*3 instead of 3/16.
But for the usage you want, one can do
proportionalNotationDur =
#(define-music-function (parser location frac) (fraction?)
#{ \set Score.proportionalNotationDuration = #(fraction->moment frac) #})
{
\proportionalNotationDur 1/16
c' c' c' c'
}
--
David Kastrup