循环声音闪光 as3 的首选方法 [英] Prefered method for looping sound flash as3

查看:23
本文介绍了循环声音闪光 as3 的首选方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Flash AS3 中循环播放声音时遇到了一些问题,因为当我让声音循环播放时,我在音频的结尾/开头出现了轻微的延迟.

I'm having some issues with looping a sound in flash AS3, in that when I tell the sound to loop I get a slight delay at the end/beginning of the audio.

音频被正确剪辑,可以在车库乐队中无间隙播放.

The audio is clipped correctly and will play without a gap on garage band.

我知道 Flash 中通常存在声音问题、编码错误以及 SOUND_COMPLETE 事件的不准确(并且 Adob​​e 应对这些问题的处理感到尴尬)

I know that there are issues with sound in general in flash, bugs with encodings and the inaccuracies with the SOUND_COMPLETE event (And Adobe should be embarrassed with their handling of these issues)

我尝试在 Sound 类的 play 方法中使用内置循环参数并对 SOUND_COMPLETE 事件做出反应,但两者都会导致延迟.

I have tried to use the built in loop argument in the play method on the Sound class and also react on the SOUND_COMPLETE event, but both cause a delay.

但是有没有人想出一种技术来循环播放没有任何明显间隙的声音?

But has anyone come up with a technique for looping a sound without any noticeable gap?

推荐答案

如果您可以使用 Flash Player 10,最可靠的方法是使用新的 SampleDataEvent.SAMPLE_DATA 事件.

The most reliable method, if you can use Flash Player 10, is to use the new SampleDataEvent.SAMPLE_DATA event.

具体来说,你要做的就是首先实例化你想要的声音,然后使用新的提取方法将声音转换成以 ByteArray 编码的原始 PCM 数据.然后你可以创建一个新的 Sound 对象,并设置监听它的 SampleDataEvent.SAMPLE_DATA 事件.当该事件被调用时,您将从 ByteArray 推送 2-8k(较低的数量会减少延迟,但会增加可听见的伪影的可能性)数据.您只需确保当您从 ByteArray 的末尾运行时,您将循环回到开头.

Specifically, what you do is to first instantiate the sound you want, then use the new extract method to convert the sound into raw PCM data encoded in a ByteArray. Then you can create a new Sound object, and setup to listen for it's SampleDataEvent.SAMPLE_DATA event. When that event is called you'll push 2-8k (a lower amount reduces latency, but increases the possibility of audible artifacts) of data from the ByteArray. You'll just make sure that as you run off the end of the ByteArray you'll just loop back to the beginning.

此方法可确保您拥有完全无间隙的播放.

This method ensures that you'll have fully gapless playback.

这篇关于循环声音闪光 as3 的首选方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆