Nice workaround for simultaneous rehearsal marks – thanks Neil!

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Nice workaround for simultaneous rehearsal marks – thanks Neil!

Xavier Scheuer
Hi,

I have had a nice conversation with Neil, in which I said that

  "Within my "Most Annoying everyday-use Issues" there is also the fact
  that it is not possible to have two simultaneous rehearsal marks (and
  the workaround of LSR #575 is really dirty

the result of which Neil creates a nice workaround that permits to have
simultaneous rehearsal marks and —the icing* on the cake— it allows
these rehearsal marks to have different settings.

[*] in French we say "the _cherry_ on the cake".

Very useful if you want one rehearsal mark at the end of a line with
some settings and another one at the begin of the following line with
different settings (see example below for right aligned "to coda" and
at the following line a normal \mark \default).
It also allows to print two rehearsal marks above and below the same
barline.

IMHO that could replace easily the different workarounds one can find:
http://lsr.dsi.unimi.it/LSR/Item?id=575
http://lsr.dsi.unimi.it/LSR/Item?id=202
http://lsr.dsi.unimi.it/LSR/Item?id=735
http://lsr.dsi.unimi.it/LSR/Item?id=736

%%%% Snippet

\version "2.15.8"

#(define (multi-mark-engraver ctx)
   (let ((texts '())
         (final-texts '())
         (events '()))

     `((start-translation-timestep
        . ,(lambda (trans)
             (set! final-texts '())))

       (listeners
        (mark-event
         . ,(lambda (trans ev)
              (set! events (cons ev events)))))

       (acknowledgers
        (break-alignment-interface
         . ,(lambda (trans grob source)
              (for-each (lambda (mark)
                          (set! (ly:grob-parent mark X) grob))
                        texts))))

       (process-music
        . ,(lambda (trans)
             (for-each
              (lambda (ev)
                (let* ((mark-grob
                        (ly:engraver-make-grob trans 'RehearsalMark ev))
                       (label (ly:event-property ev 'label))
                       (formatter (ly:context-property ctx 'markFormatter)))

                  (if (and (procedure? formatter)
                           (not (markup? label)))
                      (begin
                       (if (not (number? label))
                           (set! label
                                 (ly:context-property ctx 'rehearsalMark)))

                       (if (and (integer? label)
                                (exact? label))
                           (set! (ly:context-property ctx 'rehearsalMark)
                                 (1+ label)))

                       (if (number? label)
                           (set! label (apply formatter (list label ctx)))
                           (ly:warning "rehearsalMark must have
integer value"))))

                  (if (markup? label)
                      (begin
                       (set! (ly:grob-property mark-grob 'text) label)
                       (let ((dir (ly:event-property ev 'direction)))
                         (and (ly:dir? dir)
                              (set! (ly:grob-property mark-grob 'direction)
                                    dir))))
                      (ly:warning "mark label must be a markup object"))

                  (set! texts (cons mark-grob texts))))
              (reverse events))))

       (stop-translation-timestep
        . ,(lambda (trans)
             (if (pair? texts)
                 (let ((staves (ly:context-property ctx 'stavesFound))
                       (priority-index 0))
                   (for-each (lambda (grob)
                               (let ((my-priority (ly:grob-property
grob 'outside-staff-priority 1500)))
                                 (for-each (lambda (stave)

(ly:pointer-group-interface::add-grob grob 'side-support-elements
                                               stave))
                                           staves)
                                 (set! (ly:grob-property grob
'outside-staff-priority) (+ my-priority priority-index))
                                 (set! priority-index (1+ priority-index))
                                 (set! final-texts (cons grob final-texts))))
                             (reverse texts))
                     (set! texts '())
                     (set! events '())))))

        (finalize
         . ,(lambda (trans)
              (and (pair? final-texts)
                   (for-each (lambda (grob)
                               (set! (ly:grob-property grob 'break-visibility)
                                     end-of-line-visible))
                             final-texts)))))))

\layout {
 \context {
   \Score
   \remove "Mark_engraver"
   \consists #multi-mark-engraver
   \consists "Tweak_engraver"
 }
}

markDown =
#(define-music-function (parser location text) (markup?)
   (make-music 'MarkEvent
               'direction DOWN
               'label text))

myMark =
#(define-music-function (parser location text) (markup?)
  (make-music 'MarkEvent
              'label text))

toCoda = {
 \tweak #'self-alignment-X #RIGHT
 \tweak #'break-visibility #begin-of-line-invisible
 \myMark \markup { to \hspace #1.25 \raise #1.25 \musicglyph #"scripts.coda" }
}

\relative c' {
 c1 | c | c | c \toCoda
 \bar "||" \break
 \mark \default
 c1 | c |
 \mark \default
 \markDown "23"
 c | c
}

%%%% End of snippet

Cheers,
Xavier

--
Xavier Scheuer <[hidden email]>

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

RE: Nice workaround for simultaneous rehearsal marks – thanks Neil!

pkx166h-2
Hello,
________________________________________
From: lilypond-user-bounces+james.lowe=[hidden email] [lilypond-user-bounces+james.lowe=[hidden email]] on behalf of Xavier Scheuer [[hidden email]]
Sent: 07 August 2011 16:09
To: lilypond-user
Subject: Nice workaround for simultaneous rehearsal marks – thanks Neil!

--snip--

It also allows to print two rehearsal marks above and below the same
barline.

IMHO that could replace easily the different workarounds one can find:
http://lsr.dsi.unimi.it/LSR/Item?id=575
http://lsr.dsi.unimi.it/LSR/Item?id=202
http://lsr.dsi.unimi.it/LSR/Item?id=735
http://lsr.dsi.unimi.it/LSR/Item?id=736

--snip--

Yes once the LSR is updated to 2.16.x (assuming LSR doesn't run unstable - this snippet won't work on 2.14.1 (does it on 2.14.2?)

However I still think we need to be careful that we don't leave our 2.12.x and 2.14.x cousins behind and without a solution for simultaneous Rehearsal Marks It is an annoyance I grant you, but it's less of an annoyance than having to upgrade all your scores *just* to use this when the workarounds are not 'that' bad.

James
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

RE: Nice workaround for simultaneous rehearsal marks – thanks Neil!

Thomas Morley
pkx166h wrote
Subject: Nice workaround for simultaneous rehearsal marks – thanks Neil!

Yes once the LSR is updated to 2.16.x (assuming LSR doesn't run unstable - this snippet won't work on 2.14.1 (does it on 2.14.2?)

James
Hi,

great work!! Compiles fine on 2.14.2!

Cheers,
  Harm