lilypond-user
[Top][All Lists]
Advanced

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

Re: Need some guidance from a Lilypond Scheme expert


From: jakob lund
Subject: Re: Need some guidance from a Lilypond Scheme expert
Date: Thu, 14 Jun 2012 11:33:38 +0200

2012/6/11 Matthew Probst <address@hidden>:
> I understand the Scheme language at intermediate level, but am not adept at
> processing Lilypond data structures.
>
> I'm looking into Snippet 465:
>
> http://lsr.dsi.unimi.it/LSR/Item?id=465
>
> I have the following in my Lilypond code, for typesetting a common guitar
> strum pattern:
>
> rhtOne = #(rhythm-template #{ s16 s16 r8 s16 #} )
> \relative c' { r4 \rhtOne <f a d>1 r2 }
>
> This works fine.  However, this does not:
>
> rhtOne = #(rhythm-template #{ s16 s16 r8 s16 #} )
> Dnine = { \relative c' { <f a d>1 } }
> \relative c' { r4 \rhtOne \Dnine r2 }
>
>
> The problem is that the snippet constructs a single chord event to apply the
> rythm to, by walking down the 'elements property of the first parameter, and
> collecting their pitches into a list with (map):
>
> http://pastebin.com/tSm1tw65
>
> The data structure this sees from my first Lilypond example is like this:
>
> http://pastebin.com/Tx8qhz6u
>
>
> However, the data structure created by my second Lilypond example looks more
> like this:
>
>
> http://pastebin.com/FuCRHDyK
>
>
> In the first example, it sees an 'EventChord, so we properly fetch a list of
> all its children's 'pitch properties.  In the second example, it's
> 'SequentialMusic, not  an 'EventChord.  What I want to do is walk down the
> data structure and find the first EventChord or NoteEvent.
>
>
> That doesn't seem too hard, actually.  Need to define a function
> first-non-sequence, and conditionally drill farther into the data structure
> until I find the first non-sequence.  Understanding that this is pseudocode
> instead of proper syntax,  I'd need to do something roughly like the
> following:
>
>
> http://pastebin.com/3eNNYjHE
>
>
> Also have to potentially recurse farther into nested levels of
> 'SequentialMusic or down each item in the 'elements list, I am comfortable
> fleshing it out to that level.
>
>
> What I'm wondering, is what (if any) Lilypond scheme function do I use to
> determine the type of a music data structure?  I could certainly just say
> (car mus) but I'm wondering if there's a function I should use for the sake
> of encapsulation.  I see that one can get properties of a music element with
> (ly:music-property mus 'SYMBOL), the existing snippet code grabs the
> 'elements list using (ly:music-property mus 'elements).

try (ly:music-property mus 'name) I think that does it?

Jakob.

>
>
> If it's just a matter of use (car mus) and comparing the symbol against a
> given list of options, fine, I just don't know if I'm going the right way.
>  I've been looking at the docs for several days now, and have done so at
> several times in the past, and I'm just not quickly finding what I need.
>
>
> My goal is to finally immerse myself into the Scheme side of Lilypond, and
> start implementing some fixes to the various rhythm-pitch template snippets
> that I've been wishing for, instead of complaining.
>
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>



reply via email to

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