带偏移量的循环 OpenAL 源
OpenAL API 规定,设置偏移量仍然会导致循环源的声音循环回零。但是有没有一种方法可以循环并且仍然有一定的偏移量?
我有一个 mp3,由于它在文件开头包含带有信息的标题,因此在倒带时循环有一个小但明显的延迟。
如果没有,是否还有其他不包含这些空标头的压缩格式?
The OpenAL API states that an setting an offset still causes the sound to loop back to zero for looping sources. But is there a way to loop and still have an offset somehow?
I have an mp3, and since it contains headers with information at the start of the file, there's a small, but noticable, delay in looping when it rewinds.
If not, are there any other compressed formats that don't contain these empty headers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许你的延迟也可以代表解压缩 MP3 数据的时间?如果您的数据小到足以循环播放,您是否可以使用 API 将 MP3 解压缩为 PCM,然后将未压缩的数据提供给 AL?
另一种选择:您不必只使用一个缓冲区。您可以使用 alSourceQueueBuffers() 将它们排队。当您以这种方式进行流式传输时,AL 可以立即从一个缓冲区的末尾移动到下一个缓冲区的开头。因此,您可以将两个或三个缓冲区的数据排入队列,然后轮询源以查看第一个数据何时被消耗,然后将另一个数据排入队列。基本上,这会让你负责循环。
Maybe your delay could also represent the time to decompress the MP3 data? If your data is small enough to loop anyways, could you use an API to decompress the MP3 to PCM, and then just feed that uncompressed data to AL?
Another option: you don't have to use just one buffer. You can queue them up with alSourceQueueBuffers(). When you stream this way, AL can move immediately from the end of one buffer to the start of the next. So you could enqueue two or three buffers worth of data, then poll the source to see when the first one has been consumed, and enqueue another one. Basically, this would make you responsible for the looping.