  | |  | Timing accuracy for short sounds | Timing accuracy for short sounds
2004-02-13 - By Rob & Toni Seiler
Back Hi all,
I am writing a queue for a sound discrimination program which uses a series
(2 or 3) of pre-recorded short tones (25 - 200 msec) and quiet gaps played
in various sequences. I need precision at the <5 millisecond level so I put
in some Date.getTime() traces to check the results.
"Odd " outputs resulted, so to investigate further I made the following (see
below) simple play sequence with a similar Date.getTime() trace. This also
produced "odd " results in that there was a variation between the
Sound.duration and the "playtime " reported using the (EndDate - StartDate)
trace (eg 197 vs 78 msecs). What 's more, the results differed from run to
run with some playtimes reported as low as 62msec and as high as 109 msec.
Conclusions???
Does the actual playtime of a short sound clip truly vary from the
Sound.duration property?
Is actual playtime independent from the parent movieclip fps and number of
frames?
Is the overhead of making a new Date object large enough to impact upon the
timing of a short interval in this way?
Is there an alternative way of accurately timing sound events of less than
200 msec?
So, finally, is it possible to confidently use Flash to set up a queue to
do something like:
Play sound1 (which is say, 25msec)
Pause 1o msec (ie no sound)
Play sound2 (which is say, 15msec)
Pause 2o msec (ie no sound)
Play sound3 (which is say, 50msec)
Comments much appreciated.
Cheers
Rob
ActionScript:
SoundID = 'BEEP1 ';
trace(SoundID);
mySound = new Sound()
mySound.attachSound(SoundID,0);
trace( 'duration = ' + mySound.duration);
mySound.onSoundComplete = function() {
EndDate = new Date();
trace( 'playtime = ' + (EndDate.getTime() - StartDate.getTime()) + '\n ');
}
StartDate = new Date();
mySound.start();
Output:
BEEP1
duration = 197
playtime = 78
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:104228
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |