lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custon MMR engraver - another issue


From: Thomas Morley
Subject: Re: Custon MMR engraver - another issue
Date: Tue, 7 Jan 2020 11:27:38 +0100

Hi Craig,

Am Mo., 6. Jan. 2020 um 11:05 Uhr schrieb Thomas Morley
<address@hidden>:
>
> Am Mo., 6. Jan. 2020 um 04:16 Uhr schrieb Craig Dabelstein <address@hidden>:
>>
>> Hi again,
>>
>> When using lilypond on the command line, and trying to engrave multiple 
>> files, the multi measure rest engraver is giving this error when it moves to 
>> the second file on the list:
>>
>> /Applications/LilyPond\ 2.19.83.app/Contents/Resources/bin/lilypond 
>> -dpoint-and-click -ddelete-intermediate-files --pdf *.ly
>>
>> fatal error: symbol printMmrRange redefined
>>
>> I've been using trial and error to try to find the problem but I really 
>> don't know where to look. Anh ideas?
>
> Well, I defined a custom context-property for this engraver and implemented a 
> fatal error, if this property is redefined  Following the method in 
> define-context-properties.scm.
> You trigger this error if you compile multiple files containing the 
> definition.
> This is a security-net, we shouldn't throw it away.
> We could avoid it, if we actually reset `all-translation-properties´, though, 
> some time ago David K. warned to do so, iirc.
> I have to admit I don't remember the reasoning, though usually he has good 
> ones...
>
> I'll think about how to circumvent the problem.
>
> Cheers,
>   Harm
>

below you'll find an improved version.
Instead of defining a context-property, I use 'print-range as
subproperty of 'details of MultiMeasureRestNumber

You can now switch on/off by setting
\override MultiMeasureRestNumber.details.print-range = ##t or ##f
Of course you could define some shortcuts for them.

HTH,
  Harm

%% 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
    \column {
       \halign #0 #(number->string (- stop start))
%       %% value found by try and error
       \translate-scaled #'(0 . -6.5)
       \with-dimensions #empty-interval #empty-interval
       \halign #0
       \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)
                (let* ((details (ly:grob-property grob 'details))
                       (print-range? (assoc-get 'print-range details)))
                  (set! m-m-r-print
                    (cons (cons grob print-range?) 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 \override MultiMeasureRestNumber.details.print-range = ##f
    R2.*15
    c'2.
    R2.*15
    c'2.
  }
  \layout {
    \context {
      \Voice
      \consists #mmr-range-engraver
      \override MultiMeasureRestNumber.details.print-range = ##t
    }
  }
}

\score {
  {
    \time 3/4
    c'2.
    \compressFullBarRests
    R2.*14
    c'2.
    \once \override MultiMeasureRestNumber.details.print-range = ##t
    R2.*15
    c'2.
    R2.*15
    c'2.
  }
  \layout {
    \context {
      \Voice
      \consists #mmr-range-engraver
      \override MultiMeasureRestNumber.details.print-range = ##f
    }
  }
}

\score {
  {
    \time 3/4
    c'2.
    \compressFullBarRests
    R1*3/4*14
    c'2.
  }
  \layout {
    \context {
      \Voice
      \consists #mmr-range-engraver
      \override MultiMeasureRestNumber.details.print-range = ##t
    }
  }
}

\score {
  {
    c'1
    \compressFullBarRests
    R1*14
    c'1
  }
  \layout {
    \context {
      \Voice
      \consists #mmr-range-engraver
      \override MultiMeasureRestNumber.details.print-range = ##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
      \override MultiMeasureRestNumber.details.print-range = ##t
    }
  }
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]