Question

I want to play instrumental sounds in my app. The duration of the sounds is flexible so MIDI seems the best solution.

I am using Open Framework for now. Using Audio Units, I managed to process an input sound, not to play through an instrument. I have found AUi instruments on my Mac but I don't know how to access them from my code. I didn't find any way to play General Midi (built in MIDI instrument). No out port found with RTMidi.

Does anyone have a solution? Thank you!

Was it helpful?

Solution

I found the solution in this project.

You need to use Audio Units. Add a node with this component description:

description.componentType           = kAudioUnitType_MusicDevice;
description.componentSubType        = kAudioUnitSubType_DLSSynth;
description.componentManufacturer   = kAudioUnitManufacturer_Apple;
description.componentFlags          = 0;
description.componentFlagsMask      = 0;
AUGraphAddNode (graph, &description, &synthNode);

Open and initialize your audio units and play the notes like that:

MusicDeviceMIDIEvent (synthUnit, channel, note, velocity, 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top