Write MIDI byte stream to USBMIDI

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I have a device with the following MIDI ports:

   

1. USBMIDI in/out
2. MIDI uart in/out (as a part of the USBMIDI device)
3. MIDI over SPI in/out

   

I want to be able to route messages from all the inputs to all the outputs. By "output" in this context I mean an output from my device.

   

Now, routing between USB and UART is simple, since it happens automatically.
Reading messages from these inputs and writing them onto SPI out is also simple.
Reading from SPI into a character buffer is up and running.

   

But what is the best way to write the messages from SPI to USB/UART outputs? The problem is that these messages are just received as a stream of bytes, i.e. they are not parsed into MIDI messages that fit as input to

   

USB_PutUsbMidiIn(USB_3BYTE_COMMON, midiMsg, USB_MIDI_CABLE_00);

   

Since the UART also gets its MIDI input as a byte stream, I assume it has a parser for it, but this doesn't seem to be covered in the API documentation. I'd rather not reinvent the wheel by writing another one, so is there any "correct" way to write data into this parser from code?

0 Likes
3 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Can you please attach your project.

   

Thanks,

   

Hima

0 Likes
Anonymous
Not applicable

It's basically the USBFS_MIDI_PSoC3_5LP example project from PSoC Creator.

   

What I want to do is to take a buffer of MIDI messages such as this and send it out on the USB and UART midi ports:

   

uint8 midi_out_buffer[] = {0xf8, 0x90, 0x43, 0x64, 0x80, 0x43, 0x40, 0xf8, 0xf8, 0xf8, 0x90, 0x43, 0x64};

   

The buffer contains midi messages of varying lengths (ie: 0xf8 is a one-byte message, 0x90, 0x43, 0x64 is a three-byte message etc) so I can't just dump it into USB_PutUsbMidiIn()

0 Likes
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

   

Can you have a look at API USB_PrepareInBuffer(), here there is a parameter eventLen which is the number of bytes in MIDI event. 

   

Thanks,

   

Hima

0 Likes