Hello.
 
I'm experimenting with playing generated sounds in Flash, and I have a
question:  What is the duration, in milliseconds, of a sound's playback when
I write a pair of Floats to the "data" property of its SampleDataEvent
event?
 
For example, here's some sample code from the Adobe LangRef, which plays a
continuous tone:
 
 
 
import flash.media.Sound;
import flash.events.SampleDataEvent;
 
var mySound:Sound = new Sound();
function sineWaveGenerator(event:SampleDataEvent):void {
    for ( var c:int=0; c<8192; c++ ) {
 
event.data.writeFloat(Math.sin((Number(c+event.position)/Math.PI/2))*0.25);
 
event.data.writeFloat(Math.sin((Number(c+event.position)/Math.PI/2))*0.25);
    }
}
mySound.addEventListener(SampleDataEvent.SAMPLE_DATA,sineWaveGenerator);
mySound.play();
 
 
 
Exactly how long will each of the 8,192 Float pairs, added every time the
SampleDataEvent fires, play for?  I've tried checking mySound's "length"
property, and it always returns as "0", but I'm pretty sure it only gets set
from the ID3 data when loading an MP3 file.
 
Thank you. :)
 
 

------------------------------

Andrew Murphy
Interactive Media Developer
amur...@delvinia.com

 
370 King Street West, 5th Floor, Box 4 

Toronto Canada M5V 1J9
P (416) 364-1455 ext. 233
F (416) 364-9830  
W www.delvinia.com


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to