USB MIDI Devices problem

Hi,

I design a standalone JUCE application, which processes some MIDI data coming from MIDI Devices and send it to another MIDI Devices. I’ve got a problem with some of MIDI Devices which are connected via USB - my keyboard KETRON SD9, and poor quality USB to MIDI interface.

The whole system requires DAW app for work. When I run e.g. Cubase (the same also on Cakewalk and Ableton), and create the MIDI track with some data, then I set the MIDI outputs of this track to this USB MIDI devices. When I run my app and I want to select the same USB-MIDI devices as I set in DAW, my app goes to crash. Moreover, when I do something similar with MIDI Input in my app - so I choose the USB-MIDI input first on DAW, and then the same in my app, everything works correctly. But when I want to disable this MIDI Device in my app, it also goes to crash.

I perform the debugging of my app. I have seen that my app crashes when the functions: startBackgroundThread(), stopBackgroundThread() and isBackgroungThreadRunning are recalled. Of course I cannot abandon this, because my app will not send out any MIDI data. In the second case (with MIDI IN) my app crashes when the function MidiDevice->stop() is recalled. When I was writing the MIDI I/O services, I based on MidiDemo.h project.

Last but not least - I’ve got an audio interface Focusrite Scarlett 6i6 2nd Gen. I use its MIDI input and output, and I can freely enable / disable the Focusrite USB MIDI device on DAW and my app, and it works correctly all the time.
What should I do? Maybe I do something wrong? Where is the problem - in my app, in drivers for this USB-MIDI device, or something more?

Thanks in advance :wink:

P.S. This USB-MIDI devices works ONLY on Windows. It doesn’t work on Mac.

Under Windows, the class compliant midi driver does not support more than on app opening the same midi port. The manufacturer can supply a driver which is written in a way that allows more than one application to open the same midi port. Having said that, I wouldn’t expect attempting that would cause a crash, but instead a failure when opening the port.

1 Like

I try to implement an “reaction” on wrongly opened MIDI device, but it doesn’t solve the problem. My app operates and send MIDI data as midi buffers, and I need to run the BackgroundThread - which causes a crash. Only my app crashes, any DAW doesn’t crash.
I will write about this problem in user manual, and also write to driver developers to inform they about this issues.