[Class]
midi-time-signature

A MIDI time signature event.

midi-time-signature supports the following slot initializations:

:time number
The start time of the object.
:numerator integer
The beats-per-measure (upper number) of the time signature.
:denominator integer
The type of beat (lower number) of the time signature.
:clocks integer
The number of "MIDI clocks" between metronome clicks. There are 24 MIDI clocks in one quarter note.
:32nds integer
The number of notated 32nds in 24 MIDI clocks. The default value is 8.

Examples:

Example 1. The midi-time-signature event.

;;; 4/4 with metronome click every quarter note
(new midi-time-signature :numerator 4 :denominator 4 :clocks 24)

;;; 6/8 with metronome click every dotted quarter note
(new midi-time-signature :numerator 6 :denominator 8 :clocks 36)

Example 2. Generating time and key signatures.

(define major (new mode :degrees '(c d e f g a b c)))

(define (gen-measures mea tempo )
  ;; generate measures, each with own time and key signatures
  (let ((tonics (new heap :of '((c 0) (cs 7) (d 2) (ef -3)
                                (e 4) (f -1) (fs 6) (g 1)))))
    (process with rhy = (rhythm 'e tempo)
             repeat mea
             for bpm = (pick 2 3 4 5) ; beats in measure
             for ton = (next tonics)  ; keysig info
             do (transpose major (first ton)) ; shift mode
             output (new midi-key-signature :time (now)
                         :key (second ton))
             output (new midi-time-signature :time (now)
                         :numerator bpm :denominator 4)
             each k = (between 28 42) ; modal keynums 48-72
             as i below (1- (* bpm 2))
             output (new midi :time (+ (now) (* rhy i))
                         :keynum (keynum k :in major)
                         :duration rhy)
             wait (* rhy bpm))))

(events (gen-measures 8 120) "test.mid")
 "test.mid"
(midi-file-print "test.mid")

See also: