user513790
user513790

Reputation: 1235

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];
}

Upvotes: 7

Views: 2275

Answers (2)

Ahmad Karim
Ahmad Karim

Reputation: 479

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]; 

Upvotes: 4

Karun
Karun

Reputation: 890

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];

You can apply filters at the time of playing the recorded audio.

Upvotes: 0

Related Questions