]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/integrating-text-indications-in-metronome-marks.ly
Split WWW target in two stages WWW-1 and WWW-2
[lilypond.git] / input / lsr / integrating-text-indications-in-metronome-marks.ly
1 %% Do not edit this file; it is auto-generated from LSR http://lsr.dsi.unimi.it
2 %% This file is in the public domain.
3 \version "2.11.46"
4
5 \header {
6   lsrtags = "rhythms, text"
7
8   texidoc = "
9 This function allows you to change the tempo and specify text
10 directions at the same time, using one single command.It takes three
11 arguments: the text to be printed (the string has to be introduced with
12 a # character), the duration (it has to be specified as a text string,
13 between double quotes and with a #), and the metronome tempo (as a
14 number). This way, the given tempo will be taken into account in MIDI
15 output, but the normal @code{\\tempo} command will remain unaffected. 
16
17 "
18   doctitle = "Integrating text indications in metronome marks"
19 } % begin verbatim
20 #(define ((make-format-movement-markup-function text) duration count context)
21  (markup #:huge #:bold text #:hspace 1
22          "("
23          #:general-align Y DOWN #:smaller
24             #:note-by-number (ly:duration-log duration)
25                              (ly:duration-dot-count duration)
26                              1
27          "="
28          (number->string count)
29          ")"))
30
31
32 #(define (string->duration duration-string)
33  "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a duration object."
34  (let* ((length (string-length duration-string))
35         (dot-index (or (string-index duration-string #\.) length))
36         (len (substring duration-string 0 dot-index))
37         (dots (- length dot-index)))
38   (ly:make-duration (cond ((string=? len "breve") -1)
39                           ((string=? len "longa") -2)
40                           ((string=? len "maxima") -3)
41                           (else (log2 (string->number len))))
42                     dots 1 1)))
43
44 movement =
45 #(define-music-function (parser location text duration count music)
46
47                        (string? string? integer? ly:music?)
48  #{
49    \set Score.metronomeMarkFormatter = #(make-format-movement-markup-function $text)
50    \set Score.tempoWholesPerMinute = #$(ly:moment-mul (ly:make-moment count 1)
51                                          (ly:duration-length
52                                            (string->duration duration)))
53    \set Score.tempoUnitDuration = #$(string->duration duration)
54    \set Score.tempoUnitCount = #$count
55    $music
56    \set Score.metronomeMarkFormatter = #format-metronome-markup
57  #})
58
59 \layout { ragged-right = ##f }
60
61 \relative c' {
62   \time 3/4
63   \movement "Allegro" "2." #96
64   c2 e4
65   g2.
66   \movement "Moderato" "4" #104
67   f4 e d
68   \tempo 4 = 92
69   c2.
70 }