Lukas-Fabian Moser writes:
> Hi Pavel,
>
> Am 09.08.20 um 12:30 schrieb Павел:
>> I want to write simple function that will be change duration of
>> note. But I stuck on the first step: I can't "extract" (or "see")
>> the duration property:
>>
>> \version "2.20.0"
>> mynote = c'
>> \displayMusic \mynote
>> #(display-scheme-music
>> (ly:music-property mynote 'duration))
>
> Try setting mynote = c'8 from the start.
>
> LilyPond interprets your mynote as a naked pitch (and you obvioulsy
> can't extract a duration from a pitch). This can be seen by doing
> #(display-scheme-music mynote) which yields (ly:make-pitch 0 0), or
> simply by #(display mynote) which yields #.
>
> It seems using \displayMusic hides this fact by first upgrading
> #mynote to a full-fledged NoteEvent; these implicit conversions happen
> all the time in LilyPond.
It's not really \displayMusic which does it but the parser. The parser
would pass the pitch to \displayMusic as-is, but the predicate for
displayMusic's argument is ly:music? which refuses taking it so the
parser instead checks whether it can interpret \mynote in a manner more
acceptible to \displayMusic. When it finds a valid interpretation
passing the predicate, it ultimately calls displayMusic with it.
--
David Kastrup