lilypond-devel
[Top][All Lists]
Advanced

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

Suggestion: tempo ranges


From: John Zaitseff
Subject: Suggestion: tempo ranges
Date: Thu, 9 Oct 2008 10:25:05 +1100
User-agent: Mutt/1.5.13 (2006-08-11)

Dear LilyPond developers,

I don't know how much of a pain this would be to add (especially at
this stage of development), but would it be possible to include
ranges in tempo definitions?  I've done a quick search of the
mailing list, but cannot see that anyone else has suggested this.

A lot of music I am transcribing has tempo annotations of the form
"dotted quarter note = 92-96".  I would like to enter something like the
following in LilyPond:

  \tempo 4. = 92-96

Currently (using LilyPond 2.10.33), I get around this by creating a
custom music function, \tempoRange, then entering:

  \tempoRange #"4." #'(92 . 96)

Not as nice syntactically!  The appropriate function definition is:

  % \tempoRange #"duration" #'(lower . upper) - insert a tempo mark with range
  tempoRange =
      #(define-music-function (parser location duration lower-upper) (string? 
number-pair?)
          "Insert a tempo mark containing a range of numbers (from @var{lower} 
to
  @var{upper}) for duration @var{duration}.  Note that @var{duration} is a 
string,
  the same as is used with @code{\\note}.  For example, @code{\\tempoRange
  #\"4.\" #'(92 . 96)} creates a tempo range of between 92 and 96 dotted quarter
  notes per minute.  The actual MIDI tempo is set to 94 (mid-way between 92 and
  96)."
          (let* ((lower  (car lower-upper))
                 (upper  (cdr lower-upper))
                 (mid    (/ (+ lower upper) 2))
                 (parsed (parse-simple-duration duration))
                 (log    (car parsed))
                 (dots   (cadr parsed))
                 (n      (* mid (1- (integer-expt 2 (1+ dots)))))
                 (d      (integer-expt 2 (+ log dots))))
              #{
                  \set Score.tempoWholesPerMinute = #(ly:make-moment (round $n) 
$d)
                  \once \override TextScript #'word-space = #0
                  s4*0^\markup {
                      \hspace #0
                      \smaller {
                          \general-align #Y #DOWN \note #$duration #1
                      }
                      " = "
                      \simple
                          #(if (= $lower $upper)
                              (ly:number->string $lower)
                              (string-append (ly:number->string $lower)
                                             (ly:wide-char->utf-8 #x2013)
                                             (ly:number->string $upper)))
                  }
              #}))

(The function "parse-simple-duration" is the same as is found in the
file scm/define-markup-commands.scm).

If the idea meets with your approval, I can investigate writing a
patch for it, in a way that (hopefully) does not break anything
else.

Yours truly,

John Zaitseff

-- 
John Zaitseff                    ,--_|\    The ZAP Group
Phone:  +61 2 9643 7737         /      \   Sydney, Australia
E-mail: address@hidden   \_,--._*   http://www.zap.org.au/
                                      v




reply via email to

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