Hi, I’d like to create a virtual midi port on my iPad to send message to some apps as Cubasis or AUM, but unfortunately with this code that woks on desktop app doesn’t work on iPad: the virtual port is not detected by any app and when I try to click a button that create a message to send to that port the app gives me the error: JUCE Message Thread (1): EXC_BAD_ACCESS (code=1, address=0x1c8).
Really Thank you! I suppose that virtual midi ports exist also in iOS because I noticed that when I open a synth app I could send midi message to it through a port that the synth creates at opening (for example I opened Kaspar, Igrand, iSynphonic, synthmaster one and after cubasis and from cubasis I have a list of output midi ports with the name of apps opened through I can send message from cubasis to these other apps).
I tried again creating new project, this time choosing audio plugin from wizard in Projucer enabling in setting only standalone and IAA, after I created a new midi output device and a new midi input device but nothing change. Here what I’ve done:
on Plugin Editor I put under private members those two variables:
MidiInput* mi;
MidiOutput* mo;
on init function I put this code:
mo = MidiOutput::createNewDevice("MyDeviceOut");
// PREVIOUS LINE PRINT IN CONSOLE: CoreMIDI error: 417 - ffffd5a4
if (mo != nullptr) {
MidiOutput::openDevice(mo->getDefaultDeviceIndex());
}
mi = MidiInput::createNewDevice("MyDeviceIn", this);
// PREVIOUS LINE PRINT IN CONSOLE; CoreMIDI error: 560 - ffffd5a4
if (mi != nullptr) {
mi->start();
}
Obviously I tried that code on a desktop version and it works!
In attachment a screenshot of how cubasis looks when before it I open another app that create his own midi ports (while if I launch my test it looks the same but without in this case “iGrand Piano”).
Have you enabled the “Audio Background Capability” setting in the iOS exporter in the Projucer? This is needed to create MIDI devices otherwise CoreMidi will throw a kMIDINotPermitted error (which is the ffffd5a4 error you’re seeing).
Is this actually working?
Here we can only successfully call MidiInput::createNewDevice() if the app is running standalone. If we run the AUv3 in AUM or Cubasis we get the kMIDINotPermitted error.
We are using CMake and we are setting BACKGROUND_AUDIO_ENABLED
to TRUE which results in the same XCode Project Config as if we were using the Projucer. However even within XCode it seems I can’t set the Background Mode for Audio like stated in Apple’s documentation here:
There are apps around which create their own virtual Midi ports though, even when hosted as an AUv3. So there must be a way, but how?
Ok, I’ve spent a couple of hours down the rabbit hole:
It seems like this never worked for AUv3s, @Ayra also told me in a PM that it was only tested in Standalone. There seems to be no way to enable Audio Background Mode for an AUv3, I’ve pretty much tried everything in XCode…
It’s not a JUCE bug at least, it seems to be a restriction by Apple. Maybe one of the JUCE devs, @reuk ?, can confirm this and add it to the documentation? My hours are gone but someone else’s could be saved