Flash AS3 - OGG声音延迟(Adobe Alchemy库)

问题描述:

我想用键盘快捷键让现场鼓演奏。问题在于MP3在这种情况下不够好(编码器在声音开始时增加了随机静音),而且闪光本身也使延迟(我尝试使用已经缓冲的播放文件(specified_start_point_in_miliseconds))。所以我的解决方案是OGG(这种格式是无缝的)。 我使用Adobe Alchemy librarysimple frontend for it编译的swc文件。一切工作正常,OGG文件正在播放,但它仍然有很多延迟 - 无论它的外部或嵌入,以及如果它的第一或第n次。我需要一个解决方案,如何让声音播放速度与按键相同。 这是我很简单的例子代码:Flash AS3 - OGG声音延迟(Adobe Alchemy库)

import flash.display.Sprite; 
import flash.events.*; 
import flash.utils.ByteArray; 
import flash.events.SampleDataEvent; 
import com.mauft.OggLibrary.OggStream; 
import com.mauft.OggLibrary.OggEmbed; 

public class ogg extends Sprite 
{ 

    [Embed(source="/drumssnare2.ogg",mimeType="application/octet-stream")] private var OGG_FILE:Class //Embed Ogg file as binary stream 

    public function ogg() 
    { 
    var gameinfo:Sprite=new Sprite(); 
    gameinfo.graphics.beginFill(0x000000,1); 
    gameinfo.graphics.drawRect(0,0,240,16); 
    gameinfo.graphics.endFill(); 
    gameinfo.addEventListener(MouseEvent.CLICK, playOGG); 
    addChild(gameinfo); 
    //var streamTest:OggStream=new OggStream("http://127.0.0.1/~7z/drumssnare2.ogg"); 

     var embedTest:OggEmbed=new OggEmbed((new OGG_FILE) as ByteArray) //Create new instance of OggEmbed 

     function playOGG():void 
     { 
     //var streamTest:OggStream=new OggStream("http://www.vorbis.com/music/Hydrate-Kenny_Beltrey.ogg") 

     //streamTest.play(0); 
     embedTest.play(0); 

     } 
    } 
} 

我是有我与循环的Flash CS5.5项目的音频文件同样的问题。 我和我的音频总监花了太多时间在as3中寻找循环的快速和“无间隙”解决方案。 他制作了一个.aif文件,没有任何间隙,我将它导入到我的库中,从我的Main类调用。 然后,我们改变了声音属性,似乎是这样的:

http://s7.postimage.org/6me47lfzv/Screen_shot_2012_02_06_at_4_35_15_PM.png

在ActionScript我所说的.AIF文件是这样的:

var aifSound:AifSound = new AifSound(); 
//AifSound is the name of the file in the ActionScript tab 

//creates a new Sound Channel 
var scAif:SoundChannel = new SoundChannel(); 
scAif = aifSound.play(0,999, 1); 

OK,它给了我一个循环无间隙,延迟或性能并发症。 尝试一下并发布反馈!

ps .:对不起我的坏英语

谢谢你*!

+0

稍微好一点,但仍然太多延迟。在这里,我发给你[FLA,AS3很短的例子和原始声音文件](http://speedy.sh/WrXaf/gapless.zip)。您可以单击黑色区域或使用键盘上的任意键测试声音。我最喜欢重点测试,尝试播放一些简单的节奏节拍。 – speedy 2012-02-06 19:59:38

+0

嘿男人,试试它在其他电脑因为它在这里播放没有任何延迟!我在一个iMac核心2二重奏工作,并正常工作。 – 2012-02-06 20:33:52

+0

我在Core 2 Duo上工作,但PC。但是,无论如何,我需要它为大多数用户毫不拖延地工作(这也是一些较旧的电脑)。 – speedy 2012-02-06 20:45:52