lilypond-user
[Top][All Lists]
Advanced

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

Re: "compound music expression" to "music" expression"


From: Aaron Hill
Subject: Re: "compound music expression" to "music" expression"
Date: Sat, 24 Apr 2021 02:40:46 -0700
User-agent: Roundcube Webmail/1.4.9

On 2021-04-23 11:32 pm, David Kastrup wrote:
Gianmaria Lari <gianmarialari@gmail.com> writes:

Thank you Aaron and Jean, your code works!

But I have some trivial questions.
If I write:

\displayLilyMusic \chordmode {c}


I get:

{ < c' e' g' >4 }


It looks a good "compound music expression".

Try \displayMusic rather than \displayLilyMusic for more details.

In case David's hint was not sufficient, there is an additional layer of complexity when using \chordmode. Unfortunately, that layer is not visible when using \displayLilyMusic, and this is where the confusion arises.

\chordmode produces UnrelativableMusic that contains SequentialMusic and then EventChords of NoteEvents.

Jean's first-element assumes that the music argument has a property called elements and resolves to the first value within the collection. UnrelativableMusic only has an element property, so first-element gets stuck. Here is a modified version of first-element that does not:

%%%%
#(define (first-element music)
  (or (ly:music-property music 'element #f)
      (first (ly:music-property music 'elements))))

% This works, but you get a SequentialMusic.
{ #(first-element #{ \chordmode {c} #}) }

% This grabs the EventChord from the SequentialMusic.
{ #(first-element (first-element #{ \chordmode {c} #})) }
%%%%

My \extract uses the built-in extract-typed-music procedure to do the heavy lifting, including the logic necessary to traverse nested music expressions with both element and elements properties.


-- Aaron Hill



reply via email to

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