Re: Problem inserting tempo event (for a simple php script)
[email protected] (David Riley) Sat, 16 Aug 2003 20:07:44 +0100
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <[email protected]> |
"Alex" <[email protected]> writes: > Hi. I am trying to create MIDI using PHP. ^^^ ! > The problem I have is, how do I add a TEMPO event to this MIDI? > Tempo structure: > FF 51 03 tt tt tt > where tttttt = New tempo, in us/quarter-note, in 24-bit binary > > Let's say I want to add a tempo of 500000 to the beginning of the track, > what should I do? $tempo = 500000; $byte_0 = $tempo / 0x10000; $tempo = $tempo % 0x10000; $byte_1 = $tempo / 0x100; $byte_2 = $tempo % 0x100; Then add the bytes in order: $byte_0 $byte_1 $byte_2 in Perl: $file .= pack "CCC", $byte_0, $byte_1, $byte_2; -- David Riley [email protected]