完成与 finch 的音频回调播放
是否有与芬奇一起完成播放的回调?类似于 avaudioplayer 中的 -audioPlayerDidFinishPlaying?查看代码我找不到任何引用它的内容。
is there a finished playing callback with finch? similar to - audioPlayerDidFinishPlaying in the avaudioplayer stuff? looking through the code i could not find anything that referenced it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Finch 中没有这样的回调,因为 OpenAL 不支持。 (或者至少当我上次查看时它不支持它。)您可以像这样伪造它:
我没有尝试过,但它是一个简单的代码,它应该可以正常工作。好吧……至少在你开始扰乱音调和声速之前:)
There is no such callback in Finch, because OpenAL does not support it. (Or at least it did not support it when I last looked.) You can fake it like this:
I did not try it, but it’s a simple code, it should work fine. Well… at least until you start messing with the pitch and therefore the sound speed :)
@zoul:我知道这是一个很晚的回复。但我注意到答案不正确。如果我暂停声音或系统中断怎么办?在这种情况下,即使声音尚未完成,您也会收到回调。请阅读 openAL 规范中的“4.3.6. 管理源执行”段落以进行正确处理。
@zoul: I know this is a vey late reply. But I noticed that the answer is not correct. What if I pause the sound or if there is an interruption from system. In such case, you will receive a callback even if the sound is not completed yet. Please read paragraph "4.3.6. Managing Source Execution" from openAL specs for correct handling.
如果您不关心中断,这里有一个解决音调问题的技巧。
OpenAL 更改音调不是 1.0 时播放的声音的播放长度。
(似乎不可能从 OpenAL 查询这个新长度,
因为 AL 参数返回与之前相同的值)
音高范围从 0.5 到 2.0f。因此,如果我们假设 0.5 的音高正好是两倍长,
并且音高在 2.0 时正好是一半长,我们应该能够使用音高作为倍数:
Here's a hack with a pitch fix if you don't care about interrupts.
OpenAL changes the playing length of the sound played when pitch is not 1.0.
(it doesn't seem possible to query this new length from OpenAL,
as the AL parameters return the same values as before)
Pitch ranges from 0.5 to 2.0f. So, if we assume pitch at 0.5 is exactly twice as long,
and pitch at 2.0 is exacty half as long, we should be able to use pitch as a multipler: