gpt4 book ai didi

iphone - 如何更改 aurioTouch 项目以将录音写入 .caff 或 .wav 文件

转载 作者:行者123 更新时间:2023-11-29 04:32:37 27 4
gpt4 key购买 nike

我正在调查aurioTouch2示例代码。

我想更改一些方法以从麦克风录制音频并将这些数据写入 .caff 或 .wav 文件。所以稍后我将能够使用 AVAudioPlayer 播放此音频。

我的想法是在 applicationDidFinishLaunching 中使用 AVAudioRecorder,但可能不是最好的解决方案,或者甚至可能通过这种方式不可能(我没有尝试使用 AVAudioRecorder,因为我认为它很可能不是最好的主意)。我尝试在

中写入字节数据
void FFTBufferManager::GrabAudioData(AudioBufferList *inBL)
{
memcpy(mAudioBuffer+mAudioBufferCurrentIndex, inBL->mBuffers[0].mData, bytesToCopy);
// after this I copy to my own buffer and collect all the data during 30 seconds
}

如您所见,我复制到自己的缓冲区并在 30 秒内收集所有数据。比我将数据写入 .caff 文件。那是行不通的。

更新:

或者可能存在播放音频二进制数据(未编码为 .waf 或 .caff 音频)的方式?

最佳答案

有几种不同的方法可以做到这一点。一种方法是使用 ExtAudioFileWriteAsync .

Apple 提供了一个示例项目来演示如何执行此操作。这是RecordAudioToFile .

也可以看看其他一些帖子,例如Can anybody help me in recording iPhone output sound through Audio Unit

关于iphone - 如何更改 aurioTouch 项目以将录音写入 .caff 或 .wav 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11518441/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com