实时音频队列录音回放
嘿伙计们, 我正在尝试构建一个用于实时变声的应用程序。 第一步,我设法将音频数据录制到指定文件并在录制后播放。 现在我尝试更改在循环录制音频缓冲区后立即播放音频缓冲区的代码。 我的问题是,如何直接从录音音频队列中读取音频数据,而不是(如文档中所示)从文件中读取音频数据。 我感谢您的任何想法,如果需要,可以显示代码部分。 提前致谢, 卢卡斯(来自德国)
Hey fellows,
Iam trying to build an application for realtime voicechanging.
In a first step I managed to record audiodata to a specified file and to play it after recording.
Now I try to change the code for playing back the audiobuffers right after recording them in loop.
My question is, how it is possible to read the Audiodata directly from the recording Audioqueue and not (like shown in documentation) from a file.
Iam thankful for any ideas and could show code-parts if needed.
Thanks in advance,
Lukas (from Germany)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下 SpeakHere 示例。此行提供音频数据:
因此,您可以使用 memcpy 复制录制的数据缓冲区,而不是调用
AudioFileReadPackets
。或者,向播放AudioQueue
提供一个指向音频数据缓冲区的指针。当播放继续时,在缓冲区中前进mCurrentPacket
指针。为了录制,您将执行非常类似的操作。您将写入内存中的缓冲区,而不是写入文件。您首先需要使用
malloc
来分配它。然后,您传入的 AudioQueue 捕获记录的数据,您将该数据复制到缓冲区。随着更多数据被复制,您将记录磁头或mCurrentPacket
前进到新位置。Have a look at the SpeakHere example. This line sources the audio data:
So, rather than call
AudioFileReadPackets
, you can just use a memcpy to copy over the recorded data buffer. Or, alternatively, supply to the playbackAudioQueue
a pointer to the audio data buffer. As playback continues, advance amCurrentPacket
pointer through the buffer.To record, you'll do something very similar. Rather than writing out to a file, you'll write out to a buffer in memory. You'll first need to allocate that with a
malloc
. Then are your incomingAudioQueue
captures recorded data, you copy that data to the buffer. As more data is copied, you advance the recording head, ormCurrentPacket
to a new position.