thestk / rtmidi

A set of C++ classes that provide a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI) and Windows (Multimedia)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to detect, that a MIDI-IN is already used by another app?

MidimasterSoft opened this issue · comments

pre-information:
Hi, I'm working with RT-MIDI via a BlitzMax-Wrapper. At the moment we use V 4.0.0. The BlitzMax-Wrapper is made by Bruce A Henderson (https://github.com/bmx-ng).

Today we come to the problem, that we have a MIDI-IN-Device, but it is used by another app. The question is now: How can we find out, that this Port is not aviable for us. Does RT-MIDI offer a way to detect this? by the way... is there a forum where we can ask qusetions like this to the RT-MIDI community?

Do I understand it right: You have an existing MIDI Port on your system and want to read that MIDI stream with RtMidi. This doesn't work because the device is in use. This probably implies that you are using Windows as other systems usually have an intermediate layer that duplicates the stream to both applications. Both MacOS and ALSA have a device based API that allows exclusive access to the devices but usually the midi daemon (MacOS) or the sequencer API (ALSA) are used if exclusive access is necessary.

Whenever a port is not available while RtMidi tries to connect to it, an eception will be thrown. You should ask the BlitzMax people how to catch it.

(am a BlitzMax NG user and contributor)

The Exception - if thrown - is catched by BlitzMax NG (so you can try-catch in your BlitzMax-code too). Just verified it. As I am a Linux user (and for Windows: am lacking midi devices) I am not sure how to test if midiOutOpen() (respectively midiInOpen()) returns an error or not. Yet I doubt it fails to do so. Most likely the issue lays in the way the user interacts with rtMidi (via the BlitzMax wrapper module)

Thanks for the answers. I was able to receive the Exception with a Try/Catch-Block in BlitzMax (Window 10). The BlitzMax wrapper was already prepaired for handle the exception, but the manual did not say anything about it.

Now I'm able to find out, when a port is already used by another app or when the port is not avaiable.