微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

flex – AS3中准确的BPM事件监听器

我正在尝试将动画同步到特定BPM的音乐.我尝试过使用Timer但是在处理小间隔时(毫秒)并不准确.我做了一些阅读,发现了另一种使用小型静音音频文件和SOUND_COMPLETE事件作为计时器的方法.

我用这段代码用了167ms长的声音文件.

package
{
    import flash.events.Event;
    import flash.events.Eventdispatcher;
    import flash.media.sound;
    import flash.media.soundChannel;
    import flash.net.URLRequest;

    public class BetterTimer extends Eventdispatcher
    {
        private var silentSound:Sound;

        public function BetterTimer(silentSoundUrl:String):void {
            super();
            silentSound = new Sound( new URLRequest(silentSoundUrl) );
            silentSound.addEventListener(Event.COMPLETE,start);
        }
        public function start():void {
            this.timerFired( new Event("start") );
        }
        private function timerFired(e:Event):void {
            dispatchEvent( new Event("fire") );
            var channel:SoundChannel = silentSound.play();
            channel.addEventListener(Event.soUND_COMPLETE,timerFired,false,true);
        }
    }
}

这仍然没有留下来. Flash Player是否具有声音准确性?

解决方法

这是非常棘手的正确!有一个名为 BeatTimer的小型lib试图这样做.我自己没有尝试过这个代码,但是如果它做了它声称它应该正是你需要的东西.

原文地址:https://www.jb51.cc/flex/174372.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐