0% found this document useful (0 votes)
23 views2 pages

Lilypond Double Mark Example

The document defines functions for creating music property descriptions and double rehearsal marks in LilyPond. It creates properties for left and right labels of rehearsal marks, defines a stencil for double rehearsal marks that positions left and right labels, and defines a double-rehearsal-mark function that takes left and right strings/markups and generates the appropriate music objects.

Uploaded by

Grindelwald
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Lilypond Double Mark Example

The document defines functions for creating music property descriptions and double rehearsal marks in LilyPond. It creates properties for left and right labels of rehearsal marks, defines a stencil for double rehearsal marks that positions left and right labels, and defines a double-rehearsal-mark function that takes left and right strings/markups and generates the appropriate music objects.

Uploaded by

Grindelwald
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#(define-public (string-or-markup-or-boolean?

e)
(or (string? e) (markup? e) (boolean? e)))

#(define (music-property-description symbol type? description)


(if (not (equal? #f (object-property symbol 'music-doc)))
(ly:error (_ "symbol ~S redefined") symbol))
(set-object-property! symbol 'music-type? type?)
(set-object-property! symbol 'music-doc description)
symbol)

#(for-each
(lambda (x)
(apply music-property-description x))
`((left-label
,string-or-markup-or-boolean?
"set the left part of a RehearsalMark")
(right-label
,string-or-markup-or-boolean?
"set the right part of a RehearsalMark")
))

#(define (double-rehearsalmark-stencil grob)


(let*
((grobs-event (ly:grob-property grob 'cause '()))
(left-label (ly:event-property grobs-event 'left-label))
(right-label (ly:event-property grobs-event 'right-label))
(gap (ly:grob-property grob 'gap 1.4)))
(if (not (or (null? left-label) (null? right-label)))
(case (ly:item-break-dir grob)
((-1)
(if (boolean? left-label) empty-stencil
(grob-interpret-markup grob
(make-right-align-markup left-label))))
((1)
(if (boolean? right-label) empty-stencil
(grob-interpret-markup grob
(make-left-align-markup right-label))))
(else
(if (boolean? left-label)
(grob-interpret-markup grob
(if left-label
(make-center-align-markup right-label)
(make-left-align-markup right-label)))
(if (boolean? right-label)
(grob-interpret-markup grob
(if right-label
(make-center-align-markup left-label)
(make-right-align-markup left-label)))
(ly:stencil-add
(ly:stencil-translate
(grob-interpret-markup grob
(make-right-align-markup left-label))
(cons (* -0.5 gap) 0.0))
(ly:stencil-translate
(grob-interpret-markup grob
(make-left-align-markup right-label))
(cons (* 0.5 gap) 0.0)))))))
(begin
(ly:warning "\"doubleMark stencil\" did not find \"doubleMark texts\".")
(ly:warning "fallback to using \"ly:text-interface::print\".")
(ly:text-interface::print grob)))))

doubleMark =
#(define-music-function
(left-string right-string)
(string-or-markup-or-boolean? string-or-markup-or-boolean?)
(if (and (boolean? left-string) (boolean? right-string))
(ly:warning "~a \\doubleMark - at least one string or markup required"
(*location*)))
(make-music 'SequentialMusic
'elements (list
(make-music 'ContextSpeccedMusic
'context-type 'Score
'element
(make-music 'OverrideProperty
'symbol 'RehearsalMark
'grob-value double-rehearsalmark-stencil
'grob-property-path (list 'stencil)
'pop-first #t
'once #t))
(make-music 'ContextSpeccedMusic
'context-type 'Score
'element
(make-music 'OverrideProperty
'symbol 'RehearsalMark
'grob-value #f
'grob-property-path (list 'self-alignment-X)
'pop-first #t
'once #t))
(make-music 'ContextSpeccedMusic
'context-type 'Score
'element
(make-music 'OverrideProperty
'symbol 'RehearsalMark
'grob-value `#(,(not (boolean? left-string))
#t
,(not (boolean? right-string)))
'grob-property-path (list 'break-visibility)
'pop-first #t
'once #t))
(make-music 'MarkEvent
'label #f
'left-label (if (string? left-string)
(make-simple-markup left-string)
left-string)
'right-label (if (string? right-string)
(make-simple-markup right-string)
right-string)
'origin (*location*)))))

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy