2011-09-26 46 views
0

我在AS3創建一個混音器。我有幾個聲音樣本,用戶可以選擇創建自己的曲目。調音臺將「混音」最多4首曲目並按需播放「混合」曲目。我無法同步播放聲音。我是新來的閃光與良好的工作,不知道我錯過了什麼......這是目前「混合」功能:混合和重放多軌Actionscript 3

function mixIt(e:MouseEvent) { 

    if (isPlaying) { 
    channel1.stop(); 
      } 
    var mChannel1:SoundChannel = new SoundChannel; 
    var mChannel2:SoundChannel = new SoundChannel; 

    var tUrl1:URLRequest = new URLRequest(trackChoice1); 
    var tUrl2:URLRequest = new URLRequest(trackChoice2); 
    var s1:Sound = new Sound(); 
    var s2:Sound = new Sound(); 

    var s1Done:Boolean = false; 
    var s2Done:Boolean = false; 

      s1.addEventListener(Event.COMPLETE, onSoundLoaded1); 
    s2.addEventListener(Event.COMPLETE, onSoundLoaded2); 

      s1.load(tUrl1); 
    s2.load(tUrl2); 

    function onSoundLoaded1(e:Event) { 
     s1Done = true; 
     if (s2Done) { 
     playMix() 
     } 
    } 
    function onSoundLoaded2(e:Event) { 
     s2Done = true; 
     if (s1Done) { 
      trace("s2 Done") 
      playMix() 
     } 
    } 
    function playMix(){ 
    mChannel1 = s1.play(0, 2); 
    mChannel2 = s2.play(0, 2); 
    //trace("MIXING TRACKS :" + tUrl1 + " + " + tUrl2); 
    } 
} 

回答

1

嘗試混合聲音的字節數組使用Sound.extract()SampleDataEvent

+0

將放棄它,謝謝! – RichMase

+0

好的,所以我可以單獨提取音頻,它回放沒有問題。但是我在實際上「混合」聲音方面遇到了一些困難。我應該將字節存儲在單個聲音對象中以播放嗎?那可能嗎?對不起,在AS中有新的聲音,並且在線上沒有大量文檔。拉我的頭髮:) – RichMase

+0

我將不得不自己嘗試回答:)我會嘗試創建一個新的字節數組'SampleDataEvent'從字節總數在源bytearrays的相同位置 – www0z0k