有谁知道如何修改“在这里说话”示例代码来录制流音频?
有谁知道如何修改Apple的代码在这里说话。我需要修改它以使用 Matt Gallagher 录制流音频AudioStreamer 类,但不知何故我找不到如何选择录音源...
你能帮忙吗?
Does anyone know how to modify the code Speak Here from Apple. I need to modify it to record streaming audio using Matt Gallagher AudioStreamer classes but somehow I can't find how to select the recording source...
Could you help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有这样做,但我已经使用过 Matt 的 AudioStreamer 类相当多了,这确实是您想要扩展的项目 - 而不是 SpeakHere。 (流音频部分是其中最复杂的部分)。
您要做的就是首先设置要写入的文件,然后在 AudioStreamer.m 中有两个位置将网络数据缓冲区复制到音频队列缓冲区 - 两者都用此 // 将数据复制到音频队列缓冲区进行注释。在这些行之后添加写入文件的逻辑(使用 AudioFileWritePackets)。我猜想文件写入速度足够快,可以立即在此处执行此操作。如果没有(如果音频播放跳过或中断),那么您需要为文件写入设置一个循环缓冲区,复制字节并从后台线程调用 AudioFileWritePackets。
I haven't done this but I have used Matt's AudioStreamer class quite a bit and that's really project you want to extend - not SpeakHere. (The streaming audio part is the most complex part of this).
What you would do is first setup your file for writing and then in AudioStreamer.m there are two places where the network data buffer is copied to the audio queue buffer - both are noted with this // copy data to the audio queue buffer. After those lines add the logic to write to the file (using AudioFileWritePackets). I would guess that the file write is fast enough to do this right here, immediately. If not (if the audio playback skips or breaks up) then you'd want to set up a circular buffer for file writing, copy the bytes and call the AudioFileWritePackets from a background thread.