the amazing audio engine how to apply filters to microphone input

Im trying to make karaoke app that records the background music from file and the microphone. I also want to add filter effects to the microphone input.

i can do everything stated above using the amazing audio engine sdk but i cant figure out how to add the microphone input as a channel so i can apply filters to it (and not to the background music.)

any help would be appreciated.

my current recording code:

- (void)beginRecording {
// Init recorder
 self.recorder = [[AERecorder alloc] initWithAudioController:_audioController];
NSString *documentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,   NSUserDomainMask, YES) 
                               objectAtIndex:0];
  NSString *filePath = [documentsFolder stringByAppendingPathComponent:@"Recording.aiff"];
// Start the recording process
NSError *error = NULL;
if ( ![_recorder beginRecordingToFileAtPath:filePath 
                                   fileType:kAudioFileAIFFType 
                                     error:&error] ) {
   // Report error
   return;
}
// Receive both audio input and audio output. Note that if you're using
// AEPlaythroughChannel, mentioned above, you may not need to receive the input again.
[_audioController addInputReceiver:_recorder];
[_audioController addOutputReceiver:_recorder];
}

You can separate your your back ground music and your mic by using different channels and then you can apply the filter to your mic channel only.

first declare a channel group in the header file

AEChannelGroupRef _group;

then simply add the player that you are using for recorded file to this group

[_audioController addChannels:@[_player] toChannelGroup:_group ];

and then add the filter to this group only

[_audioController addFilter:_reverb toChannelGroup:_group]; 

self.reverb = [[[AEAudioUnitFilter alloc] initWithComponentDescription:AEAudioComponentDescriptionMake(kAudioUnitManufacturer_Apple, kAudioUnitType_Effect, kAudioUnitSubType_Reverb2) audioController:_audioController error:NULL] autorelease];

AudioUnitSetParameter(_reverb.audioUnit, kReverb2Param_DryWetMix, kAudioUnitScope_Global, 0, 100.f, 0);

[_audioController addFilter:_reverb];

您可以在播放录制的音频时应用滤镜。

链接地址: http://www.djcxy.com/p/13692.html

上一篇: 使用Vim中的Pry调试器样式断点

下一篇: 令人惊叹的音频引擎如何将滤波器应用于麦克风输入