I would like to create a function which would automate some tempo changes in my score (it would be hidden on the score with something like \override Score.MetronomeMark #'transparent = ##t
, indeed the goal is to add a bit of expressiveness into the MIDI output).
I manage to add a tempo change on the score (with #(make-music 'TempoChangeEvent ...)
), but it doesn't affect the MIDI output, like \tempo
would do. But it is exactly what I would need though.
I tried to change the context property tempoWholesPerMinute
, but it does nothing at all.
\version "2.18.2"
\language "english"
mytempo = #(define-music-function (music) (ly:music?)
#{
#(make-music 'TempoChangeEvent
'metronome-count 180
'tempo-unit (ly:make-duration 2))
\applyContext #(lambda (context)
(ly:context-set-property! context
'tempoWholesPerMinute
(ly:make-moment 180 3)))
#music
#})
\score {
\new Staff \relative c' {
\mytempo c
d e f g
}
\layout {}
\midi {}
}
How can I change the MIDI tempo by using a custom function?