2

I would like to create a Lilypond music function that allows me to express this MWE:

{ \override Score.SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/30) a b c }

as

\spn #1 #30 { a b c }

I tried with with this:

\version "2.22.1"

 spn =
#(define-music-function
  (beg end notes)
  (number? number? ly:music?)
  #{
 
 { \override Score.SpacingSpanner.base-shortest-duration = #(ly:make-moment #(cons beg end)) #notes }
    
  #})

\spn #1 #30 { a b c }

\relative c''
    { \override Score.SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/30) a b c }

which does not produces same output as the MWE.

I get programming error: Unknown type predicate.

I suspect I am expressing the ly:make-moment argument improperly.

What am I doing wrong?

1 Answer 1

4

"unknown type predicate" would be an error with LilyPond's internals when typechecking the arguments of ly:make-moment because the complaint should be that the argument of ly:make-moment is not a rational number. If this persists into the latest version, report a problem to the bug reporting list.

Of course your code also is faulty: you need to write (/ beg end) where you write (cons beg end) because the 1/30 you replace is not a LilyPond fraction 1/30 (which would be represented by (1 . 30) indeed) but a Scheme exact rational number 1/30. Fixing that will help with your problem.

But you should get a proper error message rather than LilyPond not being able to tell you what it is complaining about.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.