如何从音频队列缓冲区中提取整数样本并将修改后的样本写回?

发布于 2024-10-14 22:30:38 字数 536 浏览 12 评论 0原文

对于iPhone语音更改应用程序(目标c),我试图从录音音频队列缓冲区中获取采样的整数值,在函数中处理它们并将修改后的值写回播放缓冲区。 目前,我使用类似的方法

AudioBuffer audioBuffer = bufferList->mBuffers[0];
int bufferSize = audioBuffer.mDataByteSize / sizeof(SInt32);
SInt32 *frame = audioBuffer.mData;
SInt32  signalInput[22050];
for( int i=0; i<bufferSize; i++ ) {
    SInt32 currentSample = frame[i];
    *(signalInput +i) = currentSample;
}

来提取采样值,并且似乎工作得很好(信号输入应该是用于写入整数样本的目标向量)。 但将它们写回到缓冲区仍然是一个问题...... 我搜索了文档和很多论坛来寻找解决方案,但尚未成功。

所以我非常感谢任何建议, 预先感谢,卢卡斯

for an iphone voice changing app (objective c), i am trying to take the sampled integer values from the recording audio queue buffer, process them in a function and write the modified values back to the play back buffer.
At the moment i use something like this

AudioBuffer audioBuffer = bufferList->mBuffers[0];
int bufferSize = audioBuffer.mDataByteSize / sizeof(SInt32);
SInt32 *frame = audioBuffer.mData;
SInt32  signalInput[22050];
for( int i=0; i<bufferSize; i++ ) {
    SInt32 currentSample = frame[i];
    *(signalInput +i) = currentSample;
}

to extract the sampled values and seems to work pretty fine (signalinput is supposed to be the target vector for writing the integer samples).
but writing them back to a buffer is still a problem...
i searched the documentation and lots of forums to find a solution, but didnt succeed yet.

so id be very thankful for any advice,
thanks in advance, lukas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久隐师 2024-10-21 22:30:38

如果您想实时修改音频,您可能需要尝试使用 RemoteIO 音频单元。

使用音频队列时,您必须保存来自录制队列回调的数据,然后在不同时间的不同回调中将处理后的数据提供给播放队列回调。为此,您可能必须使用中间队列或数据缓冲区。为了使其正常工作,尝试运行一个录音应用程序,然后运行一个示例播放应用程序,然后将两者结合起来可能会有所帮助。

添加:

以下是将示例值写入音频输出队列的一些源代码示例:

http://lists.apple.com/archives/coreaudio-api/2008/Dec/msg00173.html
https://bitbucket.org/ddribin/a440/wiki/Home

只需使用您自己的预处理样本而不是正弦波。

If you want to modify audio in real-time you might want to try using RemoteIO Audio Unit instead.

When using audio queues, you have to save the data from the recording queue callback and later feed the processed data to the play queue callback, in a different callback at a different time. For this you probably have to use an intermediate queue or data buffer(s). To get this working, it might help to try to get a recording sound app running, and then a sample playing app running, then combining the two.

Added:

Here are some source code example's of writing sample values into an audio output queue:

http://lists.apple.com/archives/coreaudio-api/2008/Dec/msg00173.html
https://bitbucket.org/ddribin/a440/wiki/Home

Just use your own pre-processed samples instead of a sine wave.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文