从同一文件同时录制和播放

发布于 2024-08-18 18:30:55 字数 211 浏览 5 评论 0原文

我第一次尝试使用音频队列服务。在阅读了所有文档并使用了一些示例代码之后,我认为我很好地理解了这些类,并且已经实现了我自己的播放和录制应用程序,没有任何问题。

我需要同时从同一个缓冲区进行录制和播放,但同时写入文件和读取文件时遇到了一些重大困难。我可以毫无问题地播放文件,但仅限于播放开始之前的最后写入的缓冲区。我希望只要文件被写入,就可以继续播放该文件。这可能吗?

提前致谢!

I'm attempting to use Audio Queue Services for the first time. After reading all the documentation and playing with some sample code, I think I understand the classes pretty well and have implemented my own playback and recording application without any problems.

I need to simultaneously record and play from the same buffer, but I'm having some significant difficulty writing to a file and reading from the file at the same time. I can get the file to be played back with no problem but only for the last written buffer before the playing started. I'm hoping it's possible to continue to playback the file for as long as it's being written to. Is this possible?

Thanks in advance!

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

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

发布评论

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

评论(1

夏花。依旧 2024-08-25 18:30:55

将捕获的数据保存在您自己的缓冲区中而不是写入文件可能是值得的。然后您可以将这些缓冲区提供给播放。

请确保从 AVFoundation 框架添加以下行以同时捕获和播放:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];

希望这有帮助。

It might be worthwhile to save the captured data in your own buffers instead of writing to a file. You can then supply these buffers to the playback.

Please make sure that you add the following line from AVFoundation framework for simultaneous capture and playback:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];

Hope this helps.

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