fbpx


The MIDI Forum

  Monday, 08 August 2022
  8 Replies
  2.2K Visits
12
Votes
Undo
  Subscribe
Hi, I started developing a device with usb midi 1.0 based on a microchip usb stack example (the descriptor is almost the same of the "midi10.pdf" final example). Everything is working fine on mac os, but if I connect the device to any Windows pc it works only for PC, CC, MIDI CLOCK, Notes, but NOT FOR SYSEX. Messages are actually not seen.

WHen I compose the messages I pack them in 4 bytes groups (control byte + 3message bytes) to fill a 32 bytes buffer and send it to the host. As already said, on mac os there's no problem, so messages are correctly received.
On windows I'm using MIDI-OX to monitor the input, and to be sure about the configuration I tried to do the same thing with a commercial USB-MIDI converter and it works fine, so i'm sure it's a problem on my device.
Is there somebody who suffered of similar issues? The only thing I didn't try is to send 4 bytes buffers instead of the compact 32 bytes buffer.
Paolo Nicotra set the type of the post as  Technical Question — 1 month ago
0
Votes
Undo
Are you sending all 32 bytes, or only as many as are actually used? It's possible that the Windows driver ignore the entire USB packet when it sees an invalid event packet.
1 month ago
·
#15439
0
Votes
Undo
Good question Clemens! I tried to send 4bytes packets but it didn't work. Now I will try to complete a 32 bytes buffer and I'll tell you if it works. Than you for the suggest.
1 month ago
·
#15441
0
Votes
Undo
It didn't work.
Still having the same problem even with a complete 32Bytes buffer and a complete 64Bytes buffer.
0
Votes
Undo
Please show your source code.
1 month ago
·
#15470
0
Votes
Undo
Ok, I just rewrote a "generic" function that fills my tx buffer with only the necessary bytes (there's no check on max length since it's not necessary for this example code) to show you how I prepare the packets. Just checked and it works on mac OS (I tried on an old mac with yosemite OS and a new mac with catalina OS) but it doesn't work on windows (Windows 10). No issues with program changes or other standard "one/two/three bytes" messages.


Here' the code:

void USB_SYSEX_TX (unsigned char ID, unsigned char *tx_buf,unsigned char len)
{
unsigned char i = 0;
unsigned char tx_packets;
unsigned char last_packet_len = 0;
unsigned char buf_len;

len+=3; //Add F0, ID, F7

tx_packets = len/3;
last_packet_len = len - (tx_packets*3);
if (last_packet_len) tx_packets++;
buf_len = len + tx_packets;

if(!USBHandleBusy(USBTxHandle))
{
//First chunk
sysex_packet.v[0] = MIDI_CIN_SYSEX_START;
sysex_packet.v[1] = SysEx_START; //F0
sysex_packet.v[2] = ID;
sysex_packet.v[3] = tx_buf[0];

//middle chunks
for (i=1; i<tx_packets-1; i++)
{
sysex_packet.v[i*4] = MIDI_CIN_SYSEX_CONTINUE;
sysex_packet.v[(i*4)+1] = tx_buf[(i*3)-2];
sysex_packet.v[(i*4)+2] = tx_buf[(i*3)-1];
sysex_packet.v[(i*4)+3] = tx_buf[i*3];
}

//Last chunk
if (last_packet_len == 0)
{
sysex_packet.v[i*4] = MIDI_CIN_SYSEX_ENDS_3;
sysex_packet.v[(i*4)+1] = tx_buf[(i*3)-2];
sysex_packet.v[(i*4)+2] = tx_buf[(i*3)-1];
sysex_packet.v[(i*4)+3] = SysEx_END; //F7
}
else if (last_packet_len == 2)
{
sysex_packet.v[i*4] = MIDI_CIN_SYSEX_ENDS_2;
sysex_packet.v[(i*4)+1] = tx_buf[(i*3)-2];
sysex_packet.v[(i*4)+2] = SysEx_END; //F7
}
else if (last_packet_len == 1)
{
sysex_packet.v[i*4] = MIDI_CIN_SYSEX_ENDS_1;
sysex_packet.v[(i*4)+1] = SysEx_END; //F7
}

USBTxHandle = USBTxOnePacket(USB_DEVICE_AUDIO_MIDI_ENDPOINT,(uint8_t*)&sysex_packet,buf_len);
}
}
0
Votes
Undo
buf_len must be a multiple of four.
1 month ago
·
#15480
0
Votes
Undo
Thank you Clemens, I'll add a padding of 0s on the last chunk after the "sysex_end" and I'll try.
1 month ago
·
#15626
0
Votes
Undo
It worked! Buf_len now is multiple of four and I added a padding on the last chunk to complete the "fourtet". It works. Thank you for the support.
  • Page :
  • 1
There are no replies made for this post yet.