如何使用混响效果保存录制的音频 [英] How to save a recorded audio with reverb effect

查看:163
本文介绍了如何使用混响效果保存录制的音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 theamazingaudioengine 来录制,播放和添加iOS应用程序的混响之类的效果.我可以录制,播放录制的音频以及混响效果.但是我无法将带有混响效果的音频文件保存到图库中.有人可以帮我吗?

I am using theamazingaudioengine for recording, playing and adding effects like reverb for an iOS app. I can record, play the recorded audio along with the reverb effect. But I am unable to save audio file with the reverb effect to the gallery. Can any one please help me with this.

我正在保存这样录制的音频.

I am saving the recorded audio like this.

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

NSArray *documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[documentsFolders objectAtIndex:0] stringByAppendingPathComponent:@"Recording.aiff"];

[library writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:path] completionBlock:^(NSURL *assetURL, NSError *error){

    /*notify of completion*/

    NSLog(@"AssetURL: %@",assetURL);
    NSLog(@"Error: %@",error);

    if (!error) {
        //video saved

        [[self appDelegate] showAlertWithTitle:@"Audio Saved" message:@""];

    }
    else{

        [[self appDelegate] showAlertWithTitle:@"Error" message:error.domain];

    }

}];

提前谢谢!

推荐答案

AEAudioFileWriter类使您可以轻松地写入系统支持的任何音频文件格式.

The AEAudioFileWriter class allows you to easily write to any audio file format supported by the system.

要使用它,请使用initWithAudioDescription:实例化它,并传递您要使用的音频格式.然后,通过调用beginWritingToFileAtPath:fileType:error:开始操作,传入要记录到的文件的路径以及要使用的文件类型.常见的文件类型包括kAudioFileAIFFTypekAudioFileWAVETypekAudioFileM4AType(使用AAC音频编码)和kAudioFileCAFType.

To use it, instantiate it using initWithAudioDescription: , passing in the audio format you wish to use. Then, begin the operation by calling beginWritingToFileAtPath:fileType:error: , passing in the path to the file you'd like to record to, and the file type to use. Common file types include kAudioFileAIFFType, kAudioFileWAVEType, kAudioFileM4AType (using AAC audio encoding), and kAudioFileCAFType.

一旦开始写入操作,就可以使用C函数AEAudioFileWriterAddAudioAEAudioFileWriterAddAudioSynchronously将音频写入文件.请注意,从Core Audio线程写入音频时,仅应使用AEAudioFileWriterAddAudio,因为这是以不占用线程的方式异步完成的.

Once the write operation has started, you use the C functions AEAudioFileWriterAddAudio and AEAudioFileWriterAddAudioSynchronously to write audio to the file. Note that you should only use AEAudioFileWriterAddAudio when writing audio from the Core Audio thread, as this is done asynchronously in a way that does not hold up the thread.

完成后,调用finishWriting关闭文件.

When you are finished, call finishWriting to close the file.

更多信息...

这篇关于如何使用混响效果保存录制的音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆