splash wavelet

by arithma
♥0 | Line 27 | Modified 2010-02-23 19:29:34 | MIT License
play

ActionScript3 source code

/**
 * Copyright arithma ( http://wonderfl.net/user/arithma )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7O0k
 */

package {
	import flash.display.Sprite;
	public class Splash extends Sprite {
		private var splashSound:Vector.<Number>;
		public function Splash():void {
			splashSound = new Vector.<Number>;
			const N:int = 200;
			var x:Number = 0;
			for (var i:int = 0; i < N * 5; i++) {
				var a:Number = 0;
				for (var freq:int = 99; freq < 120; freq++)
					a += .5 * Math.sin(x / N * freq);
				splashSound.push(a*(1-Math.exp(-i/N*10))*(1 - Math.exp((i - N * 5) / N * 5)));
				x += 1;
			}
			
			graphics.lineStyle(1, 0x660000);
			graphics.moveTo(0, 0);
			graphics.lineTo(5 * N, 0);
			graphics.lineStyle(1, 0);
			graphics.moveTo(0, stage.stageWidth*.5-splashSound[0] * 10);
			for (i = 0; i < 5 * N; i++){
				graphics.lineTo(i,  stage.stageWidth*.5-splashSound[i] * 10);
				trace(splashSound[i]);
			}
		}
	}
}