[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multi-rest with automatic bar number before and after it
From: |
Thomas Morley |
Subject: |
Re: Multi-rest with automatic bar number before and after it |
Date: |
Sat, 20 Feb 2016 13:41:43 +0100 |
2016-02-19 4:23 GMT+01:00 Craig Dabelstein <address@hidden>:
> Hi Harm,
>
> I discovered a problem. It works perfectly with 4/4 time but it doesn't work
> with other time signatures. Can you suggest to me how I can make it work for
> different time signatures?
>
> All the best,
>
> Craig
I found no way to make it work with all possible \time-settings via \applyOutput
Hence the engraver below. (Also attached.)
Formating is done in a scheme-function `formatMMRNumber'. Thanks David
for the hint to `translated-scale'
Printing of the range may be enabled/disabled by setting the new
defined context-property `printMmrRange'.
Some remarks/TODOs, especially:
Why I cannot _create_ a MultiMeasureRestText-grob via `ly:engraver-make-grob'?
It works for TextScript ...
\version "2.19.36"
%% 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 {
#(number->string (1+ start))
" - "
#(number->string stop)
}
}
#})
%% TODO
%% I didn't manage to _create_ a MultiMeasureRestText-grob via
%% `ly:engraver-make-grob'
%% How to do?
%% It worked with simple TextScript ...
#(define (mmr-range-engraver context)
"Print the range of a @code{MultiMeasureRest}, if the context-property
@code{printMmrRange} is set @code{#t}."
(let ((m-m-r-print '()))
`((acknowledgers
(multi-measure-interface
. ,(lambda (engraver grob source-engraver)
(if (eq? (grob::name grob) 'MultiMeasureRestNumber)
(set! m-m-r-print
(cons
(cons grob (ly:context-property context 'printMmrRange))
m-m-r-print))))))
(finalize
.
,(lambda (trans)
(let* ((timeSignatureFraction
(ly:context-property context 'timeSignatureFraction))
(fraction
(/ (car timeSignatureFraction) (cdr timeSignatureFraction))))
(for-each
(lambda (mmr)
(if (and (cdr mmr) (not (null? (cdr mmr))))
(let* ((m-m-r-start
(/ (ly:moment-main
(grob::when (ly:spanner-bound (car mmr) LEFT)))
fraction))
(m-m-r-stop
(/ (ly:moment-main
(grob::when (ly:spanner-bound (car mmr) RIGHT)))
fraction)))
(ly:grob-set-property! (car mmr) 'text
(formatMMRNumber m-m-r-start m-m-r-stop)))))
m-m-r-print)
(set! m-m-r-print '())))))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\layout {
\override Score.BarNumber.break-visibility = ##(#t #t #t)
}
\score {
{
\time 3/4
c'2.
\compressFullBarRests
R2.*14
c'2.
\once \unset printMmrRange
R2.*15
c'2.
R2.*15
c'2.
}
\layout {
\context {
\Voice
\consists #mmr-range-engraver
printMmrRange = ##t
}
}
}
\score {
{
\time 3/4
c'2.
\compressFullBarRests
R2.*14
c'2.
\once \set printMmrRange = ##t
R2.*15
c'2.
R2.*15
c'2.
}
\layout {
\context {
\Voice
\consists #mmr-range-engraver
printMmrRange = ##f
}
}
}
\score {
{
\time 3/4
c'2.
\compressFullBarRests
R1*3/4*14
c'2.
}
\layout {
\context {
\Voice
\consists #mmr-range-engraver
printMmrRange = ##t
}
}
}
\score {
{
c'1
\compressFullBarRests
R1*14
c'1
}
\layout {
\context {
\Voice
\consists #mmr-range-engraver
printMmrRange = ##t
}
}
}
\score {
{
\time 5/8
c'2 c'8
\compressFullBarRests
R1*5/8*14
c'2 c'8
R1*5/8*13
c'2 c'8
}
\layout {
\context {
\Voice
\consists #mmr-range-engraver
printMmrRange = ##t
}
}
}
HTH,
Harm
print-MMR-range-engraver-01.png
Description: PNG image
print-MMR-range-engraver-01.ly
Description: Text Data
- Re: Multi-rest with automatic bar number before and after it, (continued)
- Re: Multi-rest with automatic bar number before and after it, Kieren MacMillan, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, tisimst, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Thomas Morley, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Craig Dabelstein, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, tisimst, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Kieren MacMillan, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Craig Dabelstein, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Thomas Morley, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Craig Dabelstein, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it, Craig Dabelstein, 2016/02/18
- Re: Multi-rest with automatic bar number before and after it,
Thomas Morley <=
- Re: Multi-rest with automatic bar number before and after it, Craig Dabelstein, 2016/02/21
- Re: Multi-rest with automatic bar number before and after it, David Kastrup, 2016/02/19