Windows MIDI code now handles sysex messages correctly.
This commit is contained in:
parent
78a36b2e9d
commit
b9ad63e2fc
1 changed files with 35 additions and 2 deletions
|
|
@ -39,17 +39,50 @@ void midi_close()
|
|||
|
||||
static int midi_pos, midi_len;
|
||||
static uint32_t midi_command;
|
||||
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 0};
|
||||
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 1};
|
||||
static int midi_insysex;
|
||||
static uint8_t midi_sysex_data[1024+2];
|
||||
|
||||
static void midi_send_sysex()
|
||||
{
|
||||
MIDIHDR hdr;
|
||||
int c;
|
||||
|
||||
hdr.lpData = midi_sysex_data;
|
||||
hdr.dwBufferLength = midi_pos;
|
||||
hdr.dwFlags = 0;
|
||||
|
||||
/* pclog("Sending sysex : ");
|
||||
for (c = 0; c < midi_pos; c++)
|
||||
pclog("%02x ", midi_sysex_data[c]);
|
||||
pclog("\n");*/
|
||||
|
||||
midiOutPrepareHeader(midi_out_device, &hdr, sizeof(MIDIHDR));
|
||||
midiOutLongMsg(midi_out_device, &hdr, sizeof(MIDIHDR));
|
||||
|
||||
midi_insysex = 0;
|
||||
}
|
||||
|
||||
void midi_write(uint8_t val)
|
||||
{
|
||||
if (val & 0x80)
|
||||
if ((val & 0x80) && !(val == 0xf7 && midi_insysex))
|
||||
{
|
||||
midi_pos = 0;
|
||||
midi_len = midi_lengths[(val >> 4) & 7];
|
||||
midi_command = 0;
|
||||
if (val == 0xf0)
|
||||
midi_insysex = 1;
|
||||
}
|
||||
|
||||
if (midi_insysex)
|
||||
{
|
||||
midi_sysex_data[midi_pos++] = val;
|
||||
|
||||
if (val == 0xf7 || midi_pos >= 1024+2)
|
||||
midi_send_sysex();
|
||||
return;
|
||||
}
|
||||
|
||||
if (midi_len)
|
||||
{
|
||||
midi_command |= (val << (midi_pos * 8));
|
||||
|
|
|
|||
Loading…
Reference in a new issue