Hello, I've been looking into writing out midi using mrpeach's [midifile]. Now I'm trying to write a tempo change message into the midi file. So far I figured out that the message format should be "FF 51 tt tt tt". (e.g. as described here http://www.deluge.co/?q=midi-tempo-bpm ) I'm not sure though, how to translate that into a message that [midifile] can accept to correctly write the tempo change into the file. I tried a few variations, like [255 81 500000( (for 120bpm) or by first changing the 500000 into three hexadecimal bytes, and then turn those into 3 floats [255 81 7 51 0( but all I get is extremely low tempi when I import that midifile into a DAW (I seem to get the most informative results with Rosegarden) Any ideas? thanks! Tim
I seem to be getting closer [255 81 3 $1 $2 $3( seems to do the trick, (the 3 was necessary to designate the 3 following bytes...) still not sure why [255 81 3 7 161 32( does not result in 120bpm but "120qpm" and 80bpm... gr, Tim
2018-02-10 19:18 GMT+01:00 tim vets timvets@gmail.com:
Hello, I've been looking into writing out midi using mrpeach's [midifile]. Now I'm trying to write a tempo change message into the midi file. So far I figured out that the message format should be "FF 51 tt tt tt". (e.g. as described here http://www.deluge.co/?q=midi-tempo-bpm ) I'm not sure though, how to translate that into a message that [midifile] can accept to correctly write the tempo change into the file. I tried a few variations, like [255 81 500000( (for 120bpm) or by first changing the 500000 into three hexadecimal bytes, and then turn those into 3 floats [255 81 7 51 0( but all I get is extremely low tempi when I import that midifile into a DAW (I seem to get the most informative results with Rosegarden) Any ideas? thanks! Tim
On Sat, Feb 10, 2018 at 1:49 PM, tim vets timvets@gmail.com wrote:
I seem to be getting closer [255 81 3 $1 $2 $3( seems to do the trick, (the 3 was necessary to designate the 3 following bytes...) still not sure why [255 81 3 7 161 32( does not result in 120bpm but "120qpm" and 80bpm...
Probably because numbers greater than 127 must be formatted in 'variable-length quantity' form, where the number is broken up into 7-bit pieces and all the pieces except the last have the high bit set, so decimal 500000 in hex is 7A120, or in binary 1111010000100100000, becomes 10011110 11000010 00100000, or 158 194 32 (if I didn't make any mistakes along the way). Using calculator in programmer mode is useful here. I need to add a meta method so you can write meta events without having to do that.
Martin
On Sat, Feb 10, 2018 at 7:48 PM, Martin Peach chakekatzil@gmail.com wrote:
On Sat, Feb 10, 2018 at 1:49 PM, tim vets timvets@gmail.com wrote:
I seem to be getting closer [255 81 3 $1 $2 $3( seems to do the trick, (the 3 was necessary to designate the 3 following bytes...) still not sure why [255 81 3 7 161 32( does not result in 120bpm but "120qpm" and 80bpm...
Probably because numbers greater than 127 must be formatted in 'variable-length quantity' form, where the number is broken up into 7-bit pieces and all the pieces except the last have the high bit set, so decimal 500000 in hex is 7A120, or in binary 1111010000100100000, becomes 10011110 11000010 00100000, or 158 194 32 (if I didn't make any mistakes along the way). Using calculator in programmer mode is useful here.
But for meta events, numbers are stored as is, in big-endian order, not as variable-length,, so [ 255 81 3 7 161 32 ( should work properly.
Martin