AVAudioRecorder 中的仪表混乱
简而言之,我正在尝试根据 iPhone 麦克风输入流中的分贝读数对某些内容进行口型同步,但我得到的值并不完全是我想要的值。我正在使用 AVAudioRecorder 的peakPowerForChannel 和averagePowerForChannel。 (我知道这是一种相当简单的口型同步技术,但质量不是主要问题)。
当分贝数增加时,仪表会按照我想要的方式做出反应(声音越大,值越高,因此我可以将其映射到嘴巴的张开程度),但是当声音快速停止时,值会缓慢减小,如尽管声音逐渐减弱(即在一两秒内逐渐消失)——这不是我想要的。
有没有一种方法可以配置 AVAudioRecorder ,使其不具有这种“淡入淡出”效果,或者我可以使用它给我的值做一些事情来获得所需的输出?或者,我可以使用其他工具吗?
谢谢!
Simply put, I'm trying to lip-sync something based on the decibel reading from the mic input stream of an iPhone, and the values I'm getting aren't quite what I'm after. I'm using AVAudioRecorder's peakPowerForChannel and averagePowerForChannel. (I'm aware that this is a rather simplistic lip-sync technique, but quality isn't a major concern).
When the number of decibels increases, the meters react as I'd like them to (higher value when louder, so I can map this to the open-ness of the mouth) but when the sound stops quickly, the values decrease slowly, as though the sound was trailing off (i.e. fading to silence over a second or two) - not what I'd like.
Is there a way of configuring the AVAudioRecorder so that it doesn't have this 'fade' effect, or can I do something with the values that it gives me to get the desired output? Alternatively, is there another tool I can use?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将
meteringEnabled
属性重置为YES
,如下所示:每次您希望将级别重置为环境级别时调用此方法。这大约需要 0.02 秒,在此期间,电平将短暂降至 0 或 -120 dB,然后重置为环境温度。
或者,您可以使用:
这大约需要 0.05 秒,但在等待时间内级别不会降至 0。事实上,什么也不会发生,因为在这种情况下,记录器对象实际上需要 0.05 秒才能停止并再次开始记录。
You can reset the
meteringEnabled
property toYES
, like this:Call this every time you want the levels to reset to ambient levels. This takes about 0.02 seconds, and in that time the levels will briefly drop down to 0, or -120 dB before resetting to ambient.
Alternatively, you can use:
This takes about 0.05 seconds, but the levels won't drop down to 0 in the wait time. In fact, nothing will happen because in this case, it actually takes the recorder object 0.05 seconds to stop and start recording again.
AVAudioPlayer 上的仪表弹道符合您所期望的显示传统音频仪表的效果:振幅增加时瞬时增加,但振幅减小时低通。
对于会说话的卡尔类型的东西,您根据录制的音频为角色设置动画,您必须获取原始音频并适当调整您自己的计量响应。如果您要实时制作角色动画(即,当用户在设备的麦克风中讲话时),您可能需要使用 AudioQueue 或 RemoteIO 来获取音频数据。否则,如果您只是在录制后处理音频文件,则可以使用 ExtAudioFile 获取所需的数据。
The meter ballistics on AVAudioPlayer are what you'd expect for displaying traditional audio meters: Instantaneous for increases in amplitude, but lowpassed for decreases.
For the Talking Carl-type thing where you animate a character based on recorded audio you'll have to get at the raw audio and tweak your own metering response as appropriate. If you're animating the character live (i.e., while the user talks in the device's microphone) you'll probably want to use AudioQueue or RemoteIO to get at the audio data. Otherwise, if you're just processing an audio file after it's been recorded, you can get the data you need using ExtAudioFile.