问题描述
我正在开发一个录制声音的应用程序.此外,我希望用户能够用自己的声音评论某些情况.我认为配置一个音频会话并仅创建两个具有不同文件URL的AVAudioRecorder实例就足够了.但这不起作用,第二个录音机确实创建了其音频文件,但没有录制任何声音.
i'm working on an app that records sound.furthermore, i want the user to be able to comment certain situations with his own voice.i thought it would be sufficient to configure one audio session and just create two AVAudioRecorder instances with different file URLs.but that doesn't work, the second audio recorder does create its audio file, but it doesn't record any sound.
有人知道如何实现两个实际上在一台设备上工作的AVAudioRecorder实例吗?
does anyone know how to realize two AVAudioRecorder instances that actually work on one device?
仅使用一个AVAudioRecorder录制即可,但不能同时使用.
recording with only one AVAudioRecorder works, but using both doesn't work.
我有一个解决方法,但这是我现在想避免的一堆代码...
i have a workaround in mind, but that's a bunch of code i would like to avoid at the moment...
谢谢!
推荐答案
解决了该问题:音频会话不是问题,这是音频格式.
figured the problem out:the audio session is not the problem, it's the audio format.
如果要使用多个AVAudioRecorder记录到多个文件中,则必须使用未压缩的音频格式.我假定一个AVAudioRecorder使用了HW辅助编码,因此每隔一个AVAudioRecorder都无法同时使用它.
if you want to record into multiple files using multiple AVAudioRecorders, you have to use uncompressed audio format(s).i assume the HW assisted encoding is used by one AVAudioRecorder and thus every further AVAudioRecorder can't use it simultaniously.
使用压缩格式(例如 kAudioFormatMPEG4AAC )的一个AVAudioRecorder可以正常工作,但每个其他录音机都必须使用未压缩的音频格式.如果所有AVAudioRecorder实例都使用未压缩的格式(例如 kAudioFormatLinearPCM ),则它也可以工作.
one AVAudioRecorder using a compressed format (e.g. kAudioFormatMPEG4AAC) works fine, but every further recorder has to use an uncompressed audio format. if all AVAudioRecorder instances use a uncompressed format (e.g. kAudioFormatLinearPCM) it also works.
这篇关于多个AVAudioRecorder实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!