Проигрывание AudioBufferList с использованием AVAudioEngine с некоторым эффектом
Можно ли предложить способ воспроизведения AudioBufferList, хранящегося в кольцевом буфере, с использованием AVAudioEngine.
- (void)configureAudioEngine {
engine = [[AVAudioEngine alloc] init];
playerNode = [[AVAudioPlayerNode alloc] init];
[engine attachNode:playerNode];
AudioUnit outputUnit = engine.outputNode.audioUnit;
OSStatus err = noErr;
AudioDeviceID outputDeviceID;
UInt32 propertySize;
AudioObjectPropertyAddress propertyAddress = {
kAudioHardwarePropertyDefaultSystemOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster };
propertySize = sizeof(outputDeviceID);
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize, &outputDeviceID);
if (err) { NSLog(@"AudioHardwareGetProperty: %d", (int)err); return; }
err = AudioUnitSetProperty(outputUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &outputDeviceID, sizeof(outputDeviceID));
if (err) { NSLog(@"AudioUnitSetProperty: %d", (int)err); return; }
AudioUnitInitialize(outputUnit);
AVAudioUnitDistortion *distortionEffect = [[AVAudioUnitDistortion alloc] init];
[engine attachNode:distortionEffect];
[engine connect:playerNode to:distortionEffect format:[distortionEffect outputFormatForBus:0]];
mixer = [engine mainMixerNode];
[engine connect:distortionEffect to:mixer format:[mixer outputFormatForBus:0]];
[distortionEffect loadFactoryPreset:AVAudioUnitDistortionPresetDrumsBitBrush];
NSError *error;
if (![engine startAndReturnError:&error])
NSLog(@"Can't start engine: %@", error);
}
я просто хочу воспроизвести audioBufferList из
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
AudioBufferList *abl = [self MakeAndAllocateAudioBufferList:sampleBuffer];
//
}
Этот буфер будет добавлен в RoundBuffer и хотите играть с использованием AVAudioEngine.