lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme function to affect a compound music expression?


From: Robin Bannister
Subject: Re: Scheme function to affect a compound music expression?
Date: Fri, 24 Oct 2014 16:54:49 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Peter Crighton wrote:

> I don’t know why the \bgr function causes it.
> Any ideas?
> ...
> Are there other places to learn about Scheme in LilyPond
> than the Scheme tutorial?


Welcome to Scheme in LilyPond.
This example shows that knowing Scheme isn't enough.
You have to cooperate with Lilypond,
and to do that successfully you have to know
how Lilypond does things (under the hood).


So read the whole LilyPond source code before you start!
Or maybe you can just peek at the seemingly relevant bits.

A more workable approach is to modify similar snippets.

How about a black box approach here?
You got a nice warning - very explicit, with location info.

Try simpler cases:
\new Voice << { c4 d r f } { e4 f r a } >>
doesn't complain,
but
\new Voice << { c4 d r f } { e4 f \tweak color #black r a } >>
does complain.
\new Voice << { c4 d e f } { e4 f e a } >>
shows both noteheads and doesn't complain,
and
\new Voice << { c4 d e f } { e4 f \tweak color #black e a } >>
also shows both noteheads and doesn't complain.

So it looks like LilyPond wants to merge the rests,
but will do this only if they seem identical.


Having read through the regression snippet
and been inspired by the way it removes things,
we can modify bgr to make it remove rests:

bgr = #(define-music-function (parser location music) (ly:music?)
  (music-map (lambda (mus)
    (if (music-is-of-type? mus 'rest-event)
      (make-music 'SkipEvent mus)
      #{
        \tweak NoteHead.font-size #-2
        \tweak Accidental.font-size #-2
        #mus
      #}))
    music ))

Note A: found 'rest-event in the Internals Reference
Note B: renamed your parameter to not imply just "note"

Hope this helps.


Cheers,
Robin



reply via email to

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