Link to home
Start Free TrialLog in
Avatar of ForLoop5
ForLoop5Flag for United States of America

asked on

gapless sync and playback audio as3

I have 37 sounds that are all the same bpm.  I would like them to sync with each other when their button is clicked to be played.  
Currently I sync the sounds to a background sound using the sound_complete listener. It works but
the sound become slightly out of sync becuse I am relying on the flash sound_complete event listener.   If I just loop them play(0,9999); they loop great but I cannot sync them with each other.   Any solutions to this?

var sndSync:Sound = new b3();
var chnSync:SoundChannel=sndSync.play();
var myVolume003:Number=0; 
    var myTransform003:SoundTransform=new SoundTransform(myVolume003); 
        chnSync.soundTransform=myTransform003; 
		
chnSync.addEventListener(Event.SOUND_COMPLETE, loopSoundf);
function loopSoundf(e:Event):void{
	   
		chnSync = sndSync.play();
		chnSync.addEventListener(Event.SOUND_COMPLETE, loopSoundf);
		chnSync.soundTransform=myTransform003; 
		  
	}
	
	syncer.addEventListener(MouseEvent.MOUSE_DOWN,soundonlySync);
	stopper.addEventListener(MouseEvent.MOUSE_DOWN,soundonlySync);
function soundonlySync(event:MouseEvent){
		chnSync.stop();
		chnSync = sndSync.play();
		chnSync.soundTransform=myTransform003; 
		chnSync.addEventListener(Event.SOUND_COMPLETE, loopSoundf);
	}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tailoreddigital
tailoreddigital
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial