Virtual MIDI Device

Hey!

I know theres a million threads about virtual MIDI devices, but they all seem to be from quite a long time ago so i’m not sure if something has changed.

Im creating a virtual MIDI device (which is successful) on macOS however I don’t see the device appearing anywhere either in Ableton or in MIDI Studio. I want to output MIDI from my application.

This is how i’m creating it:

bool MidiOutputManager::createVirtualDevice(const juce::String& deviceName)
{
    midiOutput.reset();
    
    juce::Logger::writeToLog("Attempting to create virtual MIDI device: " + deviceName);
    
    midiOutput = juce::MidiOutput::createNewDevice(deviceName);
    
    if (midiOutput != nullptr)
    {
        isVirtualDevice = true;
        currentDeviceInfo = midiOutput->getDeviceInfo();
        midiOutput->startBackgroundThread();
        juce::Logger::writeToLog("Virtual MIDI device created with identifier: " + currentDeviceInfo.identifier);
        
        // Log device info
        juce::Logger::writeToLog("Device name: " + currentDeviceInfo.name);
        juce::Logger::writeToLog("Device identifier: " + currentDeviceInfo.identifier);
        
        return true;
    }
    
    juce::Logger::writeToLog("Failed to create virtual MIDI device");
    juce::Logger::writeToLog("On macOS, this usually happens because of permissions or a sandboxed app.");
    juce::Logger::writeToLog("Make sure your app is not sandboxed and has proper entitlements.");
    
    return false;
}

Any idea what i’ve missed?

On macOS in Audio MIDI Setup create an IAC Driver in MIDI Studio. It should show up in every app on your Mac.

I am using that for testing, but it would be much more convenient for users of my app if they didn’t have to do that. It’s not exactly the most plug and play solution to have to use the IAC Driver.

Claude.ai can create an example for you to create your own Virtual MIDI Device using JUCE

I’m using pretty much the same code and it works fine here. The MIDI device shows up fine in other DAWs as a possible input.

You may need to show more code. What is the lifetime of this MidiOutputManager object?

Hmm interesting. It’s created when the application starts and the main window is constructed, and then destroyed when the application closes.

Yes, that is the expected behaviour

So I was creating multiple instances of my MidiOutputManager which I think was causing the issues.

You can consider using BMIDI Virtual MIDI SDK – Bome Software (and it will work on Windows too).

Hmm for some reason it works on my computer, but not on other peoples when i share the binary.

What is the error message they are getting? Did you sign and notarize the binary?

I don’t get any messages, I my binary is signed and notarized with the following entitlements:

➜  /Applications spctl -a -vvv Test\ MIDI.app 
Gamepad MIDI.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: Adam Ham (8D4T9CC22L)
➜  /Applications codesign -d --entitlements - Test\ MIDI.app
Executable=/Applications/Test MIDI.app/Contents/MacOS/Test MIDI
[Dict]
	[Key] com.apple.security.app-sandbox
	[Value]
		[Bool] false
	[Key] com.apple.security.device.midi
	[Value]
		[Bool] true
	[Key] com.apple.security.device.virtual-midi
	[Value]
		[Bool] true
	[Key] com.apple.security.temporary-exception.mach-lookup.global-name
	[Value]
		[Array]
			[String] com.apple.midi.server
➜  /Applications 

Just want to point out that you’re printing info on two different apps here.

Ah you can assume that they are from the same app. I copy and pasted it incorrectly.