Hi there,
There was this thread last February
https://lists.gnu.org/archive/html/lilypond-user/2016-02/msg00505.html
which ended up with a fully working custom MMR range engraver that
prints the first and last bar number of Multi-measure rests.
Correct me if I'm wrong but I think this code is mainly from Thomas Morley.
I've been using it for a little while now and I'm trying to fix an
issue with it.
The way the range get displayed *under* the staff seems hackish.
_this line :
\translate #'(0 . -7.5)
does not work y<0 because (I suppose) there is a collision with the
staff itself.
I suspect that, to overcome this limitation and thus being able to
print *bellow* the staff, _this line was added to make the object have
no dimensions at all thus no collision.
\with-dimensions #empty-interval #empty-interval
The problem with this is, as shown in the image attached, that there
is no skylines around the grob an thus collisions happens in the score
with adjacent systems.
I suspect the way to go with this is to make this markup go bellow the
staff in the first place.
How would you go about doing that?
In the hope of being clear enough.
I'm more that happy to be corrected as I am using most terms rather
loosely (grob, markup, engraver, etc).
--
Pierre-Luc Gauthier
\version "2.21.0"
%% define the custom context-property `printMmrRange'
#(define (define-translator-property symbol type? description)
(if (not (and (symbol? symbol)
(procedure? type?)
(string? description)))
(ly:error "error in call of define-translator-property"))
(if (not (equal? (object-property symbol 'translation-doc) #f))
(ly:error (_ "symbol ~S redefined") symbol))
(set-object-property! symbol 'translation-type? type?)
(set-object-property! symbol 'translation-doc description)
symbol)
#(for-each
(lambda (x)
(apply define-translator-property x))
`((printMmrRange
,boolean?
"Print range of a MultiMeasureRest")))
%% define how to format `start' and `stop'
%% for `MultiMeasureRestNumber' in the engraver
%% TODO find a method to set the values for `translate-scaled'
formatMMRNumber =
#(define-scheme-function (start stop)(integer? integer?)
#{
\markup
\center-column {
#(number->string (- stop start))
%% value found by try and error
\translate-scaled #'(0 . -6.5)
\with-dimensions #empty-interval #empty-interval
\halign #CENTER
\normal-text
\fontsize #-2
\line {
\concat {
"("
#(number->string start)
".."
#(number->string (1- stop))
")"
}
}
}
#})
#(define (mmr-range-engraver context)
"Print the range of a @code{MultiMeasureRest}, if the context-property
@code{printMmrRange} is set @code{#t}."
(let ((print-mmr-nmbr-list '())
(mmr-bar-numbr-list '()))
`((acknowledgers
(multi-measure-interface
.
,(lambda (engraver grob source-engraver)
(if (eq? (grob::name grob) 'MultiMeasureRestNumber)
(set! print-mmr-nmbr-list
(cons
(cons
grob
(ly:context-property context 'printMmrRange #f))
print-mmr-nmbr-list)))
(if (eq? (grob::name grob) 'MultiMeasureRest)
(begin
(set! mmr-bar-numbr-list
(cons
(cons
grob
(ly:context-property context 'currentBarNumber))
mmr-bar-numbr-list)))))))
(finalize
.
,(lambda (trans)
(for-each
(lambda (mmr mmr-nmbr)
(let ((measure-count (ly:grob-property (car mmr) 'measure-count)))
(if (and (cdr mmr-nmbr) (> measure-count 1))
(ly:grob-set-property! (car mmr-nmbr) 'text
(formatMMRNumber
(cdr mmr)
(+ measure-count (cdr mmr)))))))
mmr-bar-numbr-list
print-mmr-nmbr-list)
(set! print-mmr-nmbr-list '())
(set! mmr-bar-numbr-list '()))))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\layout {
\context {
\Voice
\consists #mmr-range-engraver
printMmrRange = ##t
}
}
\relative c' {
\compressFullBarRests
R1*7
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user