- [Class]
midi-tempo-change
A MIDI tempo change event.
midi-tempo-change
supports the following
slot initializations:
:time
number- The start time of the object.
:usecs
integer- Number of microseconds (usecs) per MIDI quarter note. See Example 2 for how to convert musical tempo to usecs.
Examples:
Example 1. The midi-tempo-change
event.
;;; tempo 120 quarters per minute (new midi-tempo-change :time 0 :usecs 500000) ;;; tempo 90 quarters per minute (new midi-tempo-change :time 0 :usecs 666667)
Example 2. Converting quarter notes per minute to usecs.
(define (qpm->usecs bpm ) (inexact->exact (round (* (/ 60 bpm) 1000000)))) (define (accel num tempo1 tempo2) ;; accelerate in num quarters from tempo1 to tempo2 (process for i below num for r = (interp i 0 tempo1 (- num 1) tempo2) output (new midi-tempo-change :time (now) :usecs (qpm->usecs r)) output (new midi :time (now) :duration .5 :keynum (between 60 72)) wait 1)) (events (accel 20 60 240) "test.mid") ⇒ "test.mid"
See also:
- MIDI event classes [Topic]