[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: "compound music expression" to "music" expression"
From: Gianmaria Lari <gianmarialari () gmail ! com>
Date: 2021-04-24 13:42:07
Message-ID: CAKhGe3yYpcdQyB_T3unYu_9_4xv+TxCfVvfJSJ1FSs7Pzatwug () mail ! gmail ! com
[Download RAW message or body]
Thank you David for your help.
I made some tests with \displayMusic and I have seen the situation :)
Thank you Aaron for the detailed explanation and also for the other code!
I will continue to use your \extract code but I keep also the new one for
the future :)
Have a nice w/e.
Ciao, g
On Sat, 24 Apr 2021 at 11:40, Aaron Hill <lilypond@hillvisions.com> wrote:
> 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
>
[Attachment #3 (text/html)]
<div dir="ltr">Thank you David for your help.<div><br></div><div>I made some tests \
with \displayMusic and I have seen the situation :)</div><div><br></div><div>Thank \
you Aaron for the detailed explanation and also for the other code!</div><div>I will \
continue to use your \extract code but I keep also the new one for the future \
:)</div><div><br></div><div>Have a nice w/e.</div><div><br></div><div>Ciao, \
g</div><div><br></div><div><div></div></div></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">On Sat, 24 Apr 2021 at 11:40, Aaron Hill <<a \
href="mailto:lilypond@hillvisions.com">lilypond@hillvisions.com</a>> \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2021-04-23 11:32 \
pm, David Kastrup wrote:<br> > Gianmaria Lari <<a \
href="mailto:gianmarialari@gmail.com" target="_blank">gianmarialari@gmail.com</a>> \
writes:<br> > <br>
>> Thank you Aaron and Jean, your code works!<br>
>> <br>
>> But I have some trivial questions.<br>
>> If I write:<br>
>> <br>
>> \displayLilyMusic \chordmode {c}<br>
>> <br>
>> <br>
>> I get:<br>
>> <br>
>> { < c' e' g' >4 }<br>
>> <br>
>> <br>
>> It looks a good "compound music expression".<br>
> <br>
> Try \displayMusic rather than \displayLilyMusic for more details.<br>
<br>
In case David's hint was not sufficient, there is an additional layer of <br>
complexity when using \chordmode. Unfortunately, that layer is not <br>
visible when using \displayLilyMusic, and this is where the confusion <br>
arises.<br>
<br>
\chordmode produces UnrelativableMusic that contains SequentialMusic and <br>
then EventChords of NoteEvents.<br>
<br>
Jean's first-element assumes that the music argument has a property <br>
called elements and resolves to the first value within the collection. <br>
UnrelativableMusic only has an element property, so first-element gets <br>
stuck. Here is a modified version of first-element that does not:<br>
<br>
%%%%<br>
#(define (first-element music)<br>
(or (ly:music-property music 'element #f)<br>
(first (ly:music-property music 'elements))))<br>
<br>
% This works, but you get a SequentialMusic.<br>
{ #(first-element #{ \chordmode {c} #}) }<br>
<br>
% This grabs the EventChord from the SequentialMusic.<br>
{ #(first-element (first-element #{ \chordmode {c} #})) }<br>
%%%%<br>
<br>
My \extract uses the built-in extract-typed-music procedure to do the <br>
heavy lifting, including the logic necessary to traverse nested music <br>
expressions with both element and elements properties.<br>
<br>
<br>
-- Aaron Hill<br>
</blockquote></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic