Monday, March 29, 2010

Timing of sounds

Is there anyway to be more accurate with the timing of two
sound objects dynamically in actionscript? I know that I could use
the start method to position both streams to the second but is
there a way to sync them more precisely? Thanks.Timing of sounds
you can start them to within a few milliseconds of accuracy
unless the user's cpu is tied up doing something.Timing of sounds
Just by using the sound.start(secondOffset) function?



I thought that was just an approximation.
it is. but you can apply the start() method to within a few
millisecond accuracy using, for example, getTimer().
Oh, OK thanks. I thought that it automatically rounded to the
nearest second.
i think you're confusing two different things:



the start() method ''secondOffset'' parameter has nothing to do
with WHEN a sound starts to play. it specifies at what point
(time-wise) in the sound file the sound starts. it does not control
WHEN the sound starts.



the sound starts within milliseconds of the start() methods
execution. you may not hear anything if there's dead-space in the
sound file and the start() method directs the sound object to start
in that dead-space.



to specify WHEN a sound starts, you control WHEN you execute
your start() method. and controlling when the start() method is
applied can be done very accurately.
No, sorry. Basically, I'd like to overlap two sounds. I'm not
so much concerned with when they start, only that they play
correctly in relation to each other. And for example, if I had one
sound playing and then wanted a user to add a second sound I could
make sure that the timing between the two sounds was accurate at
greater precision than a second. So, basically:



private function AddSecondSound(path:String):void {

pos:number = FirstSound.position

SecondSound.start(pos, 1)

}



I was just concerned that the first parameter is in seconds,
not milliseconds.
well, that code will be way off. the position method returns
the number of MILLISECONDS the FirstSound is playing. correct it by
dividing by 1000 to use as a sound offset in the start() method and
see if that gets you close enough to what you want.
Sorry, I knew that I needed to divide it by 1000. I'll just
check it out and see what happens. Thanks.
you're welcome.



actually, when i tested the start() method it seems to be
accurate to much more than 1 millisecond. i can detect differences
up to .00001 offset. at that point it sound like simultaneous
sounds are playing to me. at .0001 they offset is detectable by
me.
I was actually using the following :



mySoundChannel1 = mySound1.play

mySoundChannel2 = mySound2.play



instead of start(). On my development machine the sounds were
simultaneous but when I deployed it on a remote server there was a
very noticeable difference (maybe a tenth of a second). Is there a
way to close that gap? Would a dedicated server or Flash Media
Server load that second sound faster?
that doesn't make sense. is that supposed to be:



mySoundChannel1 = mySound1.play()

mySoundChannel2 = mySound2.play()



if so, that makes no sense unless mySound1 and mySound2 are
movieclips and you have a sound attached to their timelines and
that makes no sense given the discussion above.



so, i just can't make sense of your last message.

No comments:

Post a Comment