Hi Peter,

On Sat, Oct 25, 2014 at 10:41 AM, Peter Crighton <petecrigh...@gmail.com>
wrote:

> 2014-10-24 23:01 GMT+02:00 Peter Crighton <petecrigh...@gmail.com>:
>
>> 2014-10-24 16:54 GMT+02:00 Robin Bannister <r...@dataway.ch>:
>>
>>> 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.
>>
>>
>> Thanks again, Robin, this helps a lot!
>>
>> The next time I dive into Scheming I might be getting further by myself
>> before I have to ask on the list. :)
>>
>
> Nope, I didn’t really and have to ask again, sorry …
>
> I now wanted to improve the function to also skip MultiMeasureRests and
> first tried replacing 'rest-event with 'multi-measure-rest-event to see if
> that would work, which it doesn’t.
>
>
Yes, this was a stumbling block for me too recently.  It doesn't seem that
you can use 'multi-measure-rest-event with music-is-of-type?  This approach
will work, though:

 \version "2.19.15"

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

\new Voice <<
  \relative c' {
    c4 d r f
    R1
    c4 d r f
  }

  \relative c' \bgr {
    e4 f r a
    R1
    e4 f r a
  }
>>

%%%

--David
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to