lilypond-user
[Top][All Lists]
Advanced

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

Re: custom metronome-markup procedure causes weird goops-error


From: Nicolas Sceaux
Subject: Re: custom metronome-markup procedure causes weird goops-error
Date: Tue, 29 Apr 2008 12:53:07 +0200


Le 29 avr. 08 à 11:52, Reinhold Kainhofer a écrit :

Am Freitag, 25. April 2008 schrieb Valentin Villenave:
Second, unlike the helper function parse-simple-duration,
string->duration doesn't account for durations longer than a semibreve
since they can't be directly converted to a number.

Ideal answer: oh yes, that is definitely a limitation.
Pragmatic answer : hmm, do we really need \breve in metronome marks?

Lilypond-style answer: Show me an example:
http://kainhofer.com/~lilypond/input/regression/musicxml/collated-files.html#03c-MetronomeMarks.ly

For the record, here is a version without the breve limitation,
and with nicer style.

#(define ((make-format-movement-markup-function text) duration count context)
   (markup #:huge #:bold text #:hspace 1
             #:concat ("(" #:general-align Y DOWN #:smaller
                         #:note-by-number (ly:duration-log duration)
(ly:duration-dot-count duration)
                                          1)
             "="
             #:concat ((number->string count) ")")))

#(define (string->duration duration-string)
"Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a duration object."
  (let* ((length (string-length duration-string))
         (dot-index (or (string-index duration-string #\.) length))
         (len (substring duration-string 0 dot-index))
         (dots (- length dot-index)))
   (ly:make-duration (cond ((string=? len "breve") -1)
                           ((string=? len "longa") -2)
                           ((string=? len "maxima") -3)
                           (else (log2 (string->number len))))
                     dots 1 1)))

movement =
#(define-music-function (parser location text duration count music)
                        (string? string? integer? ly:music?)
  #{
\set Score . metronomeMarkFormatter = #(make-format-movement- markup-function $text) \set Score . tempoWholesPerMinute = #$(ly:duration-length (string- >duration duration))
    \set Score . tempoUnitDuration = #$(string->duration duration)
    \set Score . tempoUnitCount = #$count
    $music
    \set Score . metronomeMarkFormatter = #format-metronome-markup
  #})

\relative c' {
  \time 3/4
  \movement "Allegro" "2." #96
  c2 e4 g2.
  \movement "Moderato" "4" #104
  f4 e d
  \tempo 4 = 92
  c2.
}






reply via email to

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