I have a screen that is like an instrument. There are buttons that play sound files.
I want to record the sounds played as user presses the buttons in a single audio file so that i can save that file as mp4 or other audio format.
Can you please guide me how to achieve this in a simple way?
I am able to record using the mic with AVAudioRecorder
As I think, the recording method uses the mic as a source, but I would like it to use the "audio out" equivalent of my app to use as a source.
You could try using The Amazing Audio Engine. You can install it via Cocoapods
pod 'TheAmazingAudioEngine'
or clone via git
git clone --depth=1 https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine.git
The sound could be recorded to a file with the help of this.
So if you want to record the apps output simply use a Outputreceiver:
@property (nonatomic, strong) AEAudioController *audioController;
@property (nonatomic, strong) AERecorder *recorder;
...
self.audioController = [[AEAudioController alloc] initWithAudioDescription:[AEAudioController nonInterleaved16BitStereoAudioDescription] inputEnabled:YES];
...
//start the recording
- (void) beginRecording{
self.recorder = [[AERecorder alloc] initWithAudioController:self.audioController];
NSString *documentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
//the path to record to
NSString *filePath = [documentsFolder stringByAppendingPathComponent:@"AppOutput.aiff"];
//start recording
NSError *error = NULL;
if ( ![_recorder beginRecordingToFileAtPath:filePath fileType:kAudioFileAIFFType error:&error] ) {
//an error occured
return;
}
[self.audioController addOutputReceiver:self.recorder];
}
...
//end the recording
- (void)endRecording {
[self.audioController removeOutputReceiver:self.recorder];
[self.recorder finishRecording];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With