iPhone 上的无缝动态音频循环

发布于 2024-09-18 07:17:53 字数 437 浏览 5 评论 0原文

好的,

所以我尝试将三个声音文件无缝循环在一起,第二个文件自身循环 n 次。假设我可以通过将它们连接在一起,让它们在另一个程序中无缝地循环在一起。但是,当我使用 avaudioplayer 的 audioPlayerDidFinishPlaying 委托方法时,对接会出现轻微的延迟(即使使用“prepareToPlay”方法也是如此。另一点复杂性是,中间的声音需要继续循环 n 次,AKA 只要 TouchDidEnd方法尚未被调用,此时程序将播放第三个也是最后一个剪辑以结束声音“播放列表”。

例如,观众在表演后鼓掌,声音文件 A 将包含最初的掌声、声音。文件 2 将包含人群以连续速率欢呼的可循环样本,直到用户抬起按钮,此时程序应进入第三个声音文件,这将是人群的掌声逐渐减弱

。使用 AVAudioPlayer 的初步尝试似乎不够快,无法无延迟地循环播放,所以我需要另一种更快的方法来做到这一点,有建议吗?

Ok,

So I am trying to seamlessly loop together three sound files with the second file being looped against itself n times. Let's assume I can get them to loop seemlessly together in another program by butting them together. however when I use audioPlayerDidFinishPlaying delegate method of avaudioplayer there is a slight delay in the butting together (even with using the "prepareToPlay" method. The other bit of complexity is that the middle sound needs to continue looping n times AKA as long as the touchesDidEnd method has not been called, at which point the program would play the 3rd and final clip to end the sound "playlist."

As an example think an audience giving applause after a show. sound file A would contain the initial swell of applause, sound file 2 would contain a loopable sample of the crowd cheering at a continuous rate until the user lifts up on the button, at which time the program should kick into the 3rd sound file, which would be the applause of the crowd tailing off.

So my initial attempt using AVAudioPlayer seemed not quick enough to loop back to back without delay so I need another quicker way to do this, suggestions?

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

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

发布评论

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

评论(1

初见终念 2024-09-25 07:17:53

对于循环,请查看 AVAudioPlayer 的 numberOfLoops 属性。比尝试使用玩家的委托自己处理循环逻辑效果更好。

至于从一个循环样本平滑地淡入“尾部”样本,这将很难用 AVAudioPlayer 实现。也许您最好的选择是使用尾随声音文件启动另一个播放器,并使用计时器在两个播放器之间快速交叉淡入淡出,使用每个播放器的 volume 属性。

如果这不令人满意(我怀疑可能不会),我认为您没有太多选择,只能使用 AudioQueue API 来完成此任务。

For the looping, check out the numberOfLoops property of AVAudioPlayer. Works better than trying to handle the loop logic yourself using the player's delegate.

As for fading smoothly from one looping sample to a 'tail' sample, that's going to be difficult to pull off with AVAudioPlayer. Probably your best bet is to start another player with the trailing sound file and use a timer to rapidly cross fade between the two using the volume property of each.

If that's not satisfactory (and I suspect it may not be) I don't think you'll have much choice but to drop down to the AudioQueue API to pull this off.

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