[CM] import-events tempo-change

Rick Taube taube@uiuc.edu
Wed, 27 Aug 2003 19:20:01 -0500


> But I don't know the meaning of values in the "data #(3 7 161 32)" ??
> How can I read the tempo-change from it, in milliseconds ??
> How can I read the tempo-change from it, in milliseconds ??

The last three numbers in the vector are midi bytes encoding the actual
tempo change value. (The first number in the vector is just the number
of bytes in the message data and can be ignored.) To convert this vector
to a tempo number in milliseconds you have to perform some simple
bit-twiddling. In CLTL it looks like:

(defun tempo->ms (data)
  (/ (+ (ash (elt data 1) 16)
        (ash (elt data 2) 8)
        (elt data 3))
      1000))

In scheme it looks like:

(define (tempo->ms data)
  (/ (+ (ash (vector-ref data 1) 16)
        (ash (vector-ref data 2) 8)
        (vector-ref data 3))
      1000))

Calling the function with your vector gives:

> (tempo->ms #(3 7 161 32))

500


If your vector data is held in MIDIMSG objects you can fetch the vector
from each object using the accessor function midimsg-data, ie:

> (define a (new midimsg data 1))
 
> (midimsg-data a)
1