[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Easy definition of music function
From: |
David Kastrup |
Subject: |
Re: Easy definition of music function |
Date: |
Fri, 27 Apr 2018 21:26:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
Lukas-Fabian Moser <address@hidden> writes:
> Folks,
>
> I sometimes enter music which consists of a lot of "patterns" where
> (relatively complicated) constructions of beams, tuplets etc. are used
> repeatedly with changing pitches. Of course I'd like to put those in a
> function.
>
> For instance, in a Mozart symphony I have
>
> r16 \once \omit TupletBracket \tuplet 3/2 { c32([ e g] } c16) c-!
>
> all over the place. So, I want do define a function \pat that takes
>
> \pat c e g c
>
> and creates just this pattern.
>
> QUESTION: I am under the impression that, since I want to give only
> pitches to the function, I have to create the music in Scheme, and
> hence I do not know how to attach the various articulations etc. other
> than in Scheme. Hence, my function now reads:
[...]
> Works like a charm, but I admit that I find the definition quite
> tedious (me being a non-Schemer, essentially), especially I think that
> I only realized part of -! in my articulation definition (the MIDI
> part being omitted).
>
> What I really would like to have is something like:
>
> pat = #(define-music-function
> (pa pb pc pd)
> (ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
> #{
> r16 \once \omit TupletBracket \tuplet 3/2 { #pa 32([ #pb
> #pc] } #pd 16) #pd-!
> #}
> )
>
> But of course this does not work since pitch #pa and 32([ do not glue
> together.
>
>
> Is there some easy way to define the function I want?
Use $pa $pb $pc (and make sure to add a space before adding something
like ] afterwards) and $pd . For # in music expressions, Lily expects
music expressions, not pitches. For $ it chooses the syntactical
category according to expression type.
--
David Kastrup