Am 10.04.2015 um 23:05 schrieb Urs Liska:


Am 10.04.2015 um 01:29 schrieb Urs Liska:


Am 08.04.2015 um 10:18 schrieb Mark Knoop:
At 09:35 on 08 Apr 2015, Urs Liska wrote:
Am 8. April 2015 08:28:47 MESZ, schrieb Urs Liska <u...@openlilylib.org>:
Hi all,

what is the most viable approach to suppress all the doubled items
like makuos,
markups

dynamics etc. that are produced by the partcombiner?
Perhaps the merge-rests-engraver in OLL is adaptable?


I could now look at that code, and it seems promising. Provided it can perform its action later than the partcombiner. But I think this should be the case. Unfortunately I'm not sure yet if I manage to make that work. In any case I don't think I'll be able to adapt it to spanners because that would require a significant additional layer of housekeeping compared to "simple" markups.

OK, I've done a very primitive rewriting of the merge-rests-engraver, as can be seen in the attachment. Surprisingly the file compiled without real errors on first try, but it issued a warning "

Sorry, hit the wrong keyboard shortcut ;-(

The file issued the warning:

warning: unknown translator: `merge-markups-engraver'

warning: cannot find: `merge-markups-engraver'

and produced "normal" output.

Can anyone point me to the right direction to make this "engraver" noticed by the \score?

Thanks
Urs


\version "2.18.0"

\header {
  snippet-title = "merge-rests-engraver"
  snippet-author = "Jay Anderson"
  snippet-source =
    "http://www.mail-archive.com/lilypond-user%40gnu.org/msg69608.html";
  snippet-description = \markup {
    Merge rests of equal duration in different voice
  }
  tags = "merge, rest, rests, voice, voices"
  status = "ready"
}

#(define has-one-or-less (lambda (lst) (or (null? lst) (null? (cdr lst)))))
#(define has-at-least-two (lambda (lst) (not (has-one-or-less lst))))
#(define (all-equal lst pred)
   (or (has-one-or-less lst)
       (and (pred (car lst) (cadr lst)) (all-equal (cdr lst) pred))))

#(define merge-markups-engraver
   (lambda (context)
     (let ((markups-equal?
            (lambda (markup-a markup-b)
              (string=? 
               (markup->string markup-a)
               (markup->string markup-b))))
           (markups '()))
       `((start-translation-timestep . ,(lambda (trans)
                                          (set! markups '())))
         (stop-translation-timestep . ,(lambda (trans)
                                         (if (and (has-at-least-two markups) 
                                                  (all-equal markups 
markups-equal?))
                                             (for-each
                                              (lambda (mkup)
                                                (ly:grob-set-property! mkup 
'Y-offset 0))
                                              mkup))))
         (acknowledgers
          (text-interface . ,(lambda (engraver grob source-engraver)
                               (if (eq? 'Markup (assoc-ref
                                               (ly:grob-property grob 'meta) 
'name))
                                   (set! markups (cons grob markups))))))))))


\score {
  \new Staff \with {
    \consists merge-markups-engraver
  }
  <<
    \new Voice {
      \voiceOne
      c''^\markup "Test"
    }
    \new Voice {
    \voiceTwo
    c'_\markup "Test"
    }
  >>
  \layout {}
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to