Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!pasteur!oak.Berkeley.EDU!maverick From: maverick@oak.Berkeley.EDU (Vance Maverick) Newsgroups: comp.music Subject: Re: Need help With MIDI interface S/W Ideas. Keywords: Keyboard to IBM via MIDI. Message-ID: <18642@pasteur.Berkeley.EDU> Date: 21 Oct 89 18:36:10 GMT References: <2211@servax0.essex.ac.uk> Sender: news@pasteur.Berkeley.EDU Lines: 40 I failed sending mail, so I'll post this as a followup. > I`m not sure the actual DATA structure > I need to use on READING THE MIDI MESSAGES; especially > the timing information of each MIDI MESSAGES > In storing the MIDI MESSAGE ( key on/off ..), how do I > include the time field indicating when each note/event > ( key on/off ..) has occurred (relatively/ ??). This is to > make sure the MIDI MESSAGES are sent at a right time on > playback. For notes I recommend a structure like this: typedef struct { long time; /* Attack time from start of track */ unsigned int length; /* Length in same time units */ char pitch, /* MIDI information: pitch 0-127 */ channel, /* channel 0-15 (low nibble of status) */ velocity, /* Attack velocity (from note-on) */ release; /* Release velocity (from note-off) */ } note; (Assuming long = 32 bits, int = 16, char = 8.) In writing a MIDI sequencer three years ago, my partner and I committed ourselves early on to a track format where ons and offs were stored separately. This became a real pain when we started implementing edit operations. Also, I think you want to store the time as absolute, i.e. from the start of the track, rather than with respect to the previous note: again, the advantage becomes most apparent with edit operations. For timing on the PC, there are a couple of options. The Roland MPU interface and its clones will do timing for you, in 120ths of a quarter note (and other resolutions); this is quite adequate for a sequencer. If you don't have one, or don't want to deal with the eccentricities of the MPU command set and timing scheme, you can do the timing yourself with the PC's system timer. You'll need to speed up the timer, divert the interrupt to a handler of your own, and call the old handler at the right (old) speed. This is not "hard", but tricky to get right. I don't have the demo