I couldn’t find information about the organisation of midi datas to merge the datas for example for two inputs to one output. I want to build a midi merger with a Pic processor. The hardware is ready. For programming the PIC I need some information about that. Please let me know some informations.
As I understand your question, you have two separate, and valid, midi streams, and you wish to merge these two streams into one. Where are the two streams from? What is createing them? Are they valid/complete midi streams?
A midi stream will usually contain at least some timing data. This cannot be merely merged. The midi data will contain midi messages, many of which will comprise multiple bytes of data, and these cannot be mixed up.
Logically, a process to merge the streams will need to separate the timing data out, separate each individual midi message, send on the midi messages, and create new timing data for the complete new stream. This is not a trivial task.
If you could provide an example of the sort of data you're talking about, both streams, I may be able to tell you more.
Geoff
MIDI streams do not contain timing data.
You have to parse all incoming messages in order to get running status at the output correct. And you have to decide what to do when a large SysEx on one port blocks messages from the other port.
To all! I want to merge two Midi Inputs into one output. These are standard Midi Datas with one status byte and one or two date bytes.
In Input 1 datas are coming from a midi masterkeyboard (Hammond Clone). In Input 2 I send ProgrammChange CC. The Midi Output is connected to a bass synthesizer expander. So this is the task.
Merging without SysEx is easy.
A simple algorithm would work like this:
* There are three states, for when port 1/2 is in the middle of a command, or when none is.
* There a are three events that can trigger an action: a byte arrives on port 1/2, or the output port is ready to send the next byte.
* When a byte arrives, and the other port is not in the middle of a command, send it on. (But when the output port is not yet ready, you have to buffer it.)
* When a byte arrives, and the other port is in the middle of a command, store it in another buffer.
* When a command is finished, check if a buffer is not empty.
Hi Clemens, many thanks. I will try it.