我有一个 MIDI 合成器
AudioComponentDescription midiSynthDesc;
midiSynthDesc.componentType = kAudioUnitType_MusicDevice;
midiSynthDesc.componentSubType = kAudioUnitSubType_MIDISynth;
midiSynthDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
midiSynthDesc.componentFlags = 0;
midiSynthDesc.componentFlagsMask = 0;
它曾经在一个AUGraph中。但是由于不推荐使用 AUGraph,我使用 AudioComponentInstanceNew 来创建它,而不使用 AUNode 和 AUGraph
AudioComponent foundMIDISynthReference = AudioComponentFindNext ( NULL, &midiSynthDesc);
AudioComponentInstanceNew(foundMIDISynthReference, &midiSynthUnit);
我通过将序列附加到 AUGraph 来使用它来播放序列
NSString *presetURLPath = [[NSBundle mainBundle] pathForResource:@"GortsMiniPianoJ1" ofType:@"SF2"];
NSURL * presetURL = [NSURL fileURLWithPath:presetURLPath];
[self loadFromDLSOrSoundFont: (NSURL *)presetURL withPatch: (int)3];
NSString *midiFilePath = [[NSBundle mainBundle] pathForResource:name ofType:@"mid"];
NSURL * midiFileURL = [NSURL fileURLWithPath:midiFilePath];
NewMusicPlayer(&musicPlayer);
MusicPlayerSetSequence(musicPlayer, musicSequence);
MusicSequenceSetAUGraph(musicSequence, _processingGraph);
MusicPlayerPreroll(musicPlayer);
MusicPlayerStart(musicPlayer);
但是现在 AUGraph 已被弃用,仅使用 AudioUnit,我如何在 Core Audio 中使用 Play MIDI Files?