]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/adding-text-indications-to-metronome-marks.ly
Merge branch 'master' of ssh+git://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / input / lsr / adding-text-indications-to-metronome-marks.ly
1 %% Do not edit this file; it is auto-generated from input/new
2 %% This file is in the public domain.
3 \version "2.11.43"
4 \header {
5   lsrtags = "expressive-marks,text,tweaks-and-overrides"
6   texidoc = "
7 Using Scheme code to override the stencil for @code{MetronomeMark}
8 objects, this example allows the creation of metronome marks which include
9 text directions.  The function @code{\tempoChangeMarkup} is called with three
10 strings: the text label, note duration, and beats per minute.  To print the
11 new metronome mark, this is followed by the standard @code{\tempo} command.
12 "
13   doctitle = "Adding text indications to metronome marks"
14 } % begin verbatim
15
16 % Thanks to Alexander Kobel for this snippet
17
18 tempoMarkLabelSize = #0
19 tempoMarkNoteSize = #-6
20
21 #(define (tempoChangeMarkupFactory grob label noteValue tempo)
22  (interpret-markup
23   (ly:grob-layout grob)
24   (ly:grob-alist-chain grob (ly:output-def-lookup (ly:grob-layout grob) 'text-font-defaults))
25   (markup
26    #:fontsize tempoMarkLabelSize #:italic #:concat (label (if (string-null? label) "(" " (" ))
27    #:hspace -1
28    #:fontsize tempoMarkNoteSize #:general-align Y DOWN #:note noteValue UP
29    #:fontsize tempoMarkLabelSize #:italic #:concat( "= " tempo ")" )
30   )
31  ))
32
33 #(define (tempoChangeStencil label noteValue tempo)
34  (lambda (grob)
35   (tempoChangeMarkupFactory grob label noteValue tempo)
36  ))
37
38 tempoChangeMarkup = #(define-music-function (parser location label noteValue tempo) (string? string? string?)
39        #{
40          \once \override Score.MetronomeMark #'stencil = #(tempoChangeStencil $label $noteValue $tempo)
41        #})
42
43 \relative c' {
44   \time 4/4
45   \clef treble
46   % initialize the override
47   \tempoChangeMarkup #"Moderato" #"4" #"63"
48   % markup is printed
49   \tempo 4 = 63
50   c4 d e f
51   g a b c
52   \time 6/4
53   \mark \default
54   \tempoChangeMarkup #"presto" #"2." #"90"
55   \tempo 2. = 90
56   c2. g \break
57   e \tempoChangeMarkup #"handling collision with RehearsalMark" #"4" #"120" \tempo 4 = 120 c
58   \time 4/4
59   \mark \default
60   c1
61 }