iOS MusicPlayer: suppress sine tone playback

Hello All,


I'm working on a music app for iOS 8+ using AudioKit. Since the sequencing in AK is pretty rudimentary, I'm using the MusicPlayer API for sequencing. I'm doing this by writing user events which I convert to AKNotes upon callback. Since I'll be playing midi files, I'm using the original note events as data sources for my user events. All works nicely. The only problem is that iOS insists on playing the original note events with a sine generator. I can zero out the velocities to silence them, but I'd rather leave them unaltered. Surely there must be a way to tell the MusicPlayer not to throw note events without an assigned endpoint at a sine generator, yes? (I'm assuimng that's what's going on, btw; i.e., that the MusicPlayer uses a sine generator AU if no midi endpoint has been assigned.)


Any help appreciated.


J.

Answered by in 46436022

When you create a MusicSequence and MusicPlayer without specifying the midi endpoint, a Sampler AU is created for you by default, at the same time that it builds the rest of the AUGraph which lets you play back your MIDI data. There is sample code available on the developer site showing how to access the Sampler and configure it -- it only plays back sine waves because that is its default instrument.

Each track in your sequence must have its MIDI data routed to either a valid instrument node in the AUGraph or to a MIDI endpoint that you create. A track's MIDI data cannot go "nowhere".


-DS

Accepted Answer

When you create a MusicSequence and MusicPlayer without specifying the midi endpoint, a Sampler AU is created for you by default, at the same time that it builds the rest of the AUGraph which lets you play back your MIDI data. There is sample code available on the developer site showing how to access the Sampler and configure it -- it only plays back sine waves because that is its default instrument.

Each track in your sequence must have its MIDI data routed to either a valid instrument node in the AUGraph or to a MIDI endpoint that you create. A track's MIDI data cannot go "nowhere".


-DS

Thanks for the reply. But it's not exactly that I want data to go "nowhere", I just don't want to play the note events—my model is based on custom user events only, which I am playing (but through AudioKit, not through normal AUs). It's only a problem when working with midi files, since these will always contain standard note events, in addition to my custom user events.

Anyway, I guess I'll have to shoot them off into some endpoint nether world. Is there a way to create a kind of "dummy" endpoint, that you know of? I just want to be sure they won't play to anything (since this could be a nasty surprise for the user). I suppose I could iterate over again and remove all the note events, but that seems like a superfluous operation... It isn't necessarily a big problem to have them there, I just don't need/want to hear them.

You can create and load a "dummy" AUPreset into your default Sampler AU. I believe there are some WWDC demo projects with examples of these presets. Just remove all the regions so there is no key with a matching sample.


-DS

Ooops! Sorry the long delay (moved on to other work).

But thanks, that's a possibility. The only thing is that, at this point at least, I'm not using AUs at all—just MIDI and AudioKit. So I don't have a Sampler AU. Ideally, I'd like to use a "dummy" MIDI endpoint. Possible?

iOS MusicPlayer: suppress sine tone playback
 
 
Q