My goal is to receive MIDI events from an external keyboard and trigger the appropriate notes on a sampler. I wasn't able to come up with a working solution so far and I haven't found an example covering that exact usecase.
My code so far (macOS, Swift):
let audioEngine = AudioEngine()
let sampler = MIDISampler()
audioEngine.output = sampler
try! audioEngine.start()
try! sampler.loadEXS24("...")
sampler.enableMIDI()
When I manually trigger a note via sampler.receivedMIDINoteOn
, I hear a sound. The MIDI part itself also works - I hooked up a MIDIListener and logged the noteOn events. However I don't understand how to connect both parts together.