Reputation: 523
I need to play multiple tracks simultaneously in my app. The tracks may be normal audio files or a set of midi notes. So, I have configured an audio graph and connected various audio units (file player AUs and sampler AUs) to a multi channel mixer whose output is connected to remote io unit for playing audio files and midi notes. The sampler units are loaded with sf2 files of various instruments. All of this works fine but once I have more than two midi sampler Audio units and try to play midi notes simultaneously through those units using MusicDeviceMIDIEvent function, the output sound gets distorted/broken after a few loops. I need to simultaneously play about 10 instrument tracks and the problem starts right after I add a third midi unit. Can someone point me if there is a problem in this approach and if so, can you let me know how I can achieve this task of playing midi notes of various instruments simultaneously.
Upvotes: 1
Views: 1019
Reputation: 99
Playing multiple Midi notes on different tracks should not be a problem. I got it working fine. Make sure you stop the midi note being played before you play a new one. You can use the same function for stopping midi notes like below
UInt32 noteCommand = kMIDIMessage_NoteOff << 4 | 0;
UInt32 velocity = 0;
MusicDeviceMIDIEvent (samplerUnit, //audiounit
noteCommand,
note, //note being played
velocity,
0);
Upvotes: 1