从同一文件同时录制和播放
我第一次尝试使用音频队列服务。在阅读了所有文档并使用了一些示例代码之后,我认为我很好地理解了这些类,并且已经实现了我自己的播放和录制应用程序,没有任何问题。
我需要同时从同一个缓冲区进行录制和播放,但同时写入文件和读取文件时遇到了一些重大困难。我可以毫无问题地播放文件,但仅限于播放开始之前的最后写入的缓冲区。我希望只要文件被写入,就可以继续播放该文件。这可能吗?
提前致谢!
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将捕获的数据保存在您自己的缓冲区中而不是写入文件可能是值得的。然后您可以将这些缓冲区提供给播放。
请确保从 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.