[sdiy] Processing Midi - Dropping Notes
Theo
t.hogers at home.nl
Wed Jul 14 06:34:29 CEST 2004
Hi Bill
Does your code account for running status?
I am asking cause this sounds like a problem with running status to me.
In this case, running status would result in one note on status message followed by multiple note-number and velocity value bytes.
Also not just 3 bytes but:
Note on; note number; velo; note number; velo; ect.
There are two things that make receiving midi notes a bit complicated.
First there is the running status data compression.
For even more fun there is also "real time messages" that can come in-between the bytes of other messages.
A bit less trouble is old Yamaha stuff sending end of exclusive messages to check the midi connection,
only Bohm and other Yamaha stuff gets messed up from this..
Fun isn't it?
The real time messages are one byte only.
So just check if a message is real time, then do something with it, like nothing at all.
Next is just to get you started, not completely structured as you would like to code it.
Best follow it through a few times, it does make sense...
When receiving a byte always first check if it is a status byte.
If statusbyte (bit 7 set) and if not a "real time" message and not a "start of sysex" message or a "end of sysex" message,
then write it to the "running status buffer" and clear the "second byte" flag.
Done.
If real time, do what you have to do. (leave the "running status" buffer like it is!!)
Done
If sysex start, clear the "running status buffer" and goto sysex mode(until a end of sysex) or ignore if the sysex is not for you.
Done.
If not a status byte check if the running status buffer is empty,
when it is; just throw the byte away, its a error or part of sysex data that your not interested in.
Done.
When the "running status buffer" is not empty then:
Check if the "second byte flag" is set.
If the "second byte flag" is not set then this is the first data byte of whatever message type is in the "running status buffer".
If there is a 2 byte message type in the running status buffer your ready now.
Together with the data from the running status buffer you have your 2 byte midi message.
If there is a 3 byte message type in the running status buffer:
Store the received byte for the time being in "fist byte buffer" and set the "second byte flag"
Done.
If the "second byte flag" is set then this is the second data byte of whatever message type is in the "running status buffer".
Now your 3 byte message is complete, together with the value of the running status buffer and the "first byte buffer" a 3 byte midi message.
Do whit it whatever you like, but before you do clear the "second byte flag"
Done.
As you can see the "running status buffer" stays as it is for most of the time.
HTH
Theo
----- Original Message -----
From: bill berzinskas
To: synth-diy at dropmix.xs4all.nl
Sent: Tuesday, July 13, 2004 1:48 PM
Subject: [sdiy] Processing Midi - Dropping Notes
Hey everyone..
I've been working on a midi-cv processor for my homebrew modular.. i've got it done, and got most of the code hashed out.. using midi-ox, i can trigger the sounds.. It does get stuck in note on sometimes tho, and won't take any more data.. also when i use it in cubase, i get maybe 1 note, then it stops.. can someone give me some suitable pseudo code to work through processing the data.. as of now, i get th 3 bytes and go into an if to process the data... i've tried adding some running status parts where if the first byte is a data byte, assume the last status message.. anyway, any help would be great.. i'm using pic 18f452 and picbasic, but can get around in ASM decently..
thanks
--billie
------------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20040714/f2f498a7/attachment.htm>
More information about the Synth-diy
mailing list