lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scheme predicative types


From: Lukas-Fabian Moser
Subject: Re: Scheme predicative types
Date: Thu, 17 Sep 2020 10:14:05 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hi Aaron,
The three forms

 * \tempo 4 = 96
 * \tempo Crazy 4 = 260-270
 * \tempo "Sluggishly slow"

are hardcoded as variants into the parser. My guess is that this might
be hard (or impossible) to accomplish in a music function.

You just need to be a little creative.
That's what I hoped would happen. :-) If I understand it correctly, both the genius and the drawback of your solution lies in having the user write an explicit "\tempo" in order to invoke the parser's hard-wired way of dealing with the possible syntax variants, right?
%%%%
\version "2.20.0"

#(define (tempo? arg)
  (and (ly:music? arg)
       (not (null? (extract-typed-music arg 'tempo-change-event)))))

Maybe I'm overly cautious, but I'd prefer this to be more specific so that it accepts only actual "\tempo ..."-constructs. For example:

#(use-modules (scm display-lily)) #(define (tempo? arg)   (and (ly:music? arg)        (string-startswith (music->lily-string test) "\\tempo")))

This is probably an awful waste of computing effort, but I liked it better than checking for the kind-of special internal structure of a music _expression_ containing only a \tempo (namely, a sequential-music containing both a TempoChangeEvent and a PropertySet specced to context Score.)

Lukas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]