开发者

Mix and playback multiple tracks Actionscript 3

I am creating a sound mixer in AS3. I have several sound samples that a user can choose from to create their own track. The mixer will "mixdown" a max of 4 tracks and playback the "mixed" track on demand. I'm having trouble getting the sounds to playback in sync. I'm new to working with sound in flash and wondering what I'm missing... Here is the "mix" function at present:

function mixIt(e:MouseEvent) {

    if (isPlaying) {
    channel1.stop();
            }
    var mChannel1:SoundChannel = new SoundChannel;
    var mChannel2:SoundChannel = new SoundCha开发者_如何学编程nnel;

    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);
     }
}


try mixing sounds as byte arrays using Sound.extract() and SampleDataEvent

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜