Klaus Blum wrote:
> 
> A quick and dirty approach would be to remove the Rest_engraver from the
> second voice:

Yes, this works. 

> If you look for an automatic solution that detects if both voices have the
> same rests, go for the merge-rests-engraver already mentioned by Harm. 
> AFAIK the most recent version is here:
> https://github.com/openlilylib/openlilylib/tree/master/editorial-tools/merge-rests-engraver

The merge-rests-engraver solutions (written by Jay Anderson,
apparently) would clearly be the best solution to the problem, as it
solves the general case (i.e., when some rests are in common and some
are not). I hope that this will become a part of the standard library
in the future. It might even make sense to turn it on by default.

However, a significant problem with Jay's code is that it too doesn't
work correctly with dotted rests.

%---------------------------------------- 
\version "2.19.25"

\include "definition.ily"

\layout {
  \context { \Staff \consists #merge-rests-engraver }
  \context { \Staff \consists #merge-mmrests-engraver }
}

\new Staff <<
  \new Voice {
    \relative c'' {
      \voiceOne
      r  c  r  d | r2. e4
      d2. e4
    }
  }
  \new Voice {
    \relative c'' {
      \voiceTwo
      r4 a8 a8 r4 b8 b8 | r2. c4
      c2. a4
    }
  }
>>
%----------------------------------------

Here, the definition.ily that I have included is the latest version
from the above github link.  The output (see rests4.pdf) still shows
two dots for each of the merged dotted rests.

So it's the same problem in disguise. It seems that Jay's code, rather
than turning the redundant rests into spacers, prints them all on top
of each other, resulting in the multiple dots since the
Dot_column_engraver doesn't understand that the rests have been
merged.

My guess is that the part of the code that says

  (for-each
   (lambda (rest)
     (ly:grob-set-property! rest 'Y-offset 0))
   rests))))

should be changed: rather than just setting all the Y-offsets to 0,
all rests except the first one in the list should be disabled
completely, and preferably turned into spacers so that there will be
no dots associated with them.

But I don't know enough about internals to know how to do that.

-- Peter

Attachment: rests4.pdf
Description: PDF document, version 1.4

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

Reply via email to