Music duration

Kurt Kaufman kkaufman at snet.net
Wed Feb 11 19:02:20 EST 2009


"...I know your work and I appreciate it, but.... but...
It is a little bit complex for me :-(
I dont understand binaryEncode(etc...)
and also the bridge between Revolution (code) and Midi..."

René,

I know it looks complicated.  I think it would take me a while to  
figure it out again, even though I commented the scripts fairly heavily!
But once you understand what makes up a MIDI file, which parts are  
constant (always the same in every MIDI file of that type), and which  
parts are variable (different in each music track), you see that it is  
not that complex.  If you look at the MIDI format document, you'll see  
the various parts described in the order in which they appear.

At least MIDI files are generally not very big, so if you want to open  
them up using a Hex editor, you're not scanning a tremendous amount of  
data.  To that end I would use MIDI Builder to create a MIDI file with  
a single note, and then take a look using HexEdit:

http://sourceforge.net/project/showfiles.php?group_id=9366
(there's a French version, too)

Now compare what's in the MIDI format document with what you see in  
the HexEdit.

Rev's binaryEncode function is called after all of the various parts  
of the data have been set up, as most of the MIDI data cannot be  
represented by ascii (it's not printable, for the most part).  But the  
binaryEncode function is automatic;  you just have to give the  
function its data and the proper parameters, and Rev does the rest.  
Rev makes it easy: You can simply add the successive bytes of encoded  
data "after" what's already there.  The file can be created in a  
fraction of a second and played almost immediately.  Rev's QT player  
object handles most of the work, you just have to send it data that it  
understands.

Hope this helps,
Kurt

further info:
http://crystal.apana.org.au/ghansper/midi_introduction/midi_file_format.html
http://www.harmony-central.com/MIDI/Doc/doc.html




More information about the use-livecode mailing list