sound 1
♥0 |
Line 18 |
Modified 2009-10-10 02:51:57 |
MIT License
archived:2017-03-20 01:07:07
ActionScript3 source code
/**
* Copyright bigfish ( http://wonderfl.net/user/bigfish )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hkeJ
*/
package {
import flash.events.SampleDataEvent;
import flash.media.Sound;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
var mySound:Sound = new Sound();
function sineWaveGenerator(e:SampleDataEvent):void {
for(var c:int = 0; c < 8192; c++) {
//this first value refers to the left channel
e.data.writeFloat(Math.sin((Number(c + e.position) / Math.PI / 2)) * 0.25);
//this second value refers to the right channel
e.data.writeFloat(Math.sin((Number(c + e.position) / Math.PI / 2)) * 0.25);
}
}
mySound.addEventListener(SampleDataEvent.SAMPLE_DATA, sineWaveGenerator);
//uncomment to play ;)
trace(4/2/2);
//mySound.play();
}
}
}