On 3 September 2017 at 22:34, David Kastrup <[email protected]> wrote:

> [....]
>


> > Well, you can cheat by going inside of chords like
> >
> > \version "2.19.60"
> >
> > nc = c_3
> > nd = d_2
> > ne = e_3
> > nf = f_4
> >
> > {
> >   \fixed c' {<\nc>8 [ <\nd> <\ne> <\nf>]}
> >   \fixed c' {<\nc>16 [ <\nd> <\ne> <\nf>]}
> > }
> >
> >
> > since then the durations get removed and reassigned, but you are hardly
> > going to make your source code more readable by that.
> >
> > I think you are likely better off by creating music functions for the
> > job.
>
> Here is how to do this cheaply:
>
> \version "2.19.60"
>
> wf =
> #(define-scheme-function (p f) (ly:pitch? ly:event?)
>   (define-music-function () () #{ $p $f #}))
>
> nc = \wf c_3
> nd = \wf d_2
> ne = \wf e_3
> nf = \wf f_4
>
> {
>   \fixed c' {<>8 [\nc \nd \ne <>] \nf}
>   \fixed c' {<>16 [\nc \nd \ne <>] \nf}
> }
>
> Now the <>] thingy is still sort of ugly.  I have a patch that can get
> rid of it.  In fact, that patch also makes your example in the first
> post in this thread compile.
>
> And it has lots of other implications.  Like letting
>
> { c \tweak color #red \p }
>
> work as expected.  However, it also has some strange consequences.  When
> writing
>
> { \displayLilyMusic c \tweak color #red \p }
>
> the dynamic will not be included in the output while with
>
> { \displayLilyMusic c -\tweak color #red \p }
>
> it will.  The reason is that in the first case, LilyPond has no way of
> knowing whether \tweak color #red \p is a post-event or not before
> calling \tweak, and if it were to end up _not_ being a post-event,
> \displayLilyMusic should have gotten evaluated before \tweak even got
> called.  So basically LilyPond processes things as normal but allows
> spurious post events to remain in braced lists and does another pass
> sweeping them into the right expressions before further processing.
>
> For people who want to be in full understanding what is happening, this
> might be puzzling.  For people who want to have things "just work", it
> might often produce useful results before they start asking questions.
>
> --
> David Kastrup
>

I tried your example and it works, thank you David for this escamotage!
g.
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to