Flash 中连续声音的无缝播放

发布于 2024-07-24 04:38:08 字数 258 浏览 7 评论 0 原文

我正在制作一个闪光灯,它基本上是一个非常简单的跟踪器。 我的问题是关于顺序播放,更具体地说是时序问题。

SoundChannel 对象方便地提供了 SoundCompleted 事件,但依赖该事件会导致声音之间产生微小的间隙,这(遗憾的是)使其毫无用处。

到目前为止,我所设法挖掘的只是使用每毫秒触发事件并手动观察开始下一个声音的滴答声的教程。 这似乎有点黑客行为并且不必要地浪费资源。

有没有更好的方法通过无缝播放来按顺序计时声音?

I'm making a flash, which is basically a very simple tracker. My question is about sequential playback and more specifically timing problems.

The SoundChannel-object conveniently provides a SoundCompleted-event, but relying on that results in tiny gaps between sounds, which (sadly) makes it useless.

All I've managed to dig up so far, are tutorials using events triggering every millisecond and manually watching for the tick where to start the next sound. This seems a little hackish and unnecessarily resource wasteful.

Is there a better way to timing sounds sequentially with gapless playback?

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

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

发布评论

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

评论(2

只是偏爱你 2024-07-31 04:38:08

如果您以毫秒为单位查询当前声音的时间(或剩余时间),并且 为该时间段设置一个超时,并在超时处理程序中开始下一个声音,这样可以吗? 这不是我尝试过并发现可靠的东西,但超时处理程序将在 Flash Player 可以管理的最接近直接时间的情况下被调用(无论帧速率等如何)。 因此,如果它不起作用,我真的无法想象还有什么会起作用,除非它是估计需要多少 MS 余地的某种变化,并尝试在当前声音预定之前 5 毫秒或其他时间开始下一个声音。结尾。

If you query the current sound's time (or remaining time) in milliseconds, and set a timeout for that period, and begin the next sound in the timeout handler, would that work? It's not something I've tried and found reliable, but timeout handlers will get called as close to the direct time as the Flash Player can manage (regardless of framerate, etc). So if it doesn't work, I can't really imagine what else would, unless it was some variation of estimating how many MS of leeway are required, and trying to start the next sound 5ms or whatever before the current one is scheduled to end.

话少心凉 2024-07-31 04:38:08

这可能有效,但超时并不独立于帧速率,或者不完全独立。 正如您所说,它们的触发尽可能接近设置的超时,但我发现根据帧速率,精确度存在一些变化。

但对于最初的问题,我做了一些研究,我自己回答了

That could work, but timeouts are not independent of framerate, or not entirely anyway. They trigger, as you say, as close to the set timeout as possible but I've found that there is some variation in the exactness depending on the framerate.

But as to the original problem, I did some research and answered it myself.

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