如何用AVAudioRecorder录制wav格式的声音
答案:1 悬赏:80
解决时间 2021-12-23 21:00
- 提问者网友:冷场帝
- 2021-12-22 22:18
如何用AVAudioRecorder录制wav格式的声音
最佳答案
- 二级知识专家网友:桃花别处起长歌
- 2021-12-22 22:59
1. 在项目中导入AVFoundation框架
2. 在相应的.h文件中,引入
3. 在相应的.h文件中,声明一个AVAudioRecorder的实例变量
4. 在相应的.m文件中,初始化这个实例变量
5. o NSURL *url=[NSURL fileURLWithPath:savePath]; o NSDictionary *settings=[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey, [NSNumber numberWithFloat:22050.0], AVSampleRateKey, [NSNumber numberWithInt:1], AVNumberOfChannelsKey, nil]; o NSError *error; o audioRecorder=[[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error]; o if (error) NSLog(@%@, [error description]); o [audioRecorder prepareToRecord];
6. 初始化之后,在需要录音的地方,调用[audioRecorder record];
2. 在相应的.h文件中,引入
4. 在相应的.m文件中,初始化这个实例变量
5. o NSURL *url=[NSURL fileURLWithPath:savePath]; o NSDictionary *settings=[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey, [NSNumber numberWithFloat:22050.0], AVSampleRateKey, [NSNumber numberWithInt:1], AVNumberOfChannelsKey, nil]; o NSError *error; o audioRecorder=[[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error]; o if (error) NSLog(@%@, [error description]); o [audioRecorder prepareToRecord];
6. 初始化之后,在需要录音的地方,调用[audioRecorder record];
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯