Section 1
//b_loop_11 (audioplayer_fla.b_loop_11)
package audioplayer_fla {
import flash.display.*;
public dynamic class b_loop_11 extends MovieClip {
public function b_loop_11(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package audioplayer_fla
Section 2
//b_play_15 (audioplayer_fla.b_play_15)
package audioplayer_fla {
import flash.display.*;
public dynamic class b_play_15 extends MovieClip {
public function b_play_15(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package audioplayer_fla
Section 3
//b_stop_19 (audioplayer_fla.b_stop_19)
package audioplayer_fla {
import flash.display.*;
public dynamic class b_stop_19 extends MovieClip {
public function b_stop_19(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package audioplayer_fla
Section 4
//b_track_7 (audioplayer_fla.b_track_7)
package audioplayer_fla {
import flash.display.*;
public dynamic class b_track_7 extends MovieClip {
public function b_track_7(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package audioplayer_fla
Section 5
//VisMenu_22 (audioplayer_fla.VisMenu_22)
package audioplayer_fla {
import flash.display.*;
import flash.text.*;
import mwelsh.com.*;
public dynamic class VisMenu_22 extends MovieClip {
public var transitionTimeText:TextField;
public var btnListRight:MovieClip;
public var btnListLeft:MovieClip;
public var transitionSlider:MiniSlider;
public var volumeSlider:MiniSlider;
public var fpsText:TextField;
public var visListMask:MovieClip;
}
}//package audioplayer_fla
Section 6
//Fountain3D (mwelsh.audio.visualizer.visualizations.geom3d.Fountain3D)
package mwelsh.audio.visualizer.visualizations.geom3d {
import mwelsh.audio.visualizer.*;
import mwelsh.math.*;
import mwelsh.thunder3d.geom3d.*;
public class Fountain3D extends Object3D {
private var soundHistory:Array;
public var soundData:SoundData;
private var snd:Array;
public function Fountain3D():void{
var _local1:uint;
var _local2:uint;
var _local3:Number;
soundHistory = [];
super();
verts.push(new Vertex(new Vector(0, 0, 0), new Vector(0.3, 0.3, 1), new Vector(0, 1, 0)));
_local1 = 1;
while (_local1 < 9) {
if (_local1 == 8){
_local1 = 50;
};
_local2 = 0;
while (_local2 < 16) {
_local3 = ((_local2 * Math.PI) / 8);
verts.push(new Vertex(new Vector(((Math.cos(_local3) * _local1) / 4), 0, ((Math.sin(_local3) * _local1) / 4)), new Vector(0.3, 0.3, 1), new Vector(0, 1, 0)));
_local2++;
};
_local1++;
};
snd = [0, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
_local1 = 0;
while (_local1 < 8) {
soundHistory[_local1] = 0;
_local1++;
};
_local2 = 0;
while (_local2 < 15) {
polys.push(new Polygon([verts[(_local2 + 1)], verts[0], verts[(_local2 + 2)]]));
_local2++;
};
polys.push(new Polygon([verts[0], verts[1], verts[16]]));
_local1 = 1;
while (_local1 < 8) {
_local2 = 0;
while (_local2 < 15) {
polys.push(new Polygon([verts[((((_local1 - 1) * 16) + _local2) + 2)], verts[(((_local1 * 16) + _local2) + 2)], verts[(((_local1 * 16) + _local2) + 1)], verts[((((_local1 - 1) * 16) + _local2) + 1)]]));
_local2++;
};
polys.push(new Polygon([verts[(((_local1 - 1) * 16) + 1)], verts[((_local1 * 16) + 1)], verts[((_local1 * 16) + 16)], verts[(((_local1 - 1) * 16) + 16)]]));
_local1++;
};
scale.x = (scale.y = (scale.z = 2));
backfaceCulling = false;
}
override public function tick(_arg1:Number):void{
var _local2:uint;
var _local3:uint;
super.tick(_arg1);
rot.y = (rot.y + _arg1);
snd[0] = Math.max((snd[0] * 0.75), (soundData.getSubbandEnergy() * 2));
if (soundData.beat){
snd[0] = (snd[0] * 2);
};
snd[0] = Math.min(snd[0], 1);
soundHistory.unshift(snd[0]);
soundHistory.pop();
_local2 = 1;
while (_local2 < 8) {
_local3 = 0;
while (_local3 < 16) {
snd[_local2][_local3] = Math.max((snd[_local2][_local3] * 0.75), soundHistory[_local2]);
_local3++;
};
_local2++;
};
Vertex(verts[0]).pos.y = snd[0];
_local2 = 1;
while (_local2 < 8) {
_local3 = 0;
while (_local3 < 16) {
Vertex(verts[((((_local2 - 1) * 16) + _local3) + 1)]).pos.y = snd[_local2][_local3];
_local3++;
};
_local2++;
};
}
}
}//package mwelsh.audio.visualizer.visualizations.geom3d
Section 7
//FountainParticles (mwelsh.audio.visualizer.visualizations.geom3d.FountainParticles)
package mwelsh.audio.visualizer.visualizations.geom3d {
import mwelsh.math.*;
import mwelsh.thunder3d.geom3d.*;
public class FountainParticles extends Object3D {
private const NUM_PARTICLES:uint = 10;
public var life:Number;// = 3
private var pv:Array;
private var g:Vector;
public function FountainParticles():void{
var _local1:uint;
life = 3;
super();
pv = [];
g = new Vector(0, -5, 0);
_local1 = 0;
while (_local1 < NUM_PARTICLES) {
verts.push(new Vertex(new Vector(0, -1, 0), new Vector(1, 1, 1)));
polys.push(new Polygon([verts[_local1]]));
pv.push(new Vector(((Math.random() * 1) - 0.5), ((Math.random() * 5) + 1.25), ((Math.random() * 1) - 0.5)));
_local1++;
};
}
override public function tick(_arg1:Number):void{
var _local2:uint;
super.tick(_arg1);
life = (life - _arg1);
_local2 = 0;
while (_local2 < NUM_PARTICLES) {
pv[_local2] = Vector.add(pv[_local2], Vector.scale(_arg1, g));
Vertex(verts[_local2]).pos = Vector.add(verts[_local2].pos, Vector.scale(_arg1, pv[_local2]));
_local2++;
};
}
}
}//package mwelsh.audio.visualizer.visualizations.geom3d
Section 8
//Tunnel3D (mwelsh.audio.visualizer.visualizations.geom3d.Tunnel3D)
package mwelsh.audio.visualizer.visualizations.geom3d {
import mwelsh.audio.visualizer.*;
import mwelsh.math.*;
import mwelsh.thunder3d.geom3d.*;
public class Tunnel3D extends Object3D {
private const TUNNEL_SIDES:uint = 16;
private const TUNNEL_SEGMENTS:uint = 8;
private const TUNNEL_INTERVAL:Number = 0.2;
private var tunTime:Number;
public var soundData:SoundData;
private var t:Number;
private var tunZ:Number;
public function Tunnel3D():void{
var _local1:uint;
var _local2:Number;
super();
t = (-(TUNNEL_SEGMENTS) * TUNNEL_INTERVAL);
tunZ = ((-(TUNNEL_SEGMENTS) * TUNNEL_INTERVAL) * 8);
_local1 = 0;
_local2 = 0;
while (_local1 < TUNNEL_SIDES) {
verts.push(new Vertex(new Vector(Math.cos(_local2), Math.sin(_local2), 0), new Vector(1, 0, 0.5)));
_local2 = (_local2 + ((Math.PI * 2) / TUNNEL_SIDES));
_local1++;
};
while (polys.length < (TUNNEL_SEGMENTS * TUNNEL_SIDES)) {
tunZ = (tunZ + (TUNNEL_INTERVAL * 8));
t = (t + TUNNEL_INTERVAL);
_local1 = 0;
_local2 = 0;
while (_local1 < TUNNEL_SIDES) {
verts.unshift(new Vertex(new Vector(Math.cos(_local2), (Math.sin(_local2) + (5 * Math.sin(t))), -(tunZ)), new Vector(1, 0, 0.5)));
_local2 = (_local2 + ((Math.PI * 2) / TUNNEL_SIDES));
_local1++;
};
_local1 = 0;
while (_local1 < (TUNNEL_SIDES - 1)) {
polys.unshift(new Polygon([verts[_local1], verts[(_local1 + 1)], verts[((_local1 + TUNNEL_SIDES) + 1)], verts[(_local1 + TUNNEL_SIDES)]]));
_local1++;
};
polys.unshift(new Polygon([verts[(TUNNEL_SIDES - 1)], verts[0], verts[TUNNEL_SIDES], verts[((TUNNEL_SIDES * 2) - 1)]]));
};
tunTime = TUNNEL_INTERVAL;
}
override public function tick(_arg1:Number):void{
var _local2:uint;
var _local3:Number;
var _local4:Number;
pos.z = (pos.z + (8 * _arg1));
tunTime = (tunTime - _arg1);
backfaceCulling = false;
_local4 = (0xFF / TUNNEL_SIDES);
while (tunTime <= 0) {
tunZ = (tunZ + (TUNNEL_INTERVAL * 8));
t = (t + TUNNEL_INTERVAL);
_local2 = 0;
_local3 = 0;
while (_local2 < TUNNEL_SIDES) {
verts.unshift(new Vertex(new Vector((Math.cos(_local3) * (1 + (2 * Math.abs(soundData.rawAvg[uint((_local2 * _local4))])))), ((Math.sin(_local3) * (1 + (2 * Math.abs(soundData.rawAvg[uint((_local2 * _local4))])))) + (5 * Math.sin(t))), -(tunZ)), new Vector(1, 0, 0.5)));
_local3 = (_local3 + ((Math.PI * 2) / TUNNEL_SIDES));
_local2++;
};
_local2 = 0;
while (_local2 < (TUNNEL_SIDES - 1)) {
polys.unshift(new Polygon([verts[_local2], verts[(_local2 + 1)], verts[((_local2 + TUNNEL_SIDES) + 1)], verts[(_local2 + TUNNEL_SIDES)]]));
_local2++;
};
polys.unshift(new Polygon([verts[(TUNNEL_SIDES - 1)], verts[0], verts[TUNNEL_SIDES], verts[((TUNNEL_SIDES * 2) - 1)]]));
tunTime = (tunTime + TUNNEL_INTERVAL);
};
while (polys.length >= (TUNNEL_SEGMENTS * TUNNEL_SIDES)) {
polys.splice(-(TUNNEL_SIDES));
verts.splice(-(TUNNEL_SIDES));
};
super.tick(_arg1);
}
}
}//package mwelsh.audio.visualizer.visualizations.geom3d
Section 9
//TunnelLight (mwelsh.audio.visualizer.visualizations.geom3d.TunnelLight)
package mwelsh.audio.visualizer.visualizations.geom3d {
import mwelsh.audio.visualizer.*;
import mwelsh.math.*;
import mwelsh.thunder3d.geom3d.*;
public class TunnelLight extends Object3D {
public var soundData:SoundData;
private var t:Number;
public function TunnelLight():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:uint;
super();
t = 0;
verts.push(new Vertex(new Vector(0, -0.5, 0), new Vector(1, 1, 1)));
_local1 = -0.4;
while (_local1 < 0.5) {
_local2 = Math.sqrt((0.25 - (_local1 * _local1)));
_local3 = 0;
while (_local3 < (Math.PI * 2)) {
verts.push(new Vertex(new Vector((Math.cos(_local3) * _local2), _local1, (Math.sin(_local3) * _local2)), new Vector(1, 1, 1)));
_local3 = (_local3 + (Math.PI / 2));
};
_local1 = (_local1 + 0.2);
};
verts.push(new Vertex(new Vector(0, 0.5, 0), new Vector(1, 1, 1)));
_local4 = 0;
while (_local4 < verts.length) {
polys.push(new Polygon([verts[_local4]]));
_local4++;
};
scale = new Vector(0.02, 0.02, 0.02);
pos = new Vector(0, 0, 5);
}
override public function tick(_arg1:Number):void{
t = (t + _arg1);
pos.y = (5 * Math.sin((t - 0.625)));
scale.x = Math.max(0.02, (scale.x - (_arg1 * 4)));
scale.y = Math.max(0.02, (scale.y - (_arg1 * 4)));
scale.z = Math.max(0.02, (scale.z - (_arg1 * 4)));
if (soundData.beat){
scale.x = (scale.y = (scale.z = 1));
};
super.tick(_arg1);
}
}
}//package mwelsh.audio.visualizer.visualizations.geom3d
Section 10
//AboutVisualization (mwelsh.audio.visualizer.visualizations.AboutVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class AboutVisualization extends Visualization {
private const SECTION_TIME:Number = 8;
private const LINE_TIME:Number = 0.5;
private const LETTER_TIME:Number = 0.1;
private var gfx:Sprite;
private var activeLines:Array;
private var credits:Array;
private var bgColor:uint;// = 4289357363
private var samps:Array;
private var beatFactor:Number;// = 0
private var sins:Array;
private var sampBeats:Array;
private var origX:Number;
private var activeLetters:Array;
private var curCredits:uint;// = 0
private var dying:Boolean;// = false
private var origY:Number;
private var coss:Array;
private var cTime:Number;// = 0
private var t:Number;// = 0
private var startParity:Boolean;// = false
private var origTargX:Number;
private var origTargY:Number;
public function AboutVisualization(_arg1:uint, _arg2:uint){
var _local3:CreditLines;
var _local4:uint;
var _local5:Number;
bgColor = 4289357363;
beatFactor = 0;
t = 0;
cTime = 0;
samps = [];
sampBeats = [];
startParity = false;
activeLines = [];
activeLetters = [];
dying = false;
curCredits = 0;
credits = [];
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, bgColor);
bufferBmp.fillRect(bufferBmp.rect, bgColor);
gfx = new Sprite();
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine(("Newgrounds Audio Visualizer v" + AudioVisualizer.VERSION), 16758030));
_local3.addLine(new CreditLine(""));
_local3.addLine(new CreditLine("by Team Newgrounds", 0xEEEEEE));
credits.push(_local3);
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine("Using Adobe Flash 9"));
_local3.addLine(new CreditLine("and ActionScript 3.0"));
credits.push(_local3);
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine("Featuring Art by", 16758030));
_local3.addLine(new CreditLine(""));
_local3.addLine(new CreditLine("Jeff Bandelin", 0xEEEEEE));
_local3.addLine(new CreditLine("Weebl", 0xEEEEEE));
credits.push(_local3);
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine("Beat Detection Algorithm", 16758030));
_local3.addLine(new CreditLine("Adapted from Winamp", 0xEEEEEE));
_local3.addLine(new CreditLine("By Nullsoft and Justin Frankel", 0xEEEEEE));
_local3.addLine(new CreditLine(""));
_local3.addLine(new CreditLine("http://www.winamp.com", 0xEEEEEE));
credits.push(_local3);
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine("Special Thanks", 16758030));
_local3.addLine(new CreditLine(""));
_local3.addLine(new CreditLine("Captin of Cats", 0xEEEEEE));
_local3.addLine(new CreditLine("David Robbins", 0xEEEEEE));
_local3.addLine(new CreditLine("Marty Seefeldt", 0xEEEEEE));
_local3.addLine(new CreditLine("William Beene", 0xEEEEEE));
credits.push(_local3);
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine("Special Thanks", 16758030));
_local3.addLine(new CreditLine(""));
_local3.addLine(new CreditLine("André Michelle", 0xEEEEEE));
_local3.addLine(new CreditLine("Justin Frankel", 0xEEEEEE));
_local3.addLine(new CreditLine("SoundSpectrum, Inc.", 0xEEEEEE));
_local3.addLine(new CreditLine("UnconeD", 0xEEEEEE));
credits.push(_local3);
_local3 = new CreditLines(this);
_local3.addLine(new CreditLine("NEWGROUNDS", 16758030));
_local3.addLine(new CreditLine(""));
_local3.addLine(new CreditLine("Everthing, by everyone!", 16758030));
credits.push(_local3);
origX = w2;
origY = h2;
origTargX = w2;
origTargY = h2;
sins = [];
coss = [];
_local4 = 0;
_local5 = 0;
while (_local5 < (2 * Math.PI)) {
sins[_local4] = Math.sin(_local5);
coss[_local4] = Math.cos(_local5);
_local5 = (_local5 + ((2 * Math.PI) / 0x0100));
_local4++;
};
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:int;
var _local4:int;
var _local5:uint;
var _local6:Number;
var _local7:Number;
var _local8:uint;
var _local9:Matrix;
var _local10:Boolean;
var _local11:uint;
var _local12:CreditLine;
var _local13:CreditLetter;
pixels.lock();
bufferBmp.lock();
vectors.graphics.clear();
saveBuffer();
pixels.fillRect(pixels.rect, bgColor);
samps.unshift(_arg2.fftAvg);
sampBeats.unshift(_arg2.beat);
_local8 = 32;
if (samps.length > _local8){
samps.pop();
sampBeats.pop();
};
vectors.graphics.lineStyle(0, 0, 0);
if (_arg2.beat){
startParity = !(startParity);
beatFactor = 1;
} else {
beatFactor = (beatFactor + ((0.7 - beatFactor) / 5));
};
origX = (origX + ((origTargX - origX) / 8));
origY = (origY + ((origTargY - origY) / 8));
_local10 = startParity;
_local6 = 0;
_local7 = (Math.PI / 16);
while (_local6 < (2 * Math.PI)) {
_local9 = new Matrix();
_local9.rotate(((_local6 + _local7) / 2));
if (_local10){
_local11 = (((uint((0xFF * beatFactor)) << 16) | (uint((181 * beatFactor)) << 8)) | uint((3 * beatFactor)));
} else {
_local11 = uint((238 * beatFactor));
_local11 = (((_local11 << 16) | (_local11 << 8)) | _local11);
};
vectors.graphics.beginGradientFill(GradientType.LINEAR, (_local10) ? [_local11, 0] : [_local11, 0], [1, 1], [1, 0xFF], _local9);
vectors.graphics.moveTo(origX, origY);
vectors.graphics.lineTo((origX + ((maxDim * 2) * Math.cos(_local6))), (origY + ((maxDim * 2) * Math.sin(_local6))));
vectors.graphics.lineTo((origX + ((maxDim * 2) * Math.cos(_local7))), (origY + ((maxDim * 2) * Math.sin(_local7))));
vectors.graphics.lineTo(origX, origY);
vectors.graphics.endFill();
_local10 = !(_local10);
_local6 = _local7;
_local7 = (_local7 + (Math.PI / 16));
};
t = (t + _arg1);
cTime = (cTime + _arg1);
if (cTime >= LINE_TIME){
if (credits[curCredits].empty){
if (((!(dying)) && ((cTime >= SECTION_TIME)))){
_local3 = 0;
_local5 = activeLetters.length;
while (_local3 < _local5) {
activeLetters[_local3].die();
_local3++;
};
dying = true;
} else {
if (cTime >= (SECTION_TIME + 1)){
dying = false;
_local3 = 0;
_local5 = activeLetters.length;
while (_local3 < _local5) {
gfx.removeChildAt(0);
_local3++;
};
activeLetters = [];
cTime = (cTime - (SECTION_TIME + 1));
curCredits = ((curCredits + 1) % credits.length);
credits[curCredits].reset();
};
};
} else {
activeLines.push(credits[curCredits].getNextLine());
cTime = (cTime - LINE_TIME);
activeLines[(activeLines.length - 1)].time = (cTime - _arg1);
};
};
_local3 = 0;
_local5 = activeLines.length;
while (_local3 < _local5) {
_local12 = activeLines[_local3];
activeLines[_local3].time = (_local12.time + _arg1);
if (_local12.empty){
activeLines.splice(_local3, 1);
_local3--;
_local5--;
} else {
if (_local12.time >= LETTER_TIME){
_local13 = _local12.getNextChar();
activeLetters.push(_local13);
_local12.time = (_local12.time - LETTER_TIME);
_local13.tick(_local12.time, false);
gfx.addChild(_local13);
};
};
_local3++;
};
_local3 = 0;
_local5 = activeLetters.length;
while (_local3 < _local5) {
activeLetters[_local3].tick(_arg1, _arg2.beat);
_local3++;
};
vectors.graphics.endFill();
pixels.draw(vectors);
_local3 = 0;
while (_local3 < samps.length) {
_local4 = 0;
while (_local4 < 0x0100) {
pixels.fillRect(new Rectangle(((w2 + (((((_local3 / (_local8 - 1)) * coss[_local4]) * maxDim) * samps[_local3][_local4]) * 1.4)) - 1), ((h2 + (((((_local3 / (_local8 - 1)) * sins[_local4]) * maxDim) * samps[_local3][_local4]) * 1.4)) - 1), 2, 2), (4278190080 | uint((68 * (1 - (_local3 / (_local8 - 1)))))));
_local4 = (_local4 + 4);
};
_local3++;
};
pixels.draw(gfx);
drawBuffer(null, new ColorTransform(1, 1, 1, 0.3));
bufferBmp.unlock();
pixels.unlock();
}
public function get height():Number{
return (h);
}
public function get width():Number{
return (w);
}
}
}//package mwelsh.audio.visualizer.visualizations
import flash.display.*;
import flash.geom.*;
import flash.text.*;
class CreditLetter extends TextField {
private var beatShiftX:Number;
private var beatShiftY:Number;
private var state:uint;
private var yTarg:Number;
private var yStart:Number;
private var t:Number;// = 0
private var mParent:AboutVisualization;
private var xStart:Number;
private var beatShift:Number;// = 0
private var dieDir:Number;
private var xTarg:Number;
private static const CL_SHOW:uint = 0;
private static const CL_STEADY:uint = 1;
private static const CL_HIDE:uint = 2;
private function CreditLetter(_arg1:AboutVisualization, _arg2:String, _arg3:uint, _arg4:Number, _arg5:Number):void{
t = 0;
beatShift = 0;
super();
mParent = _arg1;
text = _arg2;
embedFonts = true;
setTextFormat(new TextFormat("Arial", 18, _arg3));
selectable = false;
type = TextFieldType.DYNAMIC;
xStart = (mParent.width / 2);
yStart = (mParent.height / 2);
xTarg = _arg4;
yTarg = _arg5;
dieDir = ((Math.random() * 2) * Math.PI);
state = CL_SHOW;
beatShiftX = ((Math.random() * 2) - 1);
beatShiftY = ((Math.random() * 2) - 1);
}
public function die():void{
state = CL_HIDE;
t = 0;
}
public function tick(_arg1:Number, _arg2:Boolean):void{
t = (t + _arg1);
if ((((state == CL_SHOW)) && ((t >= 1)))){
t = (t - 1);
state = CL_STEADY;
};
if (state == CL_SHOW){
x = (xStart + ((xTarg - xStart) * t));
y = (yStart + ((yTarg - yStart) * t));
scaleX = t;
scaleY = t;
} else {
if (state == CL_STEADY){
x = xTarg;
y = (yTarg + (Math.sin((t * 2)) * 5));
scaleX = (scaleY = 1);
} else {
x = (xTarg + ((((Math.cos(dieDir) * mParent.width) * 2) - xTarg) * t));
y = (yTarg + ((((Math.sin(dieDir) * mParent.height) * 2) - yTarg) * t));
};
};
if (_arg2){
beatShift = 5;
} else {
beatShift = (beatShift * 0.5);
};
x = (x + (beatShiftX * beatShift));
y = (y + (beatShiftY * beatShift));
}
}
class CreditLine {
private var curX:Number;
private var color:uint;
private var _lineHeight:Number;
private var _time:Number;
private var text:String;
public var parent:AboutVisualization;
private var tf:TextField;
private var spr:Sprite;
private var curChar:uint;
private var r:Rectangle;
private function CreditLine(_arg1:String="", _arg2:uint=0xEEEEEE):void{
this.color = _arg2;
this.text = _arg1;
curChar = 0;
tf = new TextField();
tf.type = TextFieldType.DYNAMIC;
tf.text = _arg1;
tf.embedFonts = true;
tf.setTextFormat(new TextFormat("Arial", 18, _arg2));
tf.selectable = false;
_time = time;
}
public function get time():Number{
return (_time);
}
public function get width():Number{
return (tf.getLineMetrics(0).width);
}
public function reset():void{
curX = ((parent.width - width) / 2);
curChar = 0;
}
public function set time(_arg1:Number):void{
_time = _arg1;
}
public function get empty():Boolean{
return ((curChar >= text.length));
}
public function getNextChar():CreditLetter{
var _local1:CreditLetter;
if (curChar >= text.length){
return (null);
};
_local1 = new CreditLetter(parent, text.charAt(curChar++), color, curX, _lineHeight);
curX = (curX + _local1.getCharBoundaries(0).width);
return (_local1);
}
public function set lineHeight(_arg1:Number):void{
_lineHeight = _arg1;
}
}
class CreditLines {
private var curLineHeight:Number;
private var parent:AboutVisualization;
private var curLine:uint;
private var lines:Array;
private function CreditLines(_arg1:AboutVisualization):void{
lines = [];
this.parent = _arg1;
curLine = 0;
}
public function get width():Number{
return (0);
}
public function get empty():Boolean{
return ((curLine >= lines.length));
}
public function get height():Number{
return ((24 * lines.length));
}
public function reset():void{
curLine = 0;
}
public function addLine(_arg1:CreditLine):void{
_arg1.parent = parent;
lines.push(_arg1);
}
public function getNextLine():CreditLine{
lines[curLine].reset();
curLineHeight = (((parent.height - height) / 2) + (curLine * 24));
lines[curLine].lineHeight = curLineHeight;
if (curLine >= lines.length){
return (null);
};
return (lines[curLine++]);
}
}
Section 11
//AgnryFaicVisualization (mwelsh.audio.visualizer.visualizations.AgnryFaicVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.events.*;
public class AgnryFaicVisualization extends Visualization {
private var faceFrontGfx:Class;
private var faceBgX:Number;// = -5
private var faceBgY:Number;// = -5
private var eye0:MovieClip;
private var eye1scale:Number;
private var eye1:MovieClip;
private var face:MovieClip;
private var faceWidth:Number;
private var t:Number;
private var gfx:Sprite;
private var faceRoll:Number;
private var eyeGfx:Class;
private var mouthPoints:Array;
private var eye0scale:Number;
private var faceStuff:Sprite;
private var faceTargetScale:Number;
private var eyebrows:Sprite;
private var mouth:Sprite;
private var faceTargetY:Number;// = 0
private var faceFront:MovieClip;
private var faceMaskGfx:Class;
private var facePitchV:Number;
private var faceTargetX:Number;// = 0
private var faceMoveCount:int;
private var faceGfx:Class;
private var faceBgVx:Number;// = 0
private var faceRedGfx:Class;
private var faceMask:MovieClip;
private var facePitch:Number;
private var faceBgVy:Number;// = 0
private var faceScale:Number;
private var fillTime:Number;
private var faceRed:Sprite;
private var faceYaw:Number;
public function AgnryFaicVisualization(_arg1:uint, _arg2:uint):void{
faceTargetX = 0;
faceTargetY = 0;
faceBgX = -5;
faceBgY = -5;
faceBgVx = 0;
faceBgVy = 0;
super(_arg1, _arg2);
loadContent("vis_agnry.swf");
fillTime = 0;
eye0scale = 0;
eye1scale = 0;
facePitch = 0;
facePitchV = 0;
faceYaw = 0;
faceRoll = 0;
t = 0;
faceMoveCount = 1;
mouthPoints = [new Point(-140, 140), new Point(-100, 40), new Point(100, 40), new Point(140, 140)];
}
private function evalCubicBezier(_arg1:Number, _arg2:Point, _arg3:Point, _arg4:Point, _arg5:Point):Point{
var _local6:Number;
_local6 = (1 - _arg1);
return (new Point(((((((_local6 * _local6) * _local6) * _arg2.x) + ((((3 * _local6) * _local6) * _arg1) * _arg3.x)) + ((((3 * _local6) * _arg1) * _arg1) * _arg4.x)) + (((_arg1 * _arg1) * _arg1) * _arg5.x)), ((((((_local6 * _local6) * _local6) * _arg2.y) + ((((3 * _local6) * _local6) * _arg1) * _arg3.y)) + ((((3 * _local6) * _arg1) * _arg1) * _arg4.y)) + (((_arg1 * _arg1) * _arg1) * _arg5.y))));
}
override protected function loadingComplete(_arg1:Event):void{
super.loadingComplete(_arg1);
faceGfx = getLoadedClass("gfx_angryface");
faceFrontGfx = getLoadedClass("gfx_angryfront");
eyeGfx = getLoadedClass("gfx_angryeye");
faceMaskGfx = getLoadedClass("gfx_facemask");
faceRedGfx = getLoadedClass("gfx_angryred");
gfx = new Sprite();
face = new faceGfx();
gfx.addChild(face);
faceRed = new faceRedGfx();
faceMask = new faceMaskGfx();
face.addChild(faceMask);
faceStuff = new Sprite();
face.addChild(faceStuff);
faceFront = new faceFrontGfx();
faceStuff.addChild(faceFront);
mouth = new Sprite();
eyebrows = new Sprite();
face.addChild(mouth);
face.addChild(eyebrows);
eye0 = new eyeGfx();
eye1 = new eyeGfx();
eye0.x = -80;
eye1.x = 80;
eye0.y = (eye1.y = 0);
faceStuff.addChild(eye0);
faceStuff.addChild(eye1);
faceStuff.mask = faceMask;
faceWidth = face.width;
face.scaleX = (face.scaleY = (faceScale = (faceTargetScale = ((1.1 * minDim) / faceWidth))));
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:uint;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Matrix;
var _local9:Number;
var _local10:Number;
var _local11:uint;
var _local12:Number;
var _local13:Point;
var _local14:Number;
var _local15:Array;
pixels.lock();
t = (t + _arg1);
if (_arg2.smartBeat){
fillTime = 1;
} else {
fillTime = Math.max(0, (fillTime - (_arg1 * 4)));
};
_local3 = (85 + (170 * fillTime));
pixels.fillRect(pixels.rect, (4278190080 | (_local3 << 16)));
_local6 = (w / 600);
_local7 = (_local6 * 20);
_local8 = new Matrix();
_local8.scale(_local6, _local6);
if (faceBgX < 0){
_local9 = (faceBgX % ((_local6 * faceRed.width) + _local7));
} else {
_local9 = (-((faceBgX % ((_local6 * faceRed.width) + _local7))) - ((_local6 * faceRed.width) + _local7));
};
if (faceBgY < 0){
_local10 = (faceBgY % ((_local6 * faceRed.height) + _local7));
} else {
_local10 = ((faceBgY % ((_local6 * faceRed.height) + _local7)) - ((_local6 * faceRed.height) + _local7));
};
_local8.translate(_local9, _local10);
_local4 = _local9;
while (_local4 < w) {
_local5 = _local10;
while (_local5 < h) {
pixels.draw(faceRed, _local8);
_local8.translate(0, ((_local6 * faceRed.height) + _local7));
_local5 = (_local5 + ((_local6 * faceRed.height) + _local7));
};
_local8.tx = (_local8.tx + ((_local6 * faceRed.width) + _local7));
_local8.ty = _local10;
_local4 = (_local4 + ((_local6 * faceRed.width) + _local7));
};
mouth.graphics.clear();
mouth.graphics.lineStyle(25, 0);
_local13 = evalCubicBezier(0, mouthPoints[0], mouthPoints[1], mouthPoints[2], mouthPoints[3]);
mouth.graphics.moveTo(_local13.x, _local13.y);
_local15 = _arg2.generateSmoothedData(3, false);
_local12 = (1 / 32);
while (_local12 <= 1) {
_local14 = _local15[uint((_local12 * 0xFF))];
_local13 = evalCubicBezier(_local12, mouthPoints[0], mouthPoints[1], mouthPoints[2], mouthPoints[3]);
mouth.graphics.lineTo((_local13.x + ((_local14 * 50) * Math.cos((Math.PI * (1 - _local12))))), (_local13.y - ((_local14 * 50) * Math.sin((Math.PI * (1 - _local12))))));
_local12 = (_local12 + (1 / 32));
};
eyebrows.graphics.clear();
eyebrows.graphics.lineStyle(25);
eyebrows.graphics.moveTo(-170, -170);
eyebrows.graphics.lineTo(0, 0);
eyebrows.graphics.lineTo(170, -170);
_local12 = 0;
_local11 = 1;
while (_local11 < 5) {
_local12 = (_local12 + _arg2.fftLeft[_local11]);
_local11++;
};
eye0scale = (((_local12 - eye0scale) * 0.75) + eye0scale);
eye0.scaleX = (eye0.scaleY = (0.8 + (eye0scale / 6)));
_local12 = 0;
_local11 = 1;
while (_local11 < 5) {
_local12 = (_local12 + _arg2.fftRight[_local11]);
_local11++;
};
eye1scale = (((_local12 - eye1scale) * 0.75) + eye1scale);
eye1.scaleX = (eye1.scaleY = (0.8 + (eye1scale / 6)));
updateAngryPos(_arg1, _arg2);
_local8 = new Matrix();
_local8.translate((w / 2), (h / 2));
pixels.draw(gfx, _local8);
pixels.unlock();
}
private function evalQuadBezier(_arg1:Number, _arg2:Point, _arg3:Point, _arg4:Point):Point{
var _local5:Number;
_local5 = (1 - _arg1);
return (new Point(((((_local5 * _local5) * _arg2.x) + (((2 * _local5) * _arg1) * _arg3.x)) + ((_arg1 * _arg1) * _arg4.x)), ((((_local5 * _local5) * _arg2.y) + (((2 * _local5) * _arg1) * _arg3.y)) + ((_arg1 * _arg1) * _arg4.y))));
}
private function updateAngryPos(_arg1:Number, _arg2:SoundData):void{
var _local3:Number;
var _local4:Number;
_local3 = facePitch;
_local4 = faceYaw;
if (_arg2.beat){
facePitch = -10;
facePitchV = -300;
faceBgVx = ((Math.random() * 12) - 6);
faceBgVy = ((Math.random() * 12) - 6);
face.scaleX = (face.scaleY = (faceScale * 1.2));
faceMoveCount--;
} else {
facePitchV = (facePitchV + ((-(facePitch) * _arg1) * 50));
};
if (faceMoveCount == 0){
faceTargetX = (w2 * ((Math.random() * 0.7) - 0.35));
faceTargetY = (h2 * ((Math.random() * 0.7) - 0.35));
faceMoveCount = (int((Math.random() * 5)) + 1);
faceTargetScale = ((((Math.random() * 1) + 0.7) * minDim) / faceWidth);
};
faceScale = (faceScale + ((faceTargetScale - faceScale) * 0.1));
face.scaleX = (face.scaleY = Math.max(faceScale, (face.scaleX - _arg1)));
faceBgX = (faceBgX + faceBgVx);
faceBgY = (faceBgY + faceBgVy);
faceYaw = ((face.x / w2) * 90);
face.x = (face.x + ((faceTargetX - face.x) * 0.1));
face.y = (face.y + ((faceTargetY - face.y) * 0.1));
facePitch = (facePitch + (facePitchV * _arg1));
faceRoll = (Math.sin(t) * 3);
face.rotation = faceRoll;
eye0.x = (-80 + faceYaw);
eye0.y = facePitch;
eye1.x = (80 + faceYaw);
eye1.y = facePitch;
eyebrows.y = facePitch;
eyebrows.x = faceYaw;
eyebrows.scaleX = (1 - Math.abs((faceYaw / 200)));
eyebrows.scaleY = (1 - Math.abs((facePitch / 200)));
mouth.y = facePitch;
mouth.x = faceYaw;
mouth.scaleX = (1 - Math.abs((faceYaw / 200)));
mouth.scaleY = (1 - Math.abs((facePitch / 200)));
faceFront.y = -((facePitch - _local3));
faceFront.x = -((faceYaw - _local4));
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 12
//BadgerVisualization (mwelsh.audio.visualizer.visualizations.BadgerVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.events.*;
import mwelsh.math.*;
import flash.text.*;
public class BadgerVisualization extends Visualization {
private var camPos:Vector;
private var scrollMode:uint;
private var oldCamPos:Vector;
private var groundColor:uint;// = 8694111
private var badgers:Array;
private var snakeBeats:int;
private var snake:MovieClip;
private var hillTarg:Number;
private var camAngle:Number;
private var camTarget:Vector;
private var air:Sprite;
private var gfx_sky:Class;
private var numBeat:uint;
private var gfx_landscape2:Class;
private var gfx_landscape3:Class;
private var yBounce:Number;// = 0
private var gfx_landscape1:Class;
private var gfx_mushroom:Class;
private var tf:TextField;
private var t:Number;
private var badgersPlay:Boolean;
private var scene:uint;
private var gfx:Sprite;
private var sHistory:Array;
private var badgerPosAvailable:Array;
private var badgerFrameOffset:Number;
private var gfx_badger:Class;
private var gfx_grass0:Class;
private var gfx_grass1:Class;
private var gfx_grass3:Class;
private var gfx_grass2:Class;
private var landscape1:MovieClip;
private var landscape2:MovieClip;
private var landscape3:MovieClip;
private var stuff:Array;
private var gfx_bush:Class;
private var gfx_snake:Class;
public function BadgerVisualization(_arg1:uint, _arg2:uint):void{
sHistory = [];
yBounce = 0;
groundColor = 8694111;
super(_arg1, _arg2);
loadContent("vis_badger.swf");
}
private function getNewScenery():MovieClip{
var _local1:uint;
_local1 = Math.floor((Math.random() * 62));
if (_local1 < 2){
return (new gfx_mushroom());
};
if (_local1 < 22){
return (new gfx_grass0());
};
if (_local1 < 42){
return (new gfx_grass1());
};
return (new gfx_grass3());
}
private function clearBadgers():void{
var _local1:uint;
_local1 = 0;
while (_local1 < badgers.length) {
gfx.removeChild(badgers[_local1]);
badgers[_local1].deleted = true;
_local1++;
};
badgers = [];
}
private function updateCamera(_arg1:Number):void{
oldCamPos = camPos.clone();
scrollMode = (Math.floor((t / 5)) % 1);
scrollMode = 1;
if (scrollMode == 0){
camTarget.x = camPos.x;
camTarget.y = camPos.y;
camTarget.z = camPos.z;
} else {
if (scrollMode == 1){
camTarget.x = (camTarget.x + ((Math.cos(camAngle) * _arg1) / 2));
camTarget.z = (camTarget.z - ((Math.sin(camAngle) * _arg1) / 2));
camTarget.y = (((Math.cos(t) * 0.025) + 0.15) + yBounce);
} else {
if (scrollMode == 2){
camAngle = (camAngle + _arg1);
} else {
if (scrollMode == 3){
camTarget.x = (camTarget.x - (Math.cos(camAngle) * _arg1));
camTarget.z = (camTarget.z + (Math.sin(camAngle) * _arg1));
};
};
};
};
camPos = Vector.add(camPos, Vector.scale(0.5, Vector.sub(camTarget, camPos)));
}
override protected function loadingComplete(_arg1:Event):void{
var _local2:Sprite;
var _local3:MovieClip;
var _local4:uint;
var _local5:Number;
super.loadingComplete(_arg1);
gfx_landscape1 = getLoadedClass("gfx_landscape1");
gfx_landscape2 = getLoadedClass("gfx_landscape2");
gfx_landscape3 = getLoadedClass("gfx_landscape3");
gfx_badger = getLoadedClass("gfx_badger");
gfx_grass0 = getLoadedClass("gfx_grass0");
gfx_grass1 = getLoadedClass("gfx_grass1");
gfx_grass2 = getLoadedClass("gfx_grass1");
gfx_grass3 = getLoadedClass("gfx_grass1");
gfx_bush = getLoadedClass("gfx_bush");
gfx_mushroom = getLoadedClass("gfx_mushroom");
gfx_sky = getLoadedClass("gfx_sky");
gfx_snake = getLoadedClass("gfx_snake");
_local2 = new gfx_sky();
gfx = new Sprite();
landscape1 = new gfx_landscape1();
landscape2 = new gfx_landscape2();
landscape3 = new gfx_landscape3();
air = new Sprite();
gfx.addChild(_local2);
gfx.addChild(air);
gfx.addChild(landscape1);
_local2.width = w;
_local2.height = (h2 * 1.1);
scene = (numBeat = (badgerFrameOffset = 0));
badgersPlay = false;
stuff = [];
badgers = [];
camPos = new Vector(0, 0.2, 0);
oldCamPos = camPos.clone();
camTarget = camPos.clone();
camAngle = 0;
_local4 = 0;
while (_local4 < 110) {
_local3 = getNewScenery();
stuff.push(_local3);
_local5 = ((camPos.z + (Math.random() * -8)) - 0.1);
_local3.pos = new Point((((Math.random() * 2) - 1) * -(_local5)), _local5);
gfx.addChild(_local3);
_local4++;
};
scrollMode = 0;
t = 0;
_local4 = 0;
while (_local4 < 0x0100) {
sHistory[_local4] = ((h2 - ((h2 * 0.2) * Math.sin((_local4 / 16)))) - (h2 * 0.3));
_local4++;
};
air.x = (((-(w) * 1.05) / 0xFF) - 1);
hillTarg = sHistory[0xFF];
tf = new TextField();
tf.type = TextFieldType.DYNAMIC;
tf.text = "http://theweebl.newgrounds.com";
tf.embedFonts = true;
tf.setTextFormat(new TextFormat("Arial", 12, 0xFFFFFF));
tf.selectable = false;
tf.width = (w - 20);
tf.alpha = 0.6;
snakeBeats = ((Math.random() * 8) + 3);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:MovieClip;
var _local4:uint;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local8:Number;
var _local9:uint;
if (((badgers[0]) && (_arg2.beat))){
badgersPlay = true;
};
if (badgersPlay){
badgerFrameOffset = (badgerFrameOffset + _arg1);
};
_local6 = badgers.length;
if (((snake) && (snake.deleted))){
snake = null;
};
if (_arg2.beat){
numBeat++;
if (badgers.length < 16){
_local3 = new gfx_badger();
badgers.push(_local3);
_local3.anim.stop();
_local3.badger = true;
_local3.pos = new Point(((camPos.x + (Math.random() * 5)) - 1), (camPos.z + (Math.random() * -4)));
gfx.addChild(_local3);
stuff.push(_local3);
};
snakeBeats--;
if (((!(snake)) && ((snakeBeats <= 0)))){
snakeBeats = ((Math.random() * 20) + 10);
snake = new gfx_snake();
gfx.addChild(snake);
stuff.push(snake);
_local8 = (Math.random() * -4);
snake.scaleX = -1;
snake.pos = new Point((camPos.x - _local8), (camPos.z + _local8));
};
};
if (tf.alpha > 0){
tf.alpha = (8 - t);
};
if (snake){
snake.pos.x = (snake.pos.x - (_arg1 * 1.2));
snake.pos.y = (snake.pos.y - (0.3 * _arg1));
};
if (_arg2.beat){
yBounce = 0.06;
} else {
yBounce = (yBounce * 0.6);
};
_local7 = 0;
while (badgerFrameOffset >= (1 / 30)) {
_local7++;
badgerFrameOffset = (badgerFrameOffset - (1 / 30));
};
if (badgers[0]){
_local9 = (badgers[0].anim.currentFrame + _local7);
if (_local9 >= badgers[0].anim.totalFrames){
badgersPlay = false;
_local9 = 1;
};
};
updateCamera(_arg1);
updateScenery();
transformStuff();
stuff.sortOn("y");
_local4 = 0;
while (_local4 < badgers.length) {
if (badgers[_local4].deleted){
badgers.splice(_local4, 1);
_local4--;
} else {
badgers[_local4].anim.gotoAndStop(_local9);
};
_local4++;
};
_local4 = 0;
while (_local4 < stuff.length) {
_local5 = gfx.getChildIndex(stuff[_local4]);
gfx.swapChildrenAt((_local4 + 3), _local5);
_local4++;
};
t = (t + _arg1);
air.x = (air.x - (_arg1 * 10));
if (air.x <= ((-(w) * 1.05) / 0xFF)){
hillTarg = ((h2 - ((h2 * Math.sin(((t / 3.45) + ((9 * Math.PI) / 8)))) * 0.2)) - (h2 * 0.3));
sHistory.push(hillTarg);
sHistory.shift();
air.x = 0;
air.graphics.clear();
air.graphics.lineStyle(0, 0, 0);
air.graphics.moveTo(0, h2);
air.graphics.beginFill(groundColor);
_local4 = 0;
while (_local4 < 0x0100) {
air.graphics.lineTo((((w * 1.05) * _local4) / 0xFF), sHistory[_local4]);
_local4++;
};
air.graphics.lineTo(w, h2);
air.graphics.lineTo(0, h2);
air.graphics.endFill();
};
pixels.lock();
pixels.draw(gfx);
pixels.draw(tf, new Matrix(1, 0, 0, 1, 5, (h - 17)), new ColorTransform(1, 1, 1, 0.6));
pixels.unlock();
}
private function updateScenery():void{
var _local1:uint;
var _local2:uint;
var _local3:Number;
var _local4:uint;
var _local5:MovieClip;
var _local6:Point;
var _local7:Number;
_local3 = 4;
_local4 = 0;
_local2 = stuff.length;
_local6 = new Point(camPos.x, camPos.z);
_local1 = 0;
while (_local1 < _local2) {
_local5 = stuff[_local1];
if (_local5.x < -(_local5.width)){
gfx.removeChild(_local5);
if (!_local5.badger){
_local4++;
};
_local5.deleted = true;
stuff.splice(_local1, 1);
_local1--;
_local2--;
};
_local1++;
};
_local1 = 0;
while (_local1 < _local4) {
_local5 = getNewScenery();
stuff.push(_local5);
_local7 = ((camPos.z + (Math.random() * -6)) - 0.1);
_local5.pos = new Point((camPos.x + (1.1 * -(_local7))), _local7);
gfx.addChild(_local5);
_local1++;
};
}
private function transformStuff():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:uint;
var _local7:MovieClip;
_local2 = Math.cos(-(camAngle));
_local3 = Math.sin(-(camAngle));
_local6 = 0;
while (_local6 < stuff.length) {
_local7 = stuff[_local6];
if (_local7.deleted){
stuff.splice(_local6, 1);
_local6--;
} else {
_local5 = ((_local7.pos.x * _local3) + (_local7.pos.y * _local2));
if (_local5 < camPos.z){
_local4 = ((_local7.pos.x * _local2) - (_local7.pos.y * _local3));
_local1 = (camPos.z - _local5);
_local7.x = (w2 + ((maxDim * (_local4 - camPos.x)) / (0.5 + _local1)));
_local7.y = (h2 - ((maxDim * -(camPos.y)) / _local1));
_local7.visible = true;
if (_local7.scaleX < 0){
_local7.scaleX = (-1 / (_local1 + 1));
} else {
_local7.scaleX = (1 / (_local1 + 1));
};
_local7.scaleY = (1 / (_local1 + 1));
} else {
_local7.visible = false;
};
};
_local6++;
};
landscape1.y = h2;
landscape1.scaleY = (camPos.y * 2.2);
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 13
//CoronaVisualization (mwelsh.audio.visualizer.visualizations.CoronaVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class CoronaVisualization extends Visualization {
private const FADE_TIME:Number = 0.01;
private const WAIT_TIME:Number = 1;
private var visRot:Number;
private var visColor:Boolean;
private var scale:Number;
private var ringRadius:Number;
private var visColor1:uint;
private var visColor2:uint;
public function CoronaVisualization(_arg1:uint, _arg2:uint){
super(_arg1, _arg2);
visRot = 0;
visColor1 = (((uint((Math.random() * 0x0100)) << 16) | (uint((Math.random() * 0x0100)) << 8)) | uint((Math.random() * 0x0100)));
visColor2 = (((uint((Math.random() * 0x0100)) << 16) | (uint((Math.random() * 0x0100)) << 8)) | uint((Math.random() * 0x0100)));
scale = 0;
ringRadius = (Math.min(_arg1, _arg2) * 0.2);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:uint;
var _local7:Matrix;
var _local8:Number;
pixels.lock();
vectors.graphics.clear();
_local3 = (h / 2);
if (_arg2.smartBeat){
visColor1 = (((uint((Math.random() * 0x0100)) << 16) | (uint((Math.random() * 0x0100)) << 8)) | uint((Math.random() * 0x0100)));
visColor2 = (((uint((Math.random() * 0x0100)) << 16) | (uint((Math.random() * 0x0100)) << 8)) | uint((Math.random() * 0x0100)));
};
visColor = !(visColor);
vectors.graphics.lineStyle(2, (visColor) ? visColor1 : visColor2, 1, false, LineScaleMode.NONE);
_local4 = _arg2.rawAvg[0];
vectors.graphics.moveTo(((w2 + (ringRadius * (1 + scale))) + ((_local4 * w) * 0.1)), _local3);
_local6 = 1;
while (_local6 < 0x0100) {
_local4 = _arg2.rawAvg[_local6];
_local5 = (((_local6 * 2) * Math.PI) / 0xFF);
vectors.graphics.lineTo((w2 + (Math.cos(_local5) * ((ringRadius * (1 + scale)) + ((_local4 * w) * 0.1)))), (_local3 + (Math.sin(_local5) * ((ringRadius * (1 + scale)) + ((_local4 * h) * 0.1)))));
_local6++;
};
_local4 = _arg2.rawAvg[0];
vectors.graphics.lineTo(((w2 + (ringRadius * (1 + scale))) + ((_local4 * w) * 0.1)), _local3);
scale = (scale + (10 * _arg1));
if (scale > 0){
scale = 0;
};
if (_arg2.beat){
scale = (scale - 1);
};
_local7 = new Matrix();
_local8 = (1 + (_arg1 * 5));
_local7.a = _local8;
_local7.d = _local8;
_local7.tx = (-((_local8 - 1)) * w2);
_local7.ty = (-((_local8 - 1)) * _local3);
bufferBmp.lock();
bufferBmp.draw(pixels, _local7, null, null);
bufferBmp.unlock();
_local7 = new Matrix();
pixels.draw(bufferBmp, _local7, null, null, pixels.rect);
_local7 = new Matrix();
_local7.translate(((Math.sin(((visRot * 0.2) + 1.2)) * w2) * 0.2), ((Math.cos(visRot) * _local3) * 0.1));
pixels.draw(vectors, _local7);
pixels.applyFilter(pixels, pixels.rect, new Point(0, 0), new BlurFilter(4, 4, 1));
visRot = (visRot + _arg1);
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 14
//CyclotronVisualization (mwelsh.audio.visualizer.visualizations.CyclotronVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
public class CyclotronVisualization extends Visualization {
private var sampBeats:Array;
private var bgColor:uint;// = 4284874854
private var samps:Array;
private var t:Number;// = 0
private var pers:Number;// = 4
public function CyclotronVisualization(_arg1:uint, _arg2:uint){
bgColor = 4284874854;
t = 0;
samps = [];
sampBeats = [];
pers = 4;
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, bgColor);
bufferBmp.fillRect(bufferBmp.rect, bgColor);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:uint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:uint;
var _local12:Number;
var _local13:uint;
pixels.lock();
bufferBmp.lock();
if (_arg2.beat){
} else {
pers = (pers + ((4 - pers) / 2));
};
t = (t + _arg1);
vectors.graphics.clear();
saveBuffer();
pixels.fillRect(pixels.rect, bgColor);
samps.unshift(_arg2.fftAvg);
sampBeats.unshift(_arg2.beat);
_local6 = 32;
if (samps.length > _local6){
samps.pop();
sampBeats.pop();
};
_local3 = (samps.length / 2);
_local9 = (1 + ((4 * Math.sin(((Math.PI * _local3) / (_local6 - 1)))) / pers));
_local12 = -(Math.cos(((Math.PI * _local3) / _local6)));
_local4 = 0;
while (_local4 < 0x0100) {
_local8 = (((2 * _local4) / 0xFF) - 1);
_local7 = (_local12 + (Math.cos(((Math.PI * _local3) / (_local6 - 1))) * samps[_local3][_local4]));
_local10 = (4 + (samps[_local3][_local4] * 4));
if (sampBeats[_local3]){
_local11 = uint(4294936831);
} else {
_local13 = uint((68 + (187 * Math.min(samps[_local3][_local4], 1))));
_local11 = ((4278190080 | (_local13 << 16)) | _local13);
};
pixels.fillRect(new Rectangle(((((_local7 * w2) / _local9) + w2) - 4), ((h2 - ((_local8 * h2) / _local9)) - 4), 8, 8), _local11);
_local4 = (_local4 + 2);
};
_local3 = ((samps.length / 2) + 1);
while (_local3 < samps.length) {
_local9 = (1 + ((4 * Math.sin(((Math.PI * _local3) / (_local6 - 1)))) / pers));
_local12 = -(Math.cos(((Math.PI * _local3) / _local6)));
_local4 = 0;
while (_local4 < 0x0100) {
_local8 = (((2 * _local4) / 0xFF) - 1);
_local7 = (_local12 + (Math.cos(((Math.PI * _local3) / (_local6 - 1))) * samps[_local3][_local4]));
_local10 = (4 + (samps[_local3][_local4] * 4));
if (sampBeats[_local3]){
_local11 = uint(4294936831);
} else {
_local13 = uint((68 + (187 * Math.min(samps[_local3][_local4], 1))));
_local11 = ((4278190080 | (_local13 << 16)) | _local13);
};
pixels.fillRect(new Rectangle(((((_local7 * w2) / _local9) + w2) - 4), ((h2 - ((_local8 * h2) / _local9)) - 4), 8, 8), _local11);
_local4 = (_local4 + 2);
};
_local3++;
};
_local3 = ((samps.length / 2) - 1);
while (_local3 >= 0) {
_local9 = (1 + ((4 * Math.sin(((Math.PI * _local3) / (_local6 - 1)))) / pers));
_local12 = -(Math.cos(((Math.PI * _local3) / _local6)));
_local4 = 0;
while (_local4 < 0x0100) {
_local8 = (((2 * _local4) / 0xFF) - 1);
_local7 = (_local12 + (Math.cos(((Math.PI * _local3) / (_local6 - 1))) * samps[_local3][_local4]));
_local10 = (4 + (samps[_local3][_local4] * 4));
if (sampBeats[_local3]){
_local11 = uint(4294936831);
} else {
_local13 = uint((68 + (187 * Math.min(samps[_local3][_local4], 1))));
_local11 = ((4278190080 | (_local13 << 16)) | _local13);
};
pixels.fillRect(new Rectangle(((((_local7 * w2) / _local9) + w2) - 3), ((h2 - ((_local8 * h2) / _local9)) - 3), 6, 6), _local11);
_local4 = (_local4 + 2);
};
_local3--;
};
pixels.draw(vectors);
bufferBmp.unlock();
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 15
//DietCokeVisualization (mwelsh.audio.visualizer.visualizations.DietCokeVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
public class DietCokeVisualization extends Visualization {
private var sampBeats:Array;
private var bgColor:uint;// = 4289357363
private var samps:Array;
private var vt:Number;// = 0
private var alphaShift:Number;// = 0
private var bgColor2:uint;// = 4288238882
private var t:Number;// = 0
private var foamData:Array;
public function DietCokeVisualization(_arg1:uint, _arg2:uint){
var _local3:uint;
bgColor = 4289357363;
bgColor2 = 4288238882;
t = 0;
samps = [];
sampBeats = [];
vt = 0;
alphaShift = 0;
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, bgColor);
bufferBmp.fillRect(bufferBmp.rect, bgColor);
foamData = [];
_local3 = 0;
while (_local3 < 0x0100) {
foamData[_local3] = 0;
_local3++;
};
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:Array;
var _local4:int;
var _local5:int;
var _local6:Number;
var _local7:uint;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:uint;
var _local13:Number;
pixels.lock();
bufferBmp.lock();
if (_arg2.beat){
vt = 0.1;
} else {
vt = (vt * 0.8);
};
t = (t + (_arg1 + vt));
_local3 = _arg2.generateSmoothedData(2, false);
_local4 = 0;
while (_local4 < 0x0100) {
foamData[_local4] = (foamData[_local4] + ((_local3[_local4] - foamData[_local4]) / 2));
_local4++;
};
vectors.graphics.clear();
pixels.fillRect(pixels.rect, bgColor);
pixels.draw(vectors);
vectors.graphics.clear();
samps.unshift(_arg2.fftAvg);
sampBeats.unshift(_arg2.beat);
_local7 = 32;
if (samps.length > _local7){
samps.pop();
sampBeats.pop();
};
_local4 = (samps.length - 1);
while (_local4 >= 0) {
_local10 = (1 + (((5 * _local4) / (_local7 - 1)) / 2));
_local13 = -(Math.cos(((4 * _local4) / _local7)));
_local5 = 0;
while (_local5 < 0x0100) {
_local8 = (((2 * _local5) / 0xFF) - 1);
_local9 = (_local13 + samps[_local4][_local5]);
_local11 = (4 + (samps[_local4][_local5] * 4));
_local12 = (((4278190080 | (uint((170 + (samps[_local4][_local5] * ((sampBeats[_local4]) ? 232 : 200 - 170)))) << 16)) | (uint((102 + (samps[_local4][_local5] * ((sampBeats[_local4]) ? 175 : 143 - 102)))) << 8)) | uint((51 + (samps[_local4][_local5] * ((sampBeats[_local4]) ? 116 : 84 - 51)))));
if (sampBeats[_local4]){
pixels.fillRect(new Rectangle((((_local8 * w2) + w2) - 4), ((h2 - (_local9 * h2)) - 4), 8, 8), (4278190080 | _local12));
} else {
pixels.fillRect(new Rectangle((((_local8 * w2) + w2) - 2), ((h2 - (_local9 * h2)) - 2), 4, 4), (4278190080 | _local12));
};
_local5 = (_local5 + 2);
};
_local4--;
};
if (_arg2.smartBeat){
alphaShift = 0.2;
} else {
alphaShift = (alphaShift * 0.9);
};
vectors.graphics.beginFill(4294962858, (0.8 + alphaShift));
vectors.graphics.lineStyle(0, 0, 0);
vectors.graphics.moveTo(w, 0);
vectors.graphics.lineTo(0, 0);
_local4 = 0;
while (_local4 < 0x0100) {
vectors.graphics.lineTo(((w * _local4) / 0xFF), (((h * 0.1) + ((foamData[_local4] * h) * 0.05)) - ((h * 0.05) * Math.pow((Math.abs((_local4 - 128)) / 128), 2))));
_local4++;
};
vectors.graphics.lineTo(w, 0);
vectors.graphics.endFill();
pixels.draw(vectors);
bufferBmp.unlock();
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 16
//Fountain3DVisualization (mwelsh.audio.visualizer.visualizations.Fountain3DVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import mwelsh.math.*;
import mwelsh.thunder3d.*;
import mwelsh.audio.visualizer.visualizations.geom3d.*;
public class Fountain3DVisualization extends ThreeDeeVisualization {
private var t:Number;
public function Fountain3DVisualization(_arg1:uint, _arg2:uint):void{
super(_arg1, _arg2, new RasterRenderer((_arg1 + 1), (_arg2 + 1)));
objects = [new Fountain3D()];
t = 0;
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:uint;
var _local4:uint;
r.camLook = new Vector(0, 0, 0);
t = (t + _arg1);
r.camPos.x = (Math.sin(t) * 5);
r.camPos.z = (Math.cos((t / 2.1231231)) * 5);
r.camPos.y = 3;
r.lightPos.x = (Math.sin(t) * 2);
r.lightPos.y = ((Math.cos((t + 0.4)) * 2) + 1.5);
r.lightPos.z = (Math.cos(((t * 0.23132) + 5)) * 2);
if (_arg2.beat){
objects.push(new FountainParticles());
};
_local3 = objects.length;
_local4 = 1;
while (_local4 < _local3) {
if (FountainParticles(objects[_local4]).life <= 0){
objects.splice(_local4, 1);
_local4--;
_local3--;
};
_local4++;
};
objects[0].soundData = _arg2;
tickObjects(_arg1);
saveBuffer();
r.drawObj(objects);
r.render(pixels);
drawBuffer(null, new ColorTransform(1, 1, 1, 0.5));
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 17
//HypnoVisualization (mwelsh.audio.visualizer.visualizations.HypnoVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
public class HypnoVisualization extends Visualization {
private var y:Number;
private var yTarg:Number;
private var lineError:int;
private var cPeriod:Number;
private var spiralV:Number;// = 5
private var lineJ:int;
private var bgColor:uint;// = 4282707711
private var lineTemp:Number;
private var blurScale:Number;// = 0
private var lineDy:int;
private var data:Array;
private var lineDx:int;
private var lineYstep:int;
private var lineSteep:Boolean;
private var cCo:Number;
private var sCo:Number;
private var sPeriod:Number;
private var cShift:Number;
private var lineW:uint;
private var thetaStart:Number;// = 0
private var lineY:int;
private var lineX:int;
private var sShift:Number;
private var t:Number;// = 0
private var x:Number;
private var xTarg:Number;
public function HypnoVisualization(_arg1:uint, _arg2:uint){
var _local3:uint;
bgColor = 4282707711;
t = 0;
thetaStart = 0;
spiralV = 5;
blurScale = 0;
data = [];
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, bgColor);
bufferBmp.fillRect(bufferBmp.rect, bgColor);
_local3 = 0;
while (_local3 < 0x0100) {
data[_local3] = 0;
_local3++;
};
x = (xTarg = w2);
y = (yTarg = h2);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:uint;
var _local4:int;
var _local5:int;
var _local6:Number;
var _local7:Matrix;
pixels.lock();
bufferBmp.lock();
_local3 = 1088;
saveBuffer();
_local4 = 0;
while (_local4 < 0x0100) {
data[_local4] = (data[_local4] + ((_arg2.rawAvg[_local4] - data[_local4]) * 0.6));
_local4++;
};
pixels.fillRect(pixels.rect, bgColor);
vectors.graphics.clear();
vectors.graphics.lineStyle(20, 4278190301, 1);
thetaStart = (thetaStart + (_arg1 * (3 + spiralV)));
if (_arg2.beat){
spiralV = (spiralV + 5.5);
} else {
spiralV = (spiralV * 0.95);
};
t = (t + (_arg1 + (spiralV / 40)));
x = (x + ((xTarg - x) * 0.1));
y = (y + ((yTarg - y) * 0.1));
vectors.graphics.moveTo(x, y);
_local4 = 0;
_local6 = thetaStart;
while (_local4 < _local3) {
vectors.graphics.lineTo((x + (((((Math.cos(_local6) * (1 + (data[(_local4 % 0x0100)] / 4))) * w2) * 1.2) * (_local4 + 2)) / _local3)), (y + (((((Math.sin(_local6) * (1 + (data[(_local4 % 0x0100)] / 4))) * w2) * 1.2) * (_local4 + 2)) / _local3)));
_local4++;
_local6 = (_local6 + ((16 * Math.PI) / _local3));
};
pixels.draw(vectors);
_local7 = new Matrix();
_local7.scale((1 + blurScale), (1 + blurScale));
drawBuffer(null, new ColorTransform(1, 1, 1, 0.9));
bufferBmp.unlock();
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 18
//LavaberryVisualization (mwelsh.audio.visualizer.visualizations.LavaberryVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class LavaberryVisualization extends Visualization {
private const NUM_RAYS:uint = 10;
private var yShift:Number;
private var sampBeats:Array;
private var bgColor:uint;// = 4294901760
private var samps:Array;
private var bData:BitmapData;
private var vt:Number;// = 0
private var thetaSpeed:Number;// = 0
private var alphaShift:Number;// = 0
private var lineColor:Number;// = 0
private var thetaFrequency:Number;// = 0
private var thetaOffset:Number;// = 0
private var d:Array;
private var xShift:Number;
private var t:Number;// = 0
private var tfTarg:Number;// = 0
private var foamData:Array;
public function LavaberryVisualization(_arg1:uint, _arg2:uint){
var _local3:uint;
var _local4:Number;
var _local5:uint;
bgColor = 4294901760;
t = 0;
samps = [];
sampBeats = [];
vt = 0;
alphaShift = 0;
thetaOffset = 0;
thetaSpeed = 0;
thetaFrequency = 0;
tfTarg = 0;
lineColor = 0;
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, bgColor);
bData = new BitmapData(w, h, false);
_local3 = (BitmapDataChannel.RED | BitmapDataChannel.BLUE);
bData.perlinNoise(100, 80, 4, (Math.random() * 10), false, true, _local3, false, null);
_local4 = ((2 * Math.PI) * Math.random());
xShift = Math.cos(_local4);
yShift = Math.sin(_local4);
d = [];
_local5 = 0;
while (_local5 < 0x0100) {
d[_local5] = 0;
_local5++;
};
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:uint;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
pixels.lock();
bufferBmp.lock();
pixels.applyFilter(pixels, pixels.rect, new Point(), new DisplacementMapFilter(bData, new Point(), BitmapDataChannel.RED, BitmapDataChannel.BLUE, (xShift * 20), (yShift * 20)));
if (_arg2.beat){
_local4 = ((Math.random() * 2) * Math.PI);
xShift = Math.cos(_local4);
yShift = Math.sin(_local4);
thetaSpeed = ((Math.random() > 0.5)) ? 5 : -5;
tfTarg = ((Math.random() > 0.5)) ? 2 : -2;
} else {
thetaSpeed = (thetaSpeed * 0.8);
tfTarg = (tfTarg * 0.95);
};
thetaFrequency = (thetaFrequency + ((tfTarg - thetaFrequency) / 2));
if (_arg2.smartBeat){
lineColor = 1;
} else {
lineColor = (lineColor * 0.9);
};
_local3 = 0;
while (_local3 < 0x0100) {
d[_local3] = (d[_local3] + ((_arg2.rawAvg[_local3] - d[_local3]) / 3));
_local3++;
};
thetaOffset = (thetaOffset + (_arg1 + ((thetaSpeed * 2) * _arg1)));
vectors.graphics.clear();
vectors.graphics.lineStyle((2 + (5 * lineColor)), ((0xFF0000 | (uint((lineColor * 136)) << 8)) | uint((lineColor * 136))));
vectors.graphics.moveTo(0, h2);
_local3 = 0;
_local7 = -1;
while (_local7 < 1) {
_local4 = ((_local7 * (10 + thetaFrequency)) + thetaOffset);
vectors.graphics.lineTo((((_local7 + 1) * w2) + (((Math.cos(_local4) * d[_local3]) * h2) * 0.8)), ((h2 + ((h2 * 0.3) * Math.sin((_local4 / 4.123)))) + ((h2 + ((d[_local3] * h2) * 0.8)) * f(_local4))));
_local3++;
_local7 = (_local7 + (1 / 128));
};
vectors.filters = [new GlowFilter(0x990000, 1, 6, 6, 1)];
pixels.draw(vectors);
vectors.filters = [];
bufferBmp.unlock();
pixels.unlock();
}
private function f(_arg1:Number):Number{
if (_arg1 < 0){
_arg1 = (-(_arg1) + Math.PI);
};
return ((((_arg1 % (2 * Math.PI)) > Math.PI)) ? -0.8 : 0.8);
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 19
//MobiusStripVisualization (mwelsh.audio.visualizer.visualizations.MobiusStripVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import mwelsh.math.*;
import mwelsh.thunder3d.geom3d.*;
import mwelsh.thunder3d.*;
public class MobiusStripVisualization extends ThreeDeeVisualization {
private var mobiusPoints:Array;
private var pBounce:Number;// = 0
private var mobSin:Array;
private var particles:Array;
private var WIDTH:uint;// = 4
private var particlesShift:Number;// = 0
private var mobiusVals:Array;
private var LENGTH:uint;// = 20
private var t:Number;
private var mobCos:Array;
private var obj:Object3D;
public function MobiusStripVisualization(_arg1:uint, _arg2:uint):void{
var _local3:Number;
var _local4:Number;
var _local5:uint;
var _local6:uint;
var _local7:Polygon;
var _local8:Vertex;
WIDTH = 4;
LENGTH = 20;
particlesShift = 0;
pBounce = 0;
super(_arg1, _arg2, new VectorRenderer(_arg1, _arg2));
r.camPos.z = 5;
r.camLook = new Vector();
r.lightPos = new Vector(1, 1, 5);
t = 0;
objects = [(obj = new Object3D())];
obj.verts = [];
obj.polys = [];
mobiusPoints = [];
mobiusVals = [];
mobCos = [];
mobSin = [];
particles = [];
_local5 = 0;
while (_local5 < LENGTH) {
_local3 = ((_local5 * Math.PI) / (LENGTH / 2));
mobiusPoints[_local5] = [];
mobCos[_local5] = Math.cos(_local3);
mobSin[_local5] = Math.sin(_local3);
_local6 = 0;
while (_local6 < (WIDTH + 1)) {
_local4 = ((_local6 / (WIDTH / 2)) - 1);
mobiusPoints[_local5][_local6] = new Vector(((1 + ((_local4 * Math.cos((_local3 / 2))) / 2)) * mobCos[_local5]), ((1 + ((_local4 * Math.cos((_local3 / 2))) / 2)) * mobSin[_local5]), ((_local4 * Math.sin((_local3 / 2))) / 2));
_local6++;
};
_local5++;
};
obj.verts.push(new Vertex(new Vector(), new Vector(0, 0.9, 0)));
_local6 = 1;
while (_local6 < (WIDTH + 1)) {
obj.verts.push(new Vertex(new Vector(), new Vector(0, 0.9, 0)));
_local6++;
};
_local5 = 1;
while (_local5 < LENGTH) {
obj.verts.push(new Vertex(new Vector(), new Vector(0, 0.9, 0)));
_local6 = 1;
while (_local6 < (WIDTH + 1)) {
obj.verts.push(new Vertex(new Vector(), new Vector(0, 0.9, 0)));
_local7 = new Polygon([obj.verts[(((_local5 - 1) * (WIDTH + 1)) + _local6)], obj.verts[((_local5 * (WIDTH + 1)) + _local6)], obj.verts[(((_local5 * (WIDTH + 1)) + _local6) - 1)], obj.verts[((((_local5 - 1) * (WIDTH + 1)) + _local6) - 1)]]);
obj.polys.push(_local7);
_local7.lineColor = 0xFF00;
_local6++;
};
_local5++;
};
_local6 = 1;
while (_local6 < (WIDTH + 1)) {
_local7 = new Polygon([obj.verts[(((LENGTH - 1) * (WIDTH + 1)) + (WIDTH - _local6))], obj.verts[_local6], obj.verts[(_local6 - 1)], obj.verts[(((LENGTH - 1) * (WIDTH + 1)) + (WIDTH - (_local6 - 1)))]]);
obj.polys.push(_local7);
_local7.lineColor = 0xFF00;
_local6++;
};
_local5 = 0;
while (_local5 < LENGTH) {
_local6 = 0;
while (_local6 < (WIDTH + 1)) {
mobiusVals[((_local5 * (WIDTH + 1)) + _local6)] = 0;
Vertex(obj.verts[((_local5 * (WIDTH + 1)) + _local6)]).pos = Vector(mobiusPoints[_local5][_local6]).clone();
_local6++;
};
_local5++;
};
obj.backfaceCulling = false;
obj.scale = new Vector(3, 3, 3);
_local8 = new Vertex(new Vector(), new Vector(1, 1, 0.3));
_local5 = 0;
while (_local5 < 100) {
_local8 = new Vertex(new Vector(0, 0, 0), new Vector(1, 0.3, 1));
obj.verts.push(_local8);
obj.polys.push(new Polygon([_local8]));
particles.push(_local8);
_local5++;
};
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:Vertex;
var _local4:uint;
var _local5:uint;
var _local6:Vertex;
var _local7:uint;
t = (t + _arg1);
_local4 = 0;
while (_local4 < LENGTH) {
_local5 = 0;
while (_local5 < (WIDTH + 1)) {
mobiusVals[((_local4 * (WIDTH + 1)) + _local5)] = (mobiusVals[((_local4 * (WIDTH + 1)) + _local5)] + ((((_arg2.rawLeft[uint(((_local4 / (LENGTH - 1)) * 0xFF))] * (_local5 / WIDTH)) + (_arg2.rawRight[uint(((_local4 / (LENGTH - 1)) * 0xFF))] * (1 - (_local5 / WIDTH)))) - mobiusVals[((_local4 * (WIDTH + 1)) + _local5)]) / 4));
_local3 = obj.verts[((_local4 * (WIDTH + 1)) + _local5)];
_local3.pos = Vector.scale((1 + mobiusVals[((_local4 * (WIDTH + 1)) + _local5)]), mobiusPoints[_local4][_local5]);
_local5++;
};
_local4++;
};
r.camPos.x = (Math.sin(t) * 5);
r.camPos.z = (Math.cos((t / 2.1231231)) * 5);
r.camPos.y = 2;
if (_arg2.beat){
pBounce = 1;
} else {
pBounce = (pBounce * 0.9);
};
particlesShift = (particlesShift + (_arg1 * (1 + (pBounce * 0.5))));
_local7 = particles.length;
_local4 = 0;
while (_local4 < particles.length) {
_local6 = particles[_local4];
_local6.pos.x = ((1 + (Math.cos(((((_local4 * 4) * Math.PI) / _local7) / 2)) / 2)) * Math.cos(((((_local4 * 4) * Math.PI) / _local7) + particlesShift)));
_local6.pos.y = ((1 + (Math.cos(((((_local4 * 4) * Math.PI) / _local7) / 2)) / 2)) * Math.sin(((((_local4 * 4) * Math.PI) / _local7) + particlesShift)));
_local6.pos.z = (Math.sin(((((_local4 * 4) * Math.PI) / _local7) / 2)) / 2);
_local6.color.y = (0.3 + (0.7 * pBounce));
_local4++;
};
tickObjects(_arg1);
r.clearScreen(pixels, 4278211840);
r.drawObj(objects);
r.render(pixels);
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 20
//NeonTideVisualization (mwelsh.audio.visualizer.visualizations.NeonTideVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class NeonTideVisualization extends Visualization {
private var dir:int;// = -1
private var tShiftTarg:Number;// = 0
private var col2r:Number;
private var yPos:Number;// = 0
private var bars:Array;
private var vy:Number;// = 0
private var col1g:Number;
private var col1b:Number;
private var col1r:Number;
private var col2g:Number;
private var scrollSpeed:Number;// = 0
private var tShift:Number;// = 0
private var col2b:Number;
public function NeonTideVisualization(_arg1:uint, _arg2:uint){
scrollSpeed = 0;
dir = -1;
yPos = 0;
vy = 0;
tShiftTarg = 0;
tShift = 0;
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, 4278190080);
col1r = Math.random();
col1g = Math.random();
col1b = Math.random();
col1r = Math.random();
col2g = Math.random();
col2b = Math.random();
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:Array;
var _local4:uint;
var _local5:uint;
var _local6:Number;
var _local7:Number;
pixels.lock();
bufferBmp.lock();
_local3 = _arg2.generateSmoothedData(3, false);
vectors.graphics.clear();
if (_arg2.beat){
vy = ((Math.random() * 10) - 5);
tShiftTarg = (((Math.random() * 4) * Math.PI) - (2 * Math.PI));
};
tShift = (tShift + ((tShiftTarg - tShift) * 0.1));
if (_arg2.smartBeat){
col1r = Math.random();
col1g = Math.random();
col1b = Math.random();
col2r = Math.random();
col2g = Math.random();
col2b = Math.random();
};
yPos = (yPos + vy);
if (_arg2.smartBeat){
dir = -(dir);
};
if (yPos < 0){
_local6 = (yPos % (h * 0.2));
} else {
_local6 = ((yPos % (h * 0.2)) - (h * 0.2));
};
while (_local6 < h) {
_local7 = (_local6 / h);
vectors.graphics.lineStyle(3, (((4278190080 | (uint((0xFF * (col1r + (_local7 * (col2r - col1r))))) << 16)) | (uint((0xFF * (col1g + (_local7 * (col2g - col1g))))) << 8)) | uint((0xFF * (col1b + (_local7 * (col2b - col1b)))))));
_local5 = 0;
vectors.graphics.moveTo(((w * _local5) / 0xFF), ((_local6 + ((((h2 * 0.5) * ((2 * _local7) - 1)) * (Math.cos((tShift + (((2 * Math.PI) * _local5) / 0xFF))) + 1)) / 2)) + (((h2 * 0.8) * ((2 * _local7) - 1)) * _local3[_local5])));
while (_local5 < 0x0100) {
vectors.graphics.lineTo(((w * _local5) / 0xFF), ((_local6 + ((((h2 * 0.5) * ((2 * _local7) - 1)) * (Math.cos((tShift + (((2 * Math.PI) * _local5) / 0xFF))) + 1)) / 2)) + (((h2 * 0.8) * ((2 * _local7) - 1)) * _local3[_local5])));
_local5++;
};
_local6 = (_local6 + (h * 0.2));
};
pixels.draw(vectors, null, null);
pixels.applyFilter(pixels, pixels.rect, new Point(), new BlurFilter(4, 4));
bufferBmp.unlock();
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 21
//Portal3DVisualization (mwelsh.audio.visualizer.visualizations.Portal3DVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import mwelsh.math.*;
import mwelsh.thunder3d.*;
import mwelsh.audio.visualizer.visualizations.geom3d.*;
public class Portal3DVisualization extends ThreeDeeVisualization {
private var t:Number;
public function Portal3DVisualization(_arg1:uint, _arg2:uint){
super(_arg1, _arg2, new VectorRenderer(_arg1, _arg2));
objects = [new Tunnel3D(), new TunnelLight()];
r.camPos.z = 10;
r.lightPos = new Vector(0, 0, 5);
t = 0;
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
t = (t + _arg1);
r.lightPos.y = (5 * Math.sin((t - 0.625)));
r.camRot.z = Math.sin(t);
r.camRot.x = (Math.sin((t / 1.4)) * 0.2);
r.camPos.y = (5 * Math.sin((t - 1.25)));
r.camRot.y = ((Math.cos(t) * 0.2) + (Math.cos((t * 1.6)) * 0.1));
objects[0].soundData = _arg2;
objects[1].soundData = _arg2;
super.tick(_arg1, _arg2);
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 22
//SauronVisualization (mwelsh.audio.visualizer.visualizations.SauronVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class SauronVisualization extends Visualization {
private var y:Number;// = 0
private var soundHistory:Array;
private var bufferAlpha:Number;// = 0
private var t:Number;// = 0
private var bgColor:uint;// = 4293831202
private var yPos:Array;
private var frontLineColor:uint;// = 4294945297
private var frontlineSize:Number;// = 0
private var xPos:Array;
private var tTarg:Number;// = 0
private var x:Number;// = 0
private var xTarg:Number;// = 0
private var yTarg:Number;// = 0
private var eyeVeinColor:uint;// = 4294936576
public function SauronVisualization(_arg1:uint, _arg2:uint){
bgColor = 4293831202;
eyeVeinColor = 4294936576;
frontLineColor = 4294945297;
soundHistory = [];
frontlineSize = 0;
bufferAlpha = 0;
tTarg = 0;
xTarg = 0;
yTarg = 0;
x = 0;
y = 0;
xPos = [];
yPos = [];
t = 0;
super(_arg1, _arg2);
pixels.fillRect(pixels.rect, bgColor);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:int;
var _local4:int;
var _local5:Array;
var _local6:Matrix;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
pixels.lock();
bufferBmp.lock();
_local5 = _arg2.generateSmoothedData(2, true);
_local3 = 0;
while (_local3 < 10) {
_local5[_local3] = (_local5[_local3] / ((11 - _local3) * 10));
_local5[0] = Math.pow((_local5[0] / 100), 3);
_local3++;
};
soundHistory.unshift(_local5);
xPos.unshift(x);
yPos.unshift(y);
if (soundHistory.length > 16){
soundHistory.pop();
xPos.pop();
yPos.pop();
};
if (_arg2.beat){
frontlineSize = 1;
} else {
frontlineSize = (frontlineSize * 0.7);
};
_local6 = new Matrix();
_local6.scale(1.04, 1.02);
drawBuffer(_local6, new ColorTransform(0.995, 0.99, 0.9, 1), BlendMode.DARKEN);
vectors.graphics.clear();
vectors.filters = [];
if (_arg2.smartBeat){
xTarg = (Math.random() - 0.5);
yTarg = (Math.random() - 0.5);
};
x = (x + ((xTarg - x) * 0.1));
y = (y + ((yTarg - y) * 0.1));
_local4 = 0;
while (_local4 < 128) {
_local3 = (soundHistory.length - 1);
_local9 = (_local3 / 15);
_local10 = (_local4 / 0xFF);
_local7 = ((1 - _local9) + 0.5);
_local11 = Math.cos(((2 * Math.PI) * _local10));
_local12 = Math.sin(((2 * Math.PI) * _local10));
vectors.graphics.moveTo(((((x + (_local11 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * w2) + w2), ((((y + (_local12 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * h2) + h2));
while (_local3 >= 0) {
_local9 = (_local3 / 15);
_local7 = ((1 - _local9) + 0.5);
_local8 = Math.min(((1 - (soundHistory[_local3][_local4] * 3)) + 0.2), 1);
vectors.graphics.lineStyle(3, ((4278190080 | (uint((_local8 * 0xFF)) << 16)) | (uint((_local8 * 136)) << 8)));
vectors.graphics.lineTo(((((x + (_local11 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * w2) + w2), ((((y + (_local12 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * h2) + h2));
_local3--;
};
_local4 = (_local4 + 5);
};
_local4 = 253;
while (_local4 >= 128) {
_local3 = (soundHistory.length - 1);
_local9 = (_local3 / 15);
_local10 = (_local4 / 0xFF);
_local7 = ((1 - _local9) + 0.5);
_local11 = Math.cos(((2 * Math.PI) * _local10));
_local12 = Math.sin(((2 * Math.PI) * _local10));
vectors.graphics.moveTo(((((x + (_local11 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * w2) + w2), ((((y + (_local12 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * h2) + h2));
while (_local3 >= 0) {
_local9 = (_local3 / 15);
_local7 = ((1 - _local9) + 0.5);
_local8 = Math.min(((1 - (soundHistory[_local3][_local4] * 3)) + 0.2), 1);
vectors.graphics.lineStyle(3, ((4278190080 | (uint((_local8 * 0xFF)) << 16)) | (uint((_local8 * 136)) << 8)));
vectors.graphics.lineTo(((((x + (_local11 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * w2) + w2), ((((y + (_local12 * ((0.001 + _local9) + soundHistory[_local3][_local4]))) * _local7) * h2) + h2));
_local3--;
};
_local4 = (_local4 - 5);
};
_local3 = 0;
_local7 = ((1 - (_local3 / 15)) + 0.5);
vectors.graphics.lineStyle((4 + (frontlineSize * 10)), (_arg2.beat) ? 4294954069 : frontLineColor);
_local4 = 0;
vectors.graphics.moveTo(((((x + (Math.cos((((2 * Math.PI) * _local4) / 0xFF)) * ((0.001 + (_local3 / 15)) + soundHistory[_local3][_local4]))) * _local7) * w2) + w2), ((((y + (Math.sin((((2 * Math.PI) * _local4) / 0xFF)) * ((0.001 + (_local3 / 15)) + soundHistory[_local3][_local4]))) * _local7) * h2) + h2));
while (_local4 < 0x0100) {
vectors.graphics.lineTo(((((x + (Math.cos((((2 * Math.PI) * _local4) / 0xFF)) * ((0.001 + (_local3 / 15)) + soundHistory[_local3][_local4]))) * _local7) * w2) + w2), ((((y + (Math.sin((((2 * Math.PI) * _local4) / 0xFF)) * ((0.001 + (_local3 / 15)) + soundHistory[_local3][_local4]))) * _local7) * h2) + h2));
_local4 = (_local4 + 1);
};
_local13 = 1;
if (_arg2.beat){
_local13 = 1.3;
};
vectors.graphics.lineStyle(0, 0, 0);
vectors.graphics.beginFill(0);
vectors.graphics.drawEllipse(((((x - ((0.02 * _local13) / 2)) * _local7) * w2) + w2), ((((y - ((0.4 * _local13) / 2)) * _local7) * h2) + h2), ((w * _local13) * 0.02), ((h * _local13) * 0.4));
vectors.graphics.endFill();
vectors.filters = [new GlowFilter(4292699648, 1, 20, 20, 20)];
_local6 = new Matrix();
_local6.scale(1.1, 1.1);
pixels.draw(vectors, _local6);
pixels.applyFilter(pixels, pixels.rect, new Point(), new BlurFilter(4, 2));
saveBuffer();
if (_arg2.beat){
saveBuffer(null, null, null, bufferBmp2);
bufferAlpha = 0.5;
} else {
bufferAlpha = (bufferAlpha * 0.95);
};
drawBuffer(null, new ColorTransform(1, 1, 1, bufferAlpha), BlendMode.ADD, bufferBmp2);
bufferBmp.unlock();
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 23
//SimpleSpectrumVisualization (mwelsh.audio.visualizer.visualizations.SimpleSpectrumVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class SimpleSpectrumVisualization extends Visualization {
private var curMax:Array;
private var soundEq:Array;
private var calibrating:Array;
private var max:Array;
private var numBars:uint;
private var numSegs:uint;
private var colors:Array;
public function SimpleSpectrumVisualization(_arg1:uint, _arg2:uint, _arg3:Number=16, _arg4:Number=16){
var _local5:uint;
super(_arg1, _arg2);
this.numBars = _arg3;
this.numSegs = _arg4;
soundEq = new Array(_arg3);
max = new Array(_arg3);
curMax = new Array(_arg3);
calibrating = new Array(_arg3);
_local5 = 0;
while (_local5 < _arg3) {
soundEq[_local5] = 0;
max[_local5] = 0;
curMax[_local5] = 1;
calibrating[_local5] = true;
_local5++;
};
colors = [];
_local5 = 0;
while (_local5 < 48) {
colors[_local5] = ((uint((_local5 * 5.3125)) << 16) | 0xFF00);
_local5++;
};
_local5 = 48;
while (_local5 < 128) {
colors[_local5] = (0xFF0000 | (uint(((128 - _local5) * 3.1875)) << 8));
_local5++;
};
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:Number;
var _local4:uint;
var _local5:uint;
var _local6:Number;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:uint;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
pixels.lock();
vectors.graphics.clear();
_local3 = Math.max(0, (1 - (4 * _arg1)));
pixels.applyFilter(pixels, pixels.rect, new Point(0, 0), new ColorMatrixFilter([_local3, 0, 0, 0, 0, 0, _local3, 0, 0, 0, 0, 0, _local3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]));
_local6 = 0;
_local7 = 0;
_local8 = (0x0100 / numBars);
_local4 = 0;
while (_local4 < numBars) {
_local9 = (_local8 - _local7);
_local6 = 0;
_local5 = _local7;
while (_local5 < _local8) {
_local6 = (_local6 + _arg2.fftAvg[_local5]);
_local5++;
};
soundEq[_local4] = Math.max((_local6 / _local9), Math.max((soundEq[_local4] - 0.05), 0));
max[_local4] = Math.max(soundEq[_local4], max[_local4]);
if (calibrating[_local4]){
if (max[_local4] > 0.1){
if (max[_local4] > 0.6){
curMax[_local4] = (curMax[_local4] + ((max[_local4] - curMax[_local4]) / 8));
} else {
if (max[_local4] > 0.3){
curMax[_local4] = (curMax[_local4] + ((max[_local4] - curMax[_local4]) / 16));
} else {
curMax[_local4] = (curMax[_local4] + ((max[_local4] - curMax[_local4]) / 32));
};
};
if (Math.abs((curMax[_local4] - max[_local4])) < 0.0001){
calibrating[_local4] = false;
};
};
} else {
curMax[_local4] = max[_local4];
};
_local7 = _local8;
_local8 = (_local8 + _local9);
_local4++;
};
vectors.graphics.lineStyle(0, 0, 0);
_local11 = (w * 0.03);
_local12 = ((w - ((numBars + 1) * _local11)) / numBars);
_local13 = (h * 0.02);
_local14 = ((h * (1.02 - (0.02 * numSegs))) / numSegs);
_local15 = (128 / numSegs);
_local4 = 0;
while (_local4 < numBars) {
_local5 = 0;
while (_local5 < Math.round(((numSegs * soundEq[_local4]) / curMax[_local4]))) {
_local10 = colors[Math.round((_local5 * _local15))];
vectors.graphics.beginFill(_local10);
vectors.graphics.drawRect(((_local11 * (_local4 + 1)) + (_local12 * _local4)), ((h - ((_local5 + 1) * _local14)) - (_local5 * _local13)), _local12, _local14);
vectors.graphics.endFill();
_local5++;
};
_local4++;
};
pixels.draw(vectors);
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 24
//SimpleWaveVisualization (mwelsh.audio.visualizer.visualizations.SimpleWaveVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import flash.geom.*;
public class SimpleWaveVisualization extends Visualization {
private var soundEq:Array;
public function SimpleWaveVisualization(_arg1:uint, _arg2:uint){
super(_arg1, _arg2);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:int;
var _local4:int;
pixels.lock();
vectors.graphics.clear();
pixels.colorTransform(pixels.rect, new ColorTransform(0.9, 0.9, 0.9));
vectors.graphics.lineStyle(0, 0, 0);
vectors.graphics.beginFill(0xFF00);
vectors.graphics.moveTo(w, h2);
vectors.graphics.lineTo(0, h2);
_local3 = 2;
_local4 = 0;
while (_local4 < 0x0100) {
vectors.graphics.lineTo(((w * _local4) / 0xFF), (h2 - ((_arg2.rawAvg[_local4] * h2) * 0.9)));
_local4 = (_local4 + _local3);
};
vectors.graphics.lineTo(w, h2);
vectors.graphics.endFill();
pixels.draw(vectors);
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 25
//SpinArtVisualization (mwelsh.audio.visualizer.visualizations.SpinArtVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.filters.*;
public class SpinArtVisualization extends Visualization {
private var c1x:Number;
private var c1y:Number;
private var leftMargin:Number;
private var theta:Number;
private var ray1theta:Number;// = 0
private var thetaTarg:Number;
private var ray1thetaTarg:Number;// = 0
private var vt:Number;// = 0
private var c3color:uint;
private var c0color:uint;
private var topMargin:Number;
private var c0x:Number;
private var c0y:Number;
private var t:Number;
private var c1color:uint;
public function SpinArtVisualization(_arg1:uint, _arg2:uint){
vt = 0;
ray1theta = 0;
ray1thetaTarg = 0;
super(_arg1, _arg2);
c0x = (c0y = (c1x = (c1y = 0)));
c0color = (0xFF | uint((Math.random() * 0xFFFFFF)));
c1color = (0xFF | uint((Math.random() * 0xFFFFFF)));
c3color = (0xFF | uint((Math.random() * 0xFFFFFF)));
t = 0;
leftMargin = ((maxDim - w) / 2);
topMargin = ((maxDim - h) / 2);
theta = (thetaTarg = 1);
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:uint;
var _local4:Matrix;
var _local5:ColorTransform;
var _local6:Point;
pixels.lock();
bufferBmp.lock();
bufferBmp2.lock();
t = (t + _arg1);
if (_arg2.beat){
vt = 0.1;
} else {
vt = (vt * 0.9);
};
t = (t + vt);
vectors.graphics.clear();
vectors.graphics.moveTo(0, h2);
vectors.graphics.lineStyle((_arg2.beat) ? 10 : 5, c3color);
_local3 = 0;
while (_local3 < 128) {
vectors.graphics.lineTo(((w * _local3) / 0xFF), (h2 + ((_arg2.fftLeft[(0xFF - (_local3 * 2))] * h2) * 0.5)));
_local3++;
};
_local3 = 128;
while (_local3 < 0x0100) {
vectors.graphics.lineTo(((w * _local3) / 0xFF), (h2 + ((_arg2.fftRight[((_local3 - 128) * 2)] * h2) * 0.5)));
_local3++;
};
vectors.graphics.lineStyle(0, 0, 0);
c0x = ((leftMargin + ((Math.sin(t) * _arg2.getSubbandEnergy(1, 2)) * w2)) + w2);
c0y = ((topMargin + ((Math.cos(((t * 1.782) + 1.2352)) * _arg2.getSubbandEnergy(1, 2)) * h2)) + h2);
c1x = ((leftMargin + (((Math.sin(((t * 1.01) + 1.23)) * _arg2.getSubbandEnergy(32, 0x0100)) * 4) * w2)) + w2);
c1y = ((topMargin + (((Math.sin(((t * 2.4) + 1.03)) * _arg2.getSubbandEnergy(32, 0x0100)) * 4) * h2)) + h2);
vectors.graphics.beginFill(c0color);
vectors.graphics.drawCircle(c0x, c0y, ((maxDim * 0.4) * _arg2.getSubbandEnergy(0)));
vectors.graphics.endFill();
vectors.graphics.beginFill(c1color);
vectors.graphics.drawCircle(c1x, c1y, ((maxDim * 0.4) * _arg2.getSubbandEnergy(1)));
vectors.graphics.endFill();
_local4 = new Matrix();
_local4.scale((0.99 + vt), (0.99 + vt));
_local5 = new ColorTransform(0.95, 0.95, 0.95);
theta = (theta + ((thetaTarg - theta) * 0.1));
_local4.rotate(theta);
_local6 = new Point((maxDim / 2), (maxDim / 2));
_local6 = _local4.deltaTransformPoint(_local6);
_local4.translate(((maxDim / 2) - _local6.x), ((maxDim / 2) - _local6.y));
bufferBmp2.draw(bufferBmp, _local4);
if (_arg2.beat){
thetaTarg = (((Math.random() * Math.PI) * 2) - Math.PI);
bufferBmp2.fillRect(bufferBmp2.rect, (0xFF | uint((Math.random() * 0xFFFFFF))));
c0color = (4278190080 | uint((Math.random() * 0xFFFFFF)));
c1color = (4278190080 | uint((Math.random() * 0xFFFFFF)));
c3color = (4278190080 | uint((Math.random() * 0xFFFFFF)));
ray1thetaTarg = (((Math.random() * 4) * Math.PI) - (2 * Math.PI));
};
ray1theta = (ray1theta + ((ray1thetaTarg - ray1theta) / 32));
bufferBmp.copyPixels(bufferBmp2, bufferBmp2.rect, new Point());
bufferBmp.draw(vectors);
bufferBmp.applyFilter(bufferBmp, bufferBmp.rect, new Point(), new BlurFilter(4, 4));
_local4 = new Matrix();
_local4.translate((-((maxDim - w)) / 2), (-((maxDim - h)) / 2));
pixels.draw(bufferBmp, _local4);
bufferBmp.unlock();
bufferBmp2.unlock();
pixels.unlock();
}
override public function createGfx(_arg1:uint, _arg2:uint):BitmapData{
w = _arg1;
h = _arg2;
w2 = (w / 2);
h2 = (h / 2);
maxDim = Math.max(w, h);
minDim = Math.min(w, h);
pixels = new BitmapData(w, h);
vectors = new Shape();
vectors.width = w;
vectors.height = h;
point = new Point();
pixels.fillRect(pixels.rect, 4278190080);
bufferBmp = new BitmapData(maxDim, maxDim, true, 4278190080);
bufferBmp2 = new BitmapData(maxDim, maxDim, true, 4278190080);
bufferBmp2.lock();
bufferBmp2.fillRect(bufferBmp2.rect, (0xFF | uint((Math.random() * 0xFFFFFF))));
bufferBmp2.unlock();
return (pixels);
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 26
//TankLogoVisualization (mwelsh.audio.visualizer.visualizations.TankLogoVisualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.events.*;
public class TankLogoVisualization extends Visualization {
private const SNDHISTORYLEN:uint = 20;
private const GACCUMTIME:Number = 0.05;
private var tankXtarg:Number;
private var lineSize:Number;
private var tankVYtarg:Number;
private var tankVX:Number;
private var tankVY:Number;
private var thetaShift2:Number;
private var tankVZ:Number;
private var thetaSpeed:Number;
private var tankBeginTime:Number;// = 4
private var rayShine:Number;
private var max:Array;
private var city:MovieClip;
private var colors:Array;
private var t:Number;
private var col:Number;
private var gfx:Sprite;
private var thetaShift:Number;
private var tankVXtarg:Number;
private var tankRotTarg:Number;
private var tankYtarg:Number;
private var sndSprites:Array;
private var tankX:Number;
private var tankY:Number;
private var tankZ:Number;
private var gAccum:Number;// = 0
private var tankBeats:int;
private var tank:MovieClip;
private var sndHistory:Array;
public function TankLogoVisualization(_arg1:uint, _arg2:uint):void{
tankBeginTime = 4;
gAccum = 0;
super(_arg1, _arg2);
thetaShift = ((Math.random() * 4) * Math.PI);
rayShine = 0;
thetaShift2 = 0;
tankRotTarg = 0;
thetaSpeed = 0;
tankZ = 0;
tankVZ = 0;
loadContent("vis_tank.swf");
lineSize = Math.sqrt(((w2 * w2) + (h * h)));
sndHistory = [];
sndSprites = [];
}
public function setRandomTankPos():void{
tankXtarg = ((Math.random() * 200) + 25);
tankYtarg = ((Math.random() * (SNDHISTORYLEN - 9)) + 4);
tankBeats = ((Math.random() * 5) + 2);
}
override protected function loadingComplete(_arg1:Event):void{
var _local2:Class;
super.loadingComplete(_arg1);
gfx = new Sprite();
_local2 = getLoadedClass("gfx_tank");
tank = new (_local2);
gfx.addChild(tank);
tankX = (tankXtarg = 100);
tankY = (tankYtarg = -40);
tankVX = 0;
tankVY = 0;
setRandomTankPos();
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:uint;
var _local7:Number;
var _local8:Array;
var _local9:Array;
var _local10:Shape;
var _local11:uint;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:Number;
var _local21:Number;
var _local22:Boolean;
var _local23:Matrix;
var _local24:Number;
pixels.lock();
pixels.fillRect(pixels.rect, 4294948099);
_local7 = 0;
_local8 = [];
if (tankBeginTime){
tankBeginTime = (tankBeginTime - (1 / 40));
if (tankBeginTime <= 0){
tank.alpha = 1;
tankBeginTime = 0;
};
};
_local9 = _arg2.generateSmoothedData(3, true);
_local8[0] = _local9[0xFF];
_local3 = 1;
while (_local3 < 128) {
_local8[_local3] = (_local8[(_local3 - 1)] + ((_local9[(0xFF - (_local3 * 2))] - _local8[(_local3 - 1)]) / 4));
_local3++;
};
_local3 = 128;
while (_local3 < 0x0100) {
_local8[_local3] = (_local8[(_local3 - 1)] + ((_local9[((_local3 - 128) * 2)] - _local8[(_local3 - 1)]) / 4));
_local3++;
};
gAccum = (gAccum + _arg1);
while (gAccum >= GACCUMTIME) {
sndHistory.unshift(_local8);
if (sndHistory.length > SNDHISTORYLEN){
sndHistory.pop();
};
_local10 = new Shape();
sndSprites.unshift(_local10);
if (sndSprites.length > SNDHISTORYLEN){
sndSprites.pop();
};
_local10.graphics.moveTo(0, (h - 1.05));
_local10.graphics.beginFill(0xFFFFFF);
_local6 = 0;
while (_local6 < 0x0100) {
_local10.graphics.lineTo((((_local6 / 0xFF) * w) * 1.5), ((h - ((sndHistory[0][_local6] * h2) * 0.5)) - ((Math.sin(((_local6 * Math.PI) / 0xFF)) * h2) * 0.15)));
_local6 = (_local6 + 2);
};
_local10.graphics.lineTo((w * 1.5), (h * 1.05));
_local10.graphics.lineTo(0, (h * 1.05));
_local10.graphics.endFill();
gAccum = (gAccum - GACCUMTIME);
};
vectors.graphics.clear();
vectors.graphics.lineStyle(0, 0, 0);
if (_arg2.beat){
rayShine = 1;
thetaSpeed = 1;
tankBeats--;
if (tankBeats < 0){
setRandomTankPos();
};
} else {
rayShine = (rayShine * 0.9);
thetaSpeed = (thetaSpeed * 0.7);
};
tankVXtarg = ((tankXtarg - tankX) / 16);
tankVYtarg = ((tankYtarg - tankY) / 16);
tankVX = (tankVX + ((tankVXtarg - tankVX) / 16));
tankVY = (tankVY + ((tankVYtarg - tankVY) / 16));
tankX = (tankX + (tankVX / 4));
tankY = (tankY + (tankVY / 4));
thetaShift = (thetaShift + ((1 + (thetaSpeed * 2)) * _arg1));
_local11 = ((0xFF0000 | (uint((197 + ((241 - 197) * rayShine))) << 8)) | uint((19 + ((122 - 19) * rayShine))));
vectors.graphics.moveTo(w2, h);
_local3 = 0;
_local4 = thetaShift;
_local5 = (thetaShift + ((2 * Math.PI) / 32));
while (_local3 < 64) {
vectors.graphics.beginFill(_local11);
vectors.graphics.lineTo((w2 + ((Math.cos(_local4) * maxDim) * 2)), (h + ((Math.sin(_local4) * maxDim) * 2)));
vectors.graphics.lineTo((w2 + ((Math.cos(_local5) * maxDim) * 2)), (h + ((Math.sin(_local5) * maxDim) * 2)));
vectors.graphics.lineTo(w2, h);
vectors.graphics.endFill();
_local3++;
_local4 = (_local4 + ((4 * Math.PI) / 32));
_local5 = (_local5 + ((4 * Math.PI) / 32));
};
vectors.graphics.moveTo(w2, h);
vectors.graphics.lineStyle(15, 0xFF8800, 0.4);
_local12 = Math.cos((thetaShift * 1.5));
_local13 = Math.sin((thetaShift * 1.5));
_local3 = 0;
while (_local3 < 0x0100) {
vectors.graphics.lineTo(((w2 + (((_local3 / 0xFF) * _local12) * lineSize)) + (((_arg2.rawAvg[_local3] * _local13) * maxDim) * 0.1)), ((h + (((_local3 / 0xFF) * _local13) * lineSize)) + (((_arg2.rawAvg[_local3] * _local12) * maxDim) * 0.1)));
_local3 = (_local3 + 4);
};
_local12 = Math.cos(((thetaShift * 1.3) + Math.PI));
_local13 = Math.sin(((thetaShift * 1.3) + Math.PI));
_local3 = 0;
while (_local3 < 0x0100) {
vectors.graphics.lineTo(((w2 + (((_local3 / 0xFF) * _local12) * lineSize)) + (((_arg2.rawAvg[_local3] * _local13) * maxDim) * 0.1)), ((h + (((_local3 / 0xFF) * _local13) * lineSize)) + (((_arg2.rawAvg[_local3] * _local12) * maxDim) * 0.1)));
_local3 = (_local3 + 4);
};
_local12 = Math.cos(((thetaShift * 2) + 1.123214));
_local13 = Math.sin(((thetaShift * 2) + 1.123214));
_local3 = 0;
while (_local3 < 0x0100) {
vectors.graphics.lineTo(((w2 + (((_local3 / 0xFF) * _local12) * lineSize)) + (((_arg2.rawAvg[_local3] * _local13) * maxDim) * 0.1)), ((h + (((_local3 / 0xFF) * _local13) * lineSize)) + (((_arg2.rawAvg[_local3] * _local12) * maxDim) * 0.1)));
_local3 = (_local3 + 4);
};
pixels.draw(vectors);
vectors.graphics.lineStyle(0, 0, 0);
tank.scaleX = (tank.scaleY = (0.4 - (tankY * 0.01)));
_local16 = 0;
_local17 = 0;
tank.x = ((((tankX / 0xFF) * w) * 1.5) - ((tankY * w) * 0.02));
tank.y = ((h - ((h * 0.015) * tankY)) - ((Math.sin(((tankX * Math.PI) / 0xFF)) * h2) * 0.15));
_local18 = tankY;
_local19 = tankX;
_local20 = 0;
if ((((_local18 >= 0)) && ((_local18 < (sndHistory.length - 1))))){
if ((((_local19 >= 0)) && ((_local19 < 0x0100)))){
_local20 = (((sndHistory[_local18][_local19] * h2) * 0.25) + ((sndHistory[(_local18 + 1)][_local19] * h2) * 0.25));
if ((_local19 - 5) >= 0){
_local16 = ((sndHistory[_local18][(_local19 - 5)] * h2) * 0.25);
};
if ((_local19 + 5) < 0x0100){
_local17 = ((sndHistory[_local18][(_local19 + 5)] * h2) * 0.25);
};
};
};
if (_local20 < tankZ){
tankVZ = (tankVZ + -0.2);
tankZ = (tankZ + tankVZ);
};
if (tankZ <= _local20){
tankZ = _local20;
tankVZ = 0;
};
tank.y = (tank.y - tankZ);
tankRotTarg = ((-8 + ((16 * tankX) / 0xFF)) - ((_local17 - _local16) * 4));
tank.rotation = (tank.rotation + ((tankRotTarg - tank.rotation) / 5));
_local21 = 1;
_local22 = true;
_local23 = new Matrix();
_local3 = (sndHistory.length - 1);
while (_local3 >= 0) {
_local24 = (gAccum / GACCUMTIME);
_local14 = ((1 - ((_local3 + _local24) / (SNDHISTORYLEN - 1))) / 3);
if (_local3 > (sndHistory.length - 5)){
_local21 = (((sndHistory.length - 1) - (_local3 + _local24)) / 4);
} else {
_local21 = 1;
};
_local23.identity();
_local23.translate(((-((_local3 + _local24)) * w) * 0.02), ((-(h) * 0.015) * (_local3 + _local24)));
pixels.draw(sndSprites[_local3], _local23, new ColorTransform(_local14, _local14, _local14, _local21));
if (((_local22) && ((_local3 <= tankY)))){
_local22 = false;
pixels.draw(gfx);
};
_local3--;
};
if (_local22){
pixels.draw(gfx);
};
pixels.unlock();
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 27
//ThreeDeeVisualization (mwelsh.audio.visualizer.visualizations.ThreeDeeVisualization)
package mwelsh.audio.visualizer.visualizations {
import mwelsh.audio.visualizer.*;
import mwelsh.thunder3d.geom3d.*;
import mwelsh.thunder3d.*;
public class ThreeDeeVisualization extends Visualization {
protected var r:Renderer;
protected var rType:Class;
protected var objects:Array;
public function ThreeDeeVisualization(_arg1:uint, _arg2:uint, _arg3:Renderer):void{
super(_arg1, _arg2);
objects = [];
r = _arg3;
}
override public function tick(_arg1:Number, _arg2:SoundData):void{
tickObjects(_arg1);
r.clearScreen(pixels);
r.drawObj(objects);
r.render(pixels);
}
protected function tickObjects(_arg1:Number):void{
var _local2:uint;
var _local3:Object3D;
var _local4:uint;
_local2 = objects.length;
_local4 = 0;
while (_local4 < _local2) {
_local3 = objects[_local4];
_local3.tick(_arg1);
_local4++;
};
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 28
//Visualization (mwelsh.audio.visualizer.visualizations.Visualization)
package mwelsh.audio.visualizer.visualizations {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.geom.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class Visualization {
protected var maxDim:uint;
protected var h2:Number;
protected var vectors:Shape;
protected var loader:Loader;
protected var minDim:uint;
protected var orientation:Boolean;
protected var w2:Number;
protected var point:Point;
protected var _loaded:Boolean;
protected var bufferBmp:BitmapData;
protected var h:uint;
protected var pixels:BitmapData;
protected var bufferBmp2:BitmapData;
protected var w:uint;
public function Visualization(_arg1:uint, _arg2:uint):void{
_loaded = true;
createGfx(_arg1, _arg2);
}
public function get loaded():Boolean{
return (_loaded);
}
protected function catchIOError(_arg1:Event):void{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadingComplete);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, catchIOError);
}
protected function loadingComplete(_arg1:Event):void{
loader.removeEventListener(Event.COMPLETE, loadingComplete);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, catchIOError);
_loaded = true;
}
protected function applyPolarTransform(_arg1:Function, _arg2:Function):void{
var _local3:uint;
var _local4:uint;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local3 = 0;
while (_local3 < w) {
_local4 = 0;
while (_local4 < w) {
_local4++;
};
_local3++;
};
}
public function createGfx(_arg1:uint, _arg2:uint):BitmapData{
w = _arg1;
h = _arg2;
w2 = (w / 2);
h2 = (h / 2);
maxDim = Math.max(w, h);
minDim = Math.min(w, h);
orientation = (h > w);
pixels = new BitmapData(w, h, false);
vectors = new Shape();
vectors.width = w;
vectors.height = h;
point = new Point();
pixels.fillRect(pixels.rect, 4278190080);
bufferBmp = new BitmapData(_arg1, _arg2, true);
bufferBmp2 = new BitmapData(_arg1, _arg2, true);
return (pixels);
}
protected function drawBuffer(_arg1:Matrix=null, _arg2:ColorTransform=null, _arg3:String=null, _arg4:BitmapData=null):void{
var _local5:Point;
if (_arg4 == null){
_arg4 = bufferBmp;
};
_local5 = new Point(w2, h2);
if (!_arg1){
_arg1 = new Matrix();
};
_local5 = _arg1.deltaTransformPoint(_local5);
_arg1.translate((w2 - _local5.x), (h2 - _local5.y));
pixels.draw(_arg4, _arg1, _arg2, _arg3);
}
public function tick(_arg1:Number, _arg2:SoundData):void{
pixels.lock();
pixels.fillRect(pixels.rect, 4278190080);
pixels.unlock();
}
public function get bitmapData():BitmapData{
return (pixels);
}
protected function loadContent(_arg1:String):void{
var _local2:URLRequest;
var _local3:LoaderContext;
_loaded = false;
_local2 = new URLRequest((AudioVisualizer.VIS_DATA_FOLDER + _arg1));
loader = new Loader();
_local3 = new LoaderContext(false, ApplicationDomain.currentDomain);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, catchIOError);
loader.load(_local2, _local3);
}
protected function getLoadedClass(_arg1:String):Class{
return (Class(loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)));
}
protected function saveBuffer(_arg1:Matrix=null, _arg2:ColorTransform=null, _arg3:String=null, _arg4:BitmapData=null):void{
var _local5:Point;
if (_arg4 == null){
_arg4 = bufferBmp;
};
if (!_arg1){
_arg1 = new Matrix();
};
_local5 = new Point(w2, h2);
_local5 = _arg1.deltaTransformPoint(_local5);
_arg1.translate((w2 - _local5.x), (h2 - _local5.y));
_arg4.draw(pixels, _arg1, _arg2, _arg3);
}
}
}//package mwelsh.audio.visualizer.visualizations
Section 29
//AudioVisualizer (mwelsh.audio.visualizer.AudioVisualizer)
package mwelsh.audio.visualizer {
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import mwelsh.audio.visualizer.visualizations.*;
import flash.utils.*;
public class AudioVisualizer extends Sprite {
private const BEAT_CONSTANT:Number = 3.1;
private const TRANSITION_SCROLL0:uint = 1;
private const TRANSITION_DISSOLVE:uint = 3;
private const TRANSITION_SCROLL3:uint = 4;
private const TRANSITION_SCROLL1:uint = 2;
private const MIN_BPM:uint = 60;
private const MAX_BPM:uint = 200;
private const NUM_TRANSITIONS:uint = 7;
private const BEAT_HISTORY_LEN:uint = 16;
private const TRANSITION_SPINOUT:uint = 6;
private const TRANSITION_FADE:uint = 0;
private const BPM_HISTORY_LEN:uint = 8;
private const VIS_FADE_TIME:uint = 1000;
private const TRANSITION_COLUMNWIPE:uint = 5;
private const TRANSITION_NONE:uint = 999;
private const MIN_BEAT_TIME:Number = 0.2;
private const TRANSITION_SQUARES:uint = 7;
private var _lastPredictedBeatTime:Number;
private var _visNumber:int;
private var _beatTypeHistory:Array;
private var _confidence:Number;
private var _beatPeak1Peak:Number;
private var _lastBeatTime:Number;
private var _beatDiscriminatedHistory:Array;
private var _transitionType:uint;
private var _beatsGuessed:uint;
private var h:uint;
private var _visPlaylist:Array;
private var w:uint;
private var _bpmDoubleCount:uint;
private var _stickyConfidenceCount:uint;
private var _beat:Boolean;
private var _resyncBpm:Boolean;
private var _predictedTimeUntilBeat:Number;
private var _averageBeatTime:Number;
private var _buffer0:BitmapData;
private var _buffer1:BitmapData;
private var _predictionBpm:uint;
private var _transitionSprite:Sprite;
private var _vis0:Visualization;
private var _vis1:Visualization;
private var _bpm:uint;
private var _bpmSticky:Boolean;
private var _topConfidenceCount:uint;
private var _beatTimeHistory:Array;
private var _transitionBitmap:BitmapData;
private var _BDTime:Number;
private var _bpmHistory:Array;
private var _bpmHalfCount:uint;
private var _beatDetection:Boolean;
private var _fullScreen:Boolean;
private var _visTransitionTime:uint;
private var _screen:BitmapData;
private var _beatPeak1:Number;
private var _beatPeak2:Number;
private var _time:int;
private var _bestConfidence:Number;
public var dbgSoundData:DebugSoundData;
private var _lastBeatHistoryTime:Number;
private var _visTime:int;
private var _soundData:SoundData;
private var _transitionTime:int;
public static const DEBUG_SONG:int = -1;
public static const VIS_DATA_FOLDER:String = "http://flash.ngfiles.com/";
public static const DEBUG_SONGS:Array = [];
public static const DEBUG:Boolean = false;
public static const VIS_CHANGED:String = "visChanged";
public static const VERSION:String = "1.1";
public function AudioVisualizer(_arg1:uint, _arg2:uint, _arg3:Array, _arg4=undefined):void{
addEventListener("enterFrame", visualizerTick);
_transitionTime = (_visTime = 0);
_lastBeatTime = 0;
_visPlaylist = _arg3;
this.w = _arg1;
this.h = _arg2;
_transitionBitmap = new BitmapData(_arg1, _arg2);
_transitionSprite = new Sprite();
createVis(_arg1, _arg2, _arg4);
_time = getTimer();
_BDTime = 0;
_visTransitionTime = 0;
_beatPeak1 = (_beatPeak1Peak = (_beatPeak2 = 0));
_fullScreen = false;
}
public function getBeat():Boolean{
return (_beat);
}
public function nextVis():void{
_visNumber = ((_visNumber + 1) % _visPlaylist.length);
changeVis(_visPlaylist[_visNumber]);
}
public function addedHandler(_arg1:Event):void{
}
public function set visualization(_arg1:String):void{
var _local2:uint;
_visNumber = -1;
_local2 = 0;
while (_local2 < _visPlaylist.length) {
if (_visPlaylist[_local2] == _arg1){
_visNumber = _local2;
};
_local2++;
};
changeVis(_arg1);
}
private function changeVis(_arg1:String, _arg2:uint=999):void{
var _local3:Class;
_local3 = (getDefinitionByName(("mwelsh.audio.visualizer.visualizations." + _arg1)) as Class);
_vis1 = new _local3(w, h);
_buffer1 = _vis1.bitmapData;
_transitionType = _arg2;
_visTime = 0;
dispatchEvent(new Event(VIS_CHANGED));
}
public function resetBeatDetection():void{
_beatDetection = true;
initSmartBeatDetection();
}
private function doubleBpm():void{
var _local1:uint;
var _local2:Array;
if (((_bpmSticky) && ((_bpm > MIN_BPM)))){
return;
};
trace("DOUBLE");
_local2 = [];
_local1 = 0;
while (_local1 < (BEAT_HISTORY_LEN - 1)) {
_local2[_local1] = (_beatTimeHistory[_local1] - _beatTimeHistory[(_local1 + 1)]);
_local1++;
};
_local1 = 1;
while (_local1 < BEAT_HISTORY_LEN) {
_beatTimeHistory[_local1] = (_beatTimeHistory[(_local1 - 1)] - (_local2[(_local1 - 1)] / 2));
_local1++;
};
_averageBeatTime = (_averageBeatTime / 2);
_bpm = (_bpm * 2);
_bpmDoubleCount = 0;
_bpmHistory = [];
_beatDiscriminatedHistory = [];
}
public function cleanup():void{
_vis0 = null;
_vis1 = null;
_buffer0 = (_buffer1 = (_screen = null));
removeEventListener("enterFrame", visualizerTick);
removeChildAt(0);
}
private function halfBpm():void{
var _local1:uint;
var _local2:Array;
if (((_bpmSticky) && ((_bpm < MAX_BPM)))){
return;
};
trace("HALF");
_local2 = [];
_local1 = 0;
while (_local1 < (BEAT_HISTORY_LEN - 1)) {
_local2[_local1] = (_beatTimeHistory[_local1] - _beatTimeHistory[(_local1 + 1)]);
_local1++;
};
_local1 = 1;
while (_local1 < BEAT_HISTORY_LEN) {
_beatTimeHistory[_local1] = (_beatTimeHistory[(_local1 - 1)] - (_local2[(_local1 - 1)] * 2));
_local1++;
};
_averageBeatTime = (_averageBeatTime * 2);
_bpm = (_bpm / 2);
_bpmHalfCount = 0;
_bpmHistory = [];
_beatDiscriminatedHistory = [];
}
public function getSoundData():SoundData{
return (_soundData);
}
public function getBPM():Number{
return (0);
}
public function prevVis():void{
_visNumber = ((_visNumber - 1) % _visPlaylist.length);
changeVis(_visPlaylist[_visNumber]);
}
private function fullScreenHandler(_arg1:Event):void{
}
public function pauseBeatDetection():void{
_beatDetection = false;
}
public function get visualization():String{
if (_visNumber < 0){
return (null);
};
return (_visPlaylist[_visNumber]);
}
private function initSmartBeatDetection():void{
_bpm = 0;
_bpmHistory = [];
_beatTimeHistory = [];
_beatDiscriminatedHistory = [];
_beatTypeHistory = [];
_lastPredictedBeatTime = 0;
_lastBeatHistoryTime = 0;
_bpmSticky = false;
_confidence = (_bestConfidence = 0);
_averageBeatTime = 0;
_topConfidenceCount = 0;
_predictionBpm = 0;
_beatsGuessed = 0;
_bpmHalfCount = (_bpmDoubleCount = 0);
_stickyConfidenceCount = 0;
_resyncBpm = false;
_predictedTimeUntilBeat = 0;
}
private function calcBpm():void{
var _local1:int;
var _local2:Number;
var _local3:uint;
var _local4:uint;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local8 = 0;
_local10 = 0;
if (_beatTimeHistory.length != BEAT_HISTORY_LEN){
return;
};
_local1 = 0;
while (_local1 < (BEAT_HISTORY_LEN - 1)) {
_local9 = (_beatTimeHistory[_local1] - _beatTimeHistory[(_local1 + 1)]);
_local2 = (_local2 + _local9);
_local10 = Math.max(_local9, _local10);
_local8 = (_local8 + (_local9 * _local9));
_local1++;
};
_averageBeatTime = (_local2 / (BEAT_HISTORY_LEN - 1));
_local1 = 0;
while (_local1 < BEAT_HISTORY_LEN) {
if (_beatTypeHistory[_local1]){
_local3++;
};
_local1++;
};
_local5 = Math.min(((2 * _local3) / BEAT_HISTORY_LEN), 1);
_local6 = Math.sqrt(((_local8 / (BEAT_HISTORY_LEN - 1)) - (_averageBeatTime * _averageBeatTime)));
_local7 = (1 - (_local6 / _local10));
_confidence = Math.max(0, (((2 * _local5) * _local7) - 1));
_local2 = 0;
_local9 = 0;
_local1 = 0;
while (_local1 < (BEAT_HISTORY_LEN - 1)) {
_local9 = (_local9 + (_beatTimeHistory[_local1] - _beatTimeHistory[(_local1 + 1)]));
if (Math.abs((_averageBeatTime - _local9)) < _local6){
_local2 = (_local2 + _local9);
_local4++;
_local9 = 0;
} else {
if (_local9 > _averageBeatTime){
_local9 = 0;
};
};
_local1++;
};
if (_local4){
_averageBeatTime = (_local2 / _local4);
};
if (_beatsGuessed >= (BEAT_HISTORY_LEN + 2)){
_local11 = _bpm;
if (_averageBeatTime){
_local11 = (60 / _averageBeatTime);
};
if (((!(_bpmHistory.length)) || (!((_local11 == _bpmHistory[0]))))){
_bpmHistory.unshift(_local11);
if (_bpmHistory.length > BPM_HISTORY_LEN){
_bpmHistory.pop();
};
};
if (((_predictionBpm) && ((_confidence >= 0.85)))){
_stickyConfidenceCount++;
if (_stickyConfidenceCount == 8){
_bpmSticky = true;
trace("STICKED");
trace(_predictionBpm);
};
} else {
_stickyConfidenceCount = 0;
};
};
_bpm = 0;
_local1 = 0;
while (_local1 < _bpmHistory.length) {
_bpm = (_bpm + _bpmHistory[_local1]);
_local1++;
};
_bpm = (_bpm / _bpmHistory.length);
_local4 = 0;
_local1 = 0;
while (_local1 < BEAT_HISTORY_LEN) {
if (_beatDiscriminatedHistory[_local1]){
_local4++;
};
_local1++;
};
if (_bpmHistory.length){
if ((((_local4 >= (BEAT_HISTORY_LEN / 2))) && (((_bpm * 2) <= MAX_BPM)))){
doubleBpm();
_beatDiscriminatedHistory = [];
};
if (_bpm < MIN_BPM){
_bpmDoubleCount++;
if (_bpmDoubleCount > 4){
doubleBpm();
};
} else {
_bpmDoubleCount = 0;
};
if (_bpm > MAX_BPM){
_bpmHalfCount++;
if (_bpmHalfCount > 4){
halfBpm();
};
} else {
_bpmHalfCount = 0;
};
};
}
public function getBitmapData():BitmapData{
return (_screen);
}
public function unpauseBeatDetection():void{
_beatDetection = true;
}
public function set fullscreen(_arg1:Boolean):void{
_fullScreen = _arg1;
if (stage){
if (_fullScreen){
};
};
}
private function visualizerTick(_arg1:Event):void{
var _local2:uint;
var _local3:Number;
var _local4:Matrix;
var _local5:Number;
var _local6:Number;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:Visualization;
_local2 = (getTimer() - _time);
_local3 = (_local2 / 1000);
_time = (_time + _local2);
_BDTime = (_BDTime + _local3);
if (!_vis0){
return;
};
_soundData = new SoundData(_beat, 0);
_beat = false;
if (_beatDetection){
_beat = beatDetect(_soundData, _local2);
_soundData.beat = _beat;
_beat = refineBeat(_beat);
if (_beat){
_predictedTimeUntilBeat = (60 / _predictionBpm);
} else {
_predictedTimeUntilBeat = (_predictedTimeUntilBeat - _local3);
if (_predictedTimeUntilBeat < 0){
_predictedTimeUntilBeat = (_predictedTimeUntilBeat + (60 / _predictionBpm));
};
};
};
_soundData.bpm = _predictionBpm;
_soundData.smartBeat = _beat;
_soundData.predictedTimeUntilBeat = _predictedTimeUntilBeat;
if (_vis1 == null){
_visTime = (_visTime + _local2);
if (((((((((_visTransitionTime) && ((_visTime >= _visTransitionTime)))) && ((_visNumber >= 0)))) && ((_visNumber < _visPlaylist.length)))) && ((_visPlaylist.length > 1)))){
_visNumber = ((_visNumber + 1) % _visPlaylist.length);
_visTime = 0;
changeVis(_visPlaylist[_visNumber], uint((Math.random() * NUM_TRANSITIONS)));
};
};
if (_vis0.loaded){
_vis0.tick(_local3, _soundData);
};
_screen.lock();
_screen.copyPixels(_buffer0, new Rectangle(0, 0, width, height), new Point());
if (((_vis1) && (_vis1.loaded))){
_transitionTime = (_transitionTime + _local2);
_vis1.tick(_local3, _soundData);
switch (_transitionType){
case TRANSITION_FADE:
_screen.draw(_buffer1, null, new ColorTransform(1, 1, 1, (_transitionTime / VIS_FADE_TIME)));
break;
case TRANSITION_SCROLL0:
_local4 = new Matrix();
_local4.createGradientBox(w, h, 0, ((((_transitionTime / VIS_FADE_TIME) * w) * 1.5) - ((1.5 * w) / 2)));
_transitionSprite.graphics.clear();
_transitionSprite.graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF, 0xFFFFFF], [1, 0], [100, 155], _local4);
_transitionSprite.graphics.lineTo(w, 0);
_transitionSprite.graphics.lineTo(w, h);
_transitionSprite.graphics.lineTo(0, h);
_transitionSprite.graphics.lineTo(0, 0);
_transitionSprite.graphics.endFill();
_transitionBitmap.fillRect(_transitionBitmap.rect, 0);
_transitionBitmap.draw(_transitionSprite);
_screen.copyPixels(_buffer1, _buffer1.rect, new Point(), _transitionBitmap, new Point(), true);
break;
case TRANSITION_SCROLL1:
_local4 = new Matrix();
_local4.createGradientBox(w, h, 0, (((w * 1.5) / 2) - (((_transitionTime / VIS_FADE_TIME) * w) * 1.5)));
_transitionSprite.graphics.clear();
_transitionSprite.graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF, 0xFFFFFF], [0, 1], [100, 155], _local4);
_transitionSprite.graphics.lineTo(w, 0);
_transitionSprite.graphics.lineTo(w, h);
_transitionSprite.graphics.lineTo(0, h);
_transitionSprite.graphics.lineTo(0, 0);
_transitionSprite.graphics.endFill();
_transitionBitmap.fillRect(_transitionBitmap.rect, 0);
_transitionBitmap.draw(_transitionSprite);
_screen.copyPixels(_buffer1, _buffer1.rect, new Point(), _transitionBitmap, new Point(), true);
break;
case TRANSITION_SCROLL3:
_screen.copyPixels(_buffer1, new Rectangle(Math.round((w * (1 - (_transitionTime / VIS_FADE_TIME)))), 0, Math.round(((w * _transitionTime) / VIS_FADE_TIME)), h), new Point(Math.round((w * (1 - (_transitionTime / VIS_FADE_TIME)))), 0));
break;
case TRANSITION_DISSOLVE:
_local5 = 10;
_local9 = 0;
while (_local9 < ((60 * _transitionTime) / VIS_FADE_TIME)) {
_local5 = _screen.pixelDissolve(_buffer1, _buffer1.rect, new Point(), _local5, uint(((w * h) / 60)));
_local9++;
};
break;
case TRANSITION_COLUMNWIPE:
_local9 = 0;
while (_local9 < 10) {
_screen.copyPixels(_buffer1, new Rectangle(Math.round(((_local9 * w) / 10)), 0, (w / 10), (h * Math.min(((2 * _transitionTime) / VIS_FADE_TIME)))), new Point(Math.round(((_local9 * w) / 10)), 0));
_local9 = (_local9 + 2);
};
if ((_transitionTime / VIS_FADE_TIME) > 0.5){
_local9 = 1;
while (_local9 < 10) {
_screen.copyPixels(_buffer1, new Rectangle(Math.round(((_local9 * w) / 10)), Math.round((h - ((h * 2) * ((_transitionTime / VIS_FADE_TIME) - 0.5)))), (w / 10), Math.round(((h * 2) * ((_transitionTime / VIS_FADE_TIME) - 0.5)))), new Point(Math.round(((_local9 * w) / 10)), Math.round((h - ((h * 2) * ((_transitionTime / VIS_FADE_TIME) - 0.5))))));
_local9 = (_local9 + 2);
};
};
break;
case TRANSITION_SQUARES:
_local6 = 0;
_local7 = 0;
_local8 = 0;
while (_local6 < (_transitionTime / VIS_FADE_TIME)) {
_screen.copyPixels(_buffer1, new Rectangle(((_local7 * w) / 10), ((_local8 * h) / 10), (w / 10), (h / 10)), new Point(((_local7 * w) / 10), ((_local8 * h) / 10)));
++_local7;
if (_local7 == 10){
_local7 = 0;
_local8++;
};
_local6 = (_local6 + (1 / 100));
};
break;
case TRANSITION_SPINOUT:
_local4 = new Matrix();
_local4.translate((w - ((w * _transitionTime) / VIS_FADE_TIME)), (h - ((h * _transitionTime) / VIS_FADE_TIME)));
_local4.scale((_transitionTime / VIS_FADE_TIME), (_transitionTime / VIS_FADE_TIME));
_screen.draw(_buffer1, _local4);
break;
default:
_transitionTime = VIS_FADE_TIME;
};
if (_transitionTime >= VIS_FADE_TIME){
_local10 = null;
_buffer0 = _buffer1;
_buffer1 = null;
_vis0 = _vis1;
_vis1 = null;
_transitionTime = 0;
};
};
_screen.unlock();
}
public function set transitionTime(_arg1:uint):void{
_visTransitionTime = (_arg1 * 1000);
}
private function createVis(_arg1:uint, _arg2:uint, _arg3:String):void{
var _local4:Class;
var _local5:uint;
if (_screen){
removeChildAt(0);
};
if ((((_arg3 == "")) || ((_arg3 == null)))){
_visNumber = uint((_visPlaylist.length * Math.random()));
} else {
_local5 = 0;
while (_local5 < _visPlaylist.length) {
if (_visPlaylist[_local5] == _arg3){
_visNumber = _local5;
};
_local5++;
};
};
_local4 = (getDefinitionByName(("mwelsh.audio.visualizer.visualizations." + _visPlaylist[_visNumber])) as Class);
_vis0 = new _local4(_arg1, _arg2);
_buffer0 = _vis0.bitmapData;
_screen = new BitmapData(_arg1, _arg2);
addChild(new Bitmap(_screen));
}
public function get fullscreen():Boolean{
return (_fullScreen);
}
private function refineBeat(_arg1:Boolean):Boolean{
var _local2:Boolean;
var _local3:Boolean;
var _local4:Boolean;
var _local5:Boolean;
var _local6:Boolean;
var _local7:uint;
var _local8:Number;
var _local9:Number;
var _local10:uint;
_local2 = false;
_local3 = false;
_local4 = false;
_local5 = false;
_local6 = false;
if (((_bpm) && ((_BDTime >= (_lastPredictedBeatTime + (60 / _bpm)))))){
_local3 = true;
};
if (_arg1){
_local2 = BeatHistoryStep(true);
};
calcBpm();
if (((((((_local2) || (_local3))) && (!(_bpmSticky)))) && (((((!(_predictionBpm)) || ((_predictionBpm > MAX_BPM)))) || ((_predictionBpm < MIN_BPM)))))){
_local6 = (_confidence >= _bestConfidence);
};
if (_confidence >= 0.5){
_topConfidenceCount++;
if (_topConfidenceCount == 8){
_local6 = true;
_topConfidenceCount = 0;
};
};
if (_local6){
_local6 = false;
_bestConfidence = _confidence;
_predictionBpm = _bpm;
};
if (!_bpmSticky){
_predictionBpm = _bpm;
};
_bpm = _predictionBpm;
if (((((_predictionBpm) && (_local2))) && (!(_local3)))){
if (_BDTime > (_lastPredictedBeatTime + ((60 / _predictionBpm) * 0.7))){
_local4 = true;
_local8 = (_predictionBpm * 1.01);
};
if (_BDTime < (_lastPredictedBeatTime + ((60 / _predictionBpm) * 0.3))){
_local5 = true;
_local8 = (_predictionBpm * 0.98);
};
if (((((!(_bpmSticky)) && (_resyncBpm))) && (((_local4) || (_local5))))){
_bpmHistory.unshift(_local8);
_local9 = 0;
_local10 = 0;
while (_local10 < BPM_HISTORY_LEN) {
_local9 = (_local9 + _bpmHistory[_local10]);
_local10++;
};
_local9 = (_local9 / BPM_HISTORY_LEN);
_predictionBpm = _local9;
};
};
if (_local4){
_lastPredictedBeatTime = _BDTime;
_resyncBpm = true;
return (true);
};
if (_local3){
_lastPredictedBeatTime = _BDTime;
if (_confidence > 0.25){
BeatHistoryStep(false);
};
_resyncBpm = false;
return (true);
} else {
if (_local5){
_lastPredictedBeatTime = _BDTime;
_resyncBpm = true;
return (false);
};
};
return (_arg1);
}
public function get transitionTime():uint{
return ((_visTransitionTime / 1000));
}
private function BeatHistoryStep(_arg1:Boolean):Boolean{
var _local2:int;
var _local3:int;
var _local4:Number;
_local4 = (_BDTime - _lastBeatHistoryTime);
if (_local4 < ((3 * _averageBeatTime) / 10)){
if (_beatTimeHistory.length == BEAT_HISTORY_LEN){
if (Math.abs((_averageBeatTime - (_BDTime - _beatTimeHistory[1]))) < Math.abs((_averageBeatTime - (_beatTimeHistory[0] - _beatTimeHistory[1])))){
_beatTimeHistory[0] = _BDTime;
_beatTypeHistory[0] = _arg1;
return (true);
};
};
return (false);
};
if (_beatTimeHistory.length == BEAT_HISTORY_LEN){
_local3 = 2;
while (_local3 < 8) {
if (Math.abs(((_averageBeatTime / _local3) - _local4)) < ((_averageBeatTime / _local3) * 0.2)){
_beatDiscriminatedHistory.unshift(true);
if (_beatDiscriminatedHistory.length > BEAT_HISTORY_LEN){
_beatDiscriminatedHistory.pop();
};
return (false);
};
_local3++;
};
};
_beatDiscriminatedHistory.unshift(false);
if (_beatDiscriminatedHistory.length > BEAT_HISTORY_LEN){
_beatDiscriminatedHistory.pop();
};
_lastBeatHistoryTime = _BDTime;
_beatTimeHistory.unshift(_BDTime);
_beatTypeHistory.unshift(_arg1);
_beatsGuessed++;
if (_beatTimeHistory.length > BEAT_HISTORY_LEN){
_beatTimeHistory.pop();
_beatTypeHistory.pop();
};
return (true);
}
protected function beatDetect(_arg1:SoundData, _arg2:uint):Boolean{
var _local3:Number;
var _local4:Boolean;
_local3 = _arg1.energy;
_local4 = false;
_beatPeak1 = (((_beatPeak1 * 121) + (_beatPeak2 * 7)) / 128);
if ((((_local3 >= (_beatPeak1 * 1.0425))) && ((_local3 > (0x0100 * 16))))){
_beatPeak1 = ((_local3 + _beatPeak1Peak) / 2);
_beatPeak1Peak = (_beatPeak1 * 1);
_local4 = true;
} else {
if (_local3 > _beatPeak2){
_beatPeak2 = _local3;
} else {
_beatPeak2 = (_beatPeak2 * 0.86);
};
};
if (_local4){
if ((_BDTime - _lastBeatTime) < MIN_BEAT_TIME){
_local4 = false;
} else {
_lastBeatTime = _BDTime;
};
};
return (_local4);
}
}
}//package mwelsh.audio.visualizer
Section 30
//DebugSoundData (mwelsh.audio.visualizer.DebugSoundData)
package mwelsh.audio.visualizer {
public class DebugSoundData extends SoundData {
public var numSubbands:uint;
public var avgEnergy:Array;
public var numEnergies:uint;
public var subbandStep:Number;
public var beatVarianceThreshold:Number;
public var curEnergy:Array;
public var subbandStepRate:Number;
public var varEnergy:Array;
public var fftAvgEnergy:Number;
public var beatConstant:Number;
public function DebugSoundData(_arg1:Boolean, _arg2:Number){
super(_arg1, _arg2);
}
}
}//package mwelsh.audio.visualizer
Section 31
//SoundData (mwelsh.audio.visualizer.SoundData)
package mwelsh.audio.visualizer {
import flash.utils.*;
import mwelsh.audio.*;
import flash.media.*;
public class SoundData {
private var _rightEnergy:Number;
private var m_PredictedTimeUntilBeat:Number;
private var _leftEnergy:Number;
private var _beat:Boolean;
private var _rawLeftData:Array;
private var _bpm:Number;
private var _fftLeftData:Array;
private var _smartBeat:Boolean;
private var _fftAvgData:Array;
private var _fftRightData:Array;
private var _rawAvgData:Array;
private var _rawRightData:Array;
private static const ENERGY_MODE:uint = 0;
public function SoundData(_arg1:Boolean, _arg2:Number){
m_PredictedTimeUntilBeat = -1;
_beat = _arg1;
_bpm = _arg2;
captureData();
}
public function set bpm(_arg1:uint):void{
_bpm = _arg1;
}
private function captureData():void{
var soundData1:ByteArray;
var soundData2:ByteArray;
var randomData:Boolean;
var i:uint;
var j:uint;
var soundFreq:Array;
var lastD:Number;
var newD:Number;
randomData = false;
soundData1 = new ByteArray();
soundData2 = new ByteArray();
if (!SoundMixer.areSoundsInaccessible()){
try {
SoundMixer.computeSpectrum(soundData1, false);
SoundMixer.computeSpectrum(soundData2, true, 1);
} catch(e:SecurityError) {
trace("computeSpectrum security error in SoundData!");
randomData = true;
};
} else {
randomData = true;
};
if (randomData){
if (AudioManager.AmIPlaying()){
lastD = 0;
j = 0;
while (j < 2) {
i = 0;
while (i < 0x0100) {
newD = ((Math.random() * 3) - 1.5);
var _local2 = (lastD + ((newD - lastD) / 8));
lastD = _local2;
soundData1.writeFloat(_local2);
soundData2.writeFloat((Math.random() * Math.pow((1 - (i / 0xFF)), 1.4)));
i = (i + 1);
};
j = (j + 1);
};
} else {
i = 0;
while (i < 0x0200) {
soundData1.writeFloat(0);
soundData2.writeFloat(0);
i = (i + 1);
};
};
soundData1.position = 0;
soundData2.position = 0;
};
_leftEnergy = (_rightEnergy = 0);
soundFreq = new Array(4);
_rawLeftData = new Array(0x0100);
_rawRightData = new Array(0x0100);
_fftLeftData = new Array(0x0100);
_fftRightData = new Array(0x0100);
_rawAvgData = new Array(0x0100);
_fftAvgData = new Array(0x0100);
i = 0;
while (i < 0x0100) {
_rawLeftData[i] = soundData1.readFloat();
_fftLeftData[i] = soundData2.readFloat();
_leftEnergy = (_leftEnergy + (Math.abs(_rawLeftData[i]) * 128));
i = (i + 1);
};
i = 0;
while (i < 0x0100) {
_rawRightData[i] = soundData1.readFloat();
_fftRightData[i] = soundData2.readFloat();
_rawAvgData[i] = ((_rawLeftData[i] + _rawRightData[i]) / 2);
_fftAvgData[i] = ((_fftLeftData[i] + _fftRightData[i]) / 2);
_rightEnergy = (_rightEnergy + (Math.abs(_rawRightData[i]) * 128));
i = (i + 1);
};
}
public function get rawAvg():Array{
return (_rawAvgData);
}
public function get rawRight():Array{
return (_rawRightData);
}
public function get rawLeft():Array{
return (_rawLeftData);
}
public function get fftRight():Array{
return (_fftRightData);
}
public function get fftLeft():Array{
return (_fftLeftData);
}
public function get predictedTimeUntilBeat():Number{
return (m_PredictedTimeUntilBeat);
}
public function get bpm():uint{
return (_bpm);
}
public function set predictedTimeUntilBeat(_arg1:Number):void{
m_PredictedTimeUntilBeat = _arg1;
}
public function set smartBeat(_arg1:Boolean):void{
_smartBeat = _arg1;
}
public function set beat(_arg1:Boolean):void{
_beat = _arg1;
}
public function getTotalSubbandEnergy(_arg1:uint=0, _arg2:uint=0x0100, _arg3:uint=2):Number{
var _local4:uint;
var _local5:Number;
_local5 = 0;
if (_arg3 == 2){
_local4 = _arg1;
while (_local4 < _arg2) {
_local5 = (_local5 + (_fftAvgData[_local4] * _fftAvgData[_local4]));
_local4++;
};
} else {
if (_arg3 == 1){
_local4 = _arg1;
while (_local4 < _arg2) {
_local5 = (_local5 + (_fftRightData[_local4] * _fftRightData[_local4]));
_local4++;
};
} else {
_local4 = _arg1;
while (_local4 < _arg2) {
_local5 = (_local5 + (_fftLeftData[_local4] * _fftLeftData[_local4]));
_local4++;
};
};
};
return (_local5);
}
public function get energy():Number{
return (Math.max(_leftEnergy, _rightEnergy));
}
public function get beat():Boolean{
return (_beat);
}
public function get smartBeat():Boolean{
return (_smartBeat);
}
public function generateSmoothedData(_arg1:uint, _arg2:Boolean, _arg3:uint=2):Array{
var _local4:Array;
var _local5:Array;
var _local6:uint;
var _local7:int;
_local4 = [];
if (_arg2){
if (_arg3 == 0){
_local5 = _fftLeftData;
} else {
if (_arg3 == 1){
_local5 = _fftRightData;
} else {
_local5 = _fftAvgData;
};
};
} else {
if (_arg3 == 0){
_local5 = _rawLeftData;
} else {
if (_arg3 == 1){
_local5 = _rawRightData;
} else {
_local5 = _rawAvgData;
};
};
};
_local6 = 0;
while (_local6 < 0x0100) {
_local4[_local6] = 0;
_local6++;
};
_local6 = 0;
while (_local6 < 0x0100) {
_local7 = Math.max(0, (_local6 - _arg1));
while (_local7 <= Math.min(0xFF, (_local6 + _arg1))) {
_local4[_local6] = (_local4[_local6] + _local5[_local7]);
_local7++;
};
_local4[_local6] = (_local4[_local6] / ((_arg1 * 2) + 1));
_local6++;
};
return (_local4);
}
public function get fftAvg():Array{
return (_fftAvgData);
}
public function getSubbandEnergy(_arg1:uint=0, _arg2:uint=0x0100, _arg3:uint=2):Number{
var _local4:uint;
var _local5:Number;
_local5 = 0;
if (_arg3 == 2){
_local4 = _arg1;
while (_local4 < _arg2) {
_local5 = (_local5 + (_fftAvgData[_local4] * _fftAvgData[_local4]));
_local4++;
};
} else {
if (_arg3 == 1){
_local4 = _arg1;
while (_local4 < _arg2) {
_local5 = (_local5 + (_fftRightData[_local4] * _fftRightData[_local4]));
_local4++;
};
} else {
_local4 = _arg1;
while (_local4 < _arg2) {
_local5 = (_local5 + (_fftLeftData[_local4] * _fftLeftData[_local4]));
_local4++;
};
};
};
return ((_local5 / (_arg2 - _arg1)));
}
}
}//package mwelsh.audio.visualizer
Section 32
//AudioManager (mwelsh.audio.AudioManager)
package mwelsh.audio {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.net.*;
import flash.errors.*;
public class AudioManager extends EventDispatcher {
private var m_SongEndTime:int;
private var m_SongPosition:uint;
private var m_Status:uint;
private var m_SoundChannel:SoundChannel;
private var m_Filename:String;
private var m_Ticker:DisplayObject;
private var m_Volume:Number;// = 1
private var m_GivenLength:uint;
private var m_Looping:Boolean;
private var m_MusicData:Sound;
private var m_Time:uint;// = 0
private static const SONG_STOPPED = 0;
private static const SONG_PLAYING = 1;
public static const SONG_COMPLETE_EVENT:String = "songCompleteEvent";
private static const SONG_PAUSED = 2;
public static var m_Instance:AudioManager;
public function AudioManager():void{
m_Volume = 1;
m_Time = 0;
super();
m_Status = SONG_STOPPED;
m_Looping = false;
m_SongPosition = 0;
m_Ticker = new Sprite();
m_Ticker.addEventListener("enterFrame", checkLoop);
m_Instance = this;
}
public function stop():void{
if (!m_MusicData){
return;
};
m_Status = SONG_STOPPED;
m_SongPosition = 0;
if (m_SoundChannel){
m_SoundChannel.removeEventListener("soundComplete", songComplete);
m_SoundChannel.stop();
m_SoundChannel = null;
};
}
public function get volume():Number{
return (m_Volume);
}
public function get music():String{
return (m_Filename);
}
public function get position():uint{
if (m_SoundChannel){
return (m_SoundChannel.position);
};
return (m_SongPosition);
}
private function cleanupMusicData(_arg1:Event=null):void{
if (m_MusicData){
m_MusicData.close();
m_MusicData.removeEventListener(IOErrorEvent.IO_ERROR, cleanupMusicData);
m_MusicData.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, cleanupMusicData);
m_MusicData = null;
if (m_SoundChannel){
m_SoundChannel.stop();
m_SoundChannel = null;
};
};
}
public function get lengthDownloaded():uint{
if (m_MusicData){
return (m_MusicData.length);
};
return (0);
}
public function set volume(_arg1:Number):void{
m_Volume = _arg1;
if (m_SoundChannel){
m_SoundChannel.soundTransform = new SoundTransform(_arg1);
};
}
public function play():void{
if (!m_MusicData){
return;
};
if (m_Status == SONG_PAUSED){
pause();
} else {
if (m_Status == SONG_PLAYING){
stop();
};
m_SoundChannel = m_MusicData.play(m_SongPosition);
m_SoundChannel.soundTransform = new SoundTransform(m_Volume);
m_SoundChannel.addEventListener("soundComplete", songComplete);
m_Status = SONG_PLAYING;
if (downloadComplete){
m_SongEndTime = ((getTimer() + m_MusicData.length) - m_SongPosition);
};
};
}
public function get looping():Boolean{
return (m_Looping);
}
public function set position(_arg1:uint){
if (!m_MusicData){
return;
};
m_SongPosition = Math.min((length - 50), _arg1);
if (m_Status == SONG_PLAYING){
if (m_SoundChannel){
m_SoundChannel.stop();
m_SoundChannel.removeEventListener("soundComplete", songComplete);
};
m_SoundChannel = m_MusicData.play(m_SongPosition);
m_SoundChannel.soundTransform = new SoundTransform(m_Volume);
m_SoundChannel.addEventListener("soundComplete", songComplete);
if (m_MusicData.bytesLoaded == m_MusicData.bytesTotal){
m_SongEndTime = ((getTimer() + length) - m_SongPosition);
};
};
}
public function set music(_arg1:String){
loadMusic(_arg1);
}
private function loadMusic(_arg1:String){
var lc:SoundLoaderContext;
var file = _arg1;
stop();
if (m_MusicData){
cleanupMusicData();
};
m_Filename = file;
lc = new SoundLoaderContext(1000, true);
try {
m_MusicData = new Sound(new URLRequest(m_Filename), lc);
m_MusicData.addEventListener(IOErrorEvent.IO_ERROR, cleanupMusicData);
m_MusicData.addEventListener(SecurityErrorEvent.SECURITY_ERROR, cleanupMusicData);
} catch(e:Error) {
if ((((e is IOError)) && ((e.errorID == 2032)))){
m_MusicData.close();
};
trace((("Error loading music file " + m_Filename) + "!"));
trace(e);
cleanupMusicData();
};
}
public function get downloadComplete():Boolean{
return (((((m_MusicData) && (m_MusicData.bytesTotal))) && ((m_MusicData.bytesLoaded == m_MusicData.bytesTotal))));
}
public function set length(_arg1:uint):void{
m_GivenLength = _arg1;
}
public function get length():uint{
if (downloadComplete){
return (m_MusicData.length);
};
if (m_GivenLength){
return (m_GivenLength);
};
if (m_MusicData){
return ((m_MusicData.length / (m_MusicData.bytesLoaded / m_MusicData.bytesTotal)));
};
return (0);
}
private function checkLoop(_arg1:Event){
var _local2:uint;
var _local3:Number;
_local2 = (getTimer() - m_Time);
m_Time = (m_Time + _local2);
if (((m_MusicData) && (m_SoundChannel))){
if ((((((m_SongEndTime == 0)) && ((m_Status == SONG_PLAYING)))) && (downloadComplete))){
m_SongEndTime = ((getTimer() + length) - m_SoundChannel.position);
};
_local3 = (m_SongEndTime - getTimer());
if ((((((((((((m_Status == SONG_PLAYING)) && ((m_MusicData.length > 0)))) && ((m_MusicData.bytesLoaded == m_MusicData.bytesTotal)))) && (m_Looping))) && (m_SongEndTime))) && ((_local3 <= 100)))){
trace("LOOP");
m_SoundChannel.removeEventListener("soundComplete", songComplete);
m_SoundChannel = m_MusicData.play(0);
m_SoundChannel.soundTransform = new SoundTransform(m_Volume);
m_SoundChannel.addEventListener("soundComplete", songComplete);
m_SongPosition = 0;
m_SongEndTime = ((getTimer() + m_MusicData.length) - m_SongPosition);
};
};
}
public function get status():uint{
return (m_Status);
}
private function songComplete(_arg1:Event=null):void{
dispatchEvent(new Event(SONG_COMPLETE_EVENT));
stop();
if (m_Looping){
play();
};
}
public function pause():void{
if (m_Status == SONG_PAUSED){
if (!m_MusicData){
return;
};
m_SoundChannel = m_MusicData.play(m_SongPosition);
m_SoundChannel.soundTransform = new SoundTransform(m_Volume);
if (downloadComplete){
m_SongEndTime = (((getTimer() + m_MusicData.length) - m_SongPosition) - 100);
};
m_SoundChannel.addEventListener("soundComplete", songComplete);
m_Status = SONG_PLAYING;
} else {
if (!m_MusicData){
return;
};
m_Status = SONG_PAUSED;
if (m_SoundChannel){
m_SoundChannel.stop();
m_SoundChannel.removeEventListener("soundComplete", songComplete);
m_SongPosition = m_SoundChannel.position;
m_SoundChannel = null;
} else {
m_SongPosition = 0;
};
};
}
public function set looping(_arg1:Boolean):void{
m_Looping = _arg1;
}
public static function AmIPlaying():Boolean{
if (!m_Instance){
return (false);
};
return ((m_Instance.status == SONG_PLAYING));
}
}
}//package mwelsh.audio
Section 33
//AudioPlayer (mwelsh.audio.AudioPlayer)
package mwelsh.audio {
import flash.display.*;
import mwelsh.audio.visualizer.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import mwelsh.com.*;
import flash.net.*;
import flash.ui.*;
import flash.external.*;
public class AudioPlayer extends MovieClip {
private var _artistName:String;// = ""
private var _fps:Number;
public var visContainer:MovieClip;
private var _visMenuAccum:Number;
private var _frameTime:Number;
private var _visPlaylist:Array;
private var _visPlaylistClasses:Array;
public var txtSongPos:TextField;
public var t:int;
public var btnStop:MovieClip;
public var visMask2:MovieClip;
private var _visListMinX:Number;
private var _songName:String;// = ""
public var tankbg:MovieClip;
private var _audio:AudioManager;
public var slider:SimpleSlider;
public var visList:MovieClip;
public var btnPause:MovieClip;
public var txtArtistName:TextField;
public var btnLoop:MovieClip;
private var _mouseHoverTime:Number;
private var _visListScrolling:Boolean;
public var visMask:MovieClip;
private var _visMenuItems:Array;
private var _frameCount:uint;
private var _vis:AudioVisualizer;
public var autoPlay:Boolean;
public var visMenu:MovieClip;
private var _menuShowing:Boolean;
public var btnPlay:MovieClip;
private var _visListMaxX:Number;
private var _visState:uint;
private var _playerMode:uint;
private var _menuSelectedText:TextField;
public var txtSongName:TextField;
private var _visMenuPos:Number;
public var visTitleStrip:MovieClip;
private var _transitionTime:uint;
private var _sharedObject:SharedObject;
private var _visListSpeed:Number;
private var _contextMenu:ContextMenu;
public static const STATE_ACTIVE:uint = 0;
public static const MODE_USERPAGE:uint = 1;
public static const STATE_INACTIVE:uint = 3;
public static const MODE_AUDIOUPLOAD:uint = 2;
public static const MODE_AUDIOVIEW:uint = 0;
public function AudioPlayer(_arg1:uint, _arg2:Array):void{
var _local3:uint;
_artistName = "";
_songName = "";
super();
t = 0;
_playerMode = _arg1;
_visPlaylist = _arg2;
_visPlaylistClasses = [];
_local3 = 0;
while (_local3 < _arg2.length) {
_visPlaylistClasses[_local3] = _visPlaylist[_local3][1];
_local3++;
};
init();
}
private function initVisMenu():void{
var xPos:Number;
var spr:Sprite;
var tf:VisTextField;
var visName:String;
var i:uint;
visMenu.visible = false;
visMenu.mask = visMask2;
_menuShowing = false;
xPos = (visMenu.btnListLeft.x + 15);
visList = new MovieClip();
visMenu.addChild(visList);
visList.mask = visMenu.visListMask;
_visMenuItems = [];
spr = new Sprite();
tf = new VisTextField();
tf.antiAliasType = AntiAliasType.NORMAL;
tf.type = TextFieldType.DYNAMIC;
tf.text = "Off";
tf.selectable = false;
tf.x = xPos;
tf.y = 20;
tf.width = 80;
tf.setTextFormat(new TextFormat("Arial", 12, 4289374890, true, false, false, null, null, TextFormatAlign.CENTER));
xPos = (xPos + 90);
spr.addChild(tf);
spr.addEventListener(MouseEvent.CLICK, hideVis);
spr.buttonMode = (spr.useHandCursor = true);
spr.mouseChildren = false;
visList.addChild(spr);
_visMenuItems.push(tf);
if (_visState == STATE_INACTIVE){
_menuSelectedText = tf;
};
i = 0;
while (i < _visPlaylist.length) {
visName = _visPlaylist[i][0];
spr = new Sprite();
tf = new VisTextField();
tf.className = _visPlaylist[i][1];
tf.antiAliasType = AntiAliasType.NORMAL;
tf.type = TextFieldType.DYNAMIC;
tf.text = visName;
tf.selectable = false;
tf.x = xPos;
tf.y = 20;
tf.width = 80;
tf.setTextFormat(new TextFormat("Arial", 12, 4289374890, true, false, false, null, null, TextFormatAlign.CENTER));
xPos = (xPos + 90);
spr.addChild(tf);
_visMenuItems.push(tf);
spr.addEventListener(MouseEvent.CLICK, visMenuSelectVis);
spr.buttonMode = (spr.useHandCursor = true);
spr.mouseChildren = false;
if (((_vis) && ((tf.className == _vis.visualization)))){
_menuSelectedText = tf;
};
visList.addChild(spr);
i = (i + 1);
};
_menuSelectedText.textColor = 4294967295;
visMenu.btnListLeft.addEventListener(MouseEvent.MOUSE_DOWN, function ():void{
_visListScrolling = true;
_visListSpeed = 1;
});
visMenu.btnListLeft.buttonMode = true;
visMenu.btnListRight.addEventListener(MouseEvent.MOUSE_DOWN, function ():void{
_visListScrolling = true;
_visListSpeed = -1;
});
visMenu.btnListRight.buttonMode = true;
App.getInstance().addEventListener(MouseEvent.MOUSE_UP, function ():void{
_visListScrolling = false;
});
App.getStage().addEventListener("mouseLeave", function ():void{
_visListScrolling = false;
});
visMenu.transitionSlider.min = 5;
visMenu.transitionSlider.max = 90;
visMenu.transitionSlider.clamp = 1;
visMenu.transitionSlider.value = transitionTime;
visMenu.transitionSlider.dragUpdate = true;
visMenu.transitionSlider.addEventListener(Event.CHANGE, transitionSliderUpdate);
visMenu.volumeSlider.min = 0;
visMenu.volumeSlider.max = 1;
visMenu.volumeSlider.clamp = 0;
visMenu.volumeSlider.dragUpdate = true;
visMenu.volumeSlider.value = _audio.volume;
visMenu.volumeSlider.addEventListener(Event.CHANGE, volumeSliderUpdate);
if (visMenu.btnFullscreen){
visMenu.btnFullscreen.addEventListener(MouseEvent.CLICK, function ():void{
_vis.fullscreen = !(_vis.fullscreen);
});
visMenu.btnFullscreen.mouseChildren = false;
visMenu.btnFullscreen.buttonMode = true;
};
tankbg.addEventListener(MouseEvent.CLICK, toggleVisMenu);
tankbg.buttonMode = true;
_visListMaxX = 0;
_visListMinX = (-(xPos) + visMenu.visListMask.width);
}
private function visChanged(_arg1:Event=null):void{
var _local2:String;
var _local3:uint;
if (_menuSelectedText){
_menuSelectedText.textColor = 4289374890;
_menuSelectedText = null;
};
_local2 = _vis.visualization;
_local3 = 0;
while (_local3 < _visMenuItems.length) {
if (VisTextField(_visMenuItems[_local3]).className == _local2){
_menuSelectedText = _visMenuItems[_local3];
_menuSelectedText.textColor = 4294967295;
};
_local3++;
};
}
private function changePos(_arg1:Event):void{
_audio.position = slider.value;
}
public function set songName(_arg1:String):void{
_songName = _arg1;
if (txtSongName){
txtSongName.text = _arg1;
};
}
private function initContextMenu():void{
var cItem:ContextMenuItem;
_contextMenu = new ContextMenu();
_contextMenu.hideBuiltInItems();
var _local2 = new ContextMenuItem(("Newgrounds Audio Player v" + AudioVisualizer.VERSION));
cItem = _local2;
_contextMenu.customItems.push(_local2);
cItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function ():void{
if (_vis){
_vis.visualization = "AboutVisualization";
visChanged();
};
});
this.contextMenu = _contextMenu;
if (slider){
slider.contextMenu = _contextMenu;
};
}
private function visMenuSelectVis(_arg1:MouseEvent):void{
if (_visState == STATE_INACTIVE){
_visState = STATE_ACTIVE;
initVis(VisTextField(Sprite(_arg1.target).getChildAt(0)).className);
visChanged();
saveSettings();
} else {
_vis.visualization = VisTextField(Sprite(_arg1.target).getChildAt(0)).className;
};
}
public function get aritstName():String{
return (_artistName);
}
private function saveSettings():void{
if (_playerMode == MODE_USERPAGE){
_sharedObject.data.autoPlay = autoPlay;
};
if ((((_playerMode == MODE_USERPAGE)) || ((_playerMode == MODE_AUDIOVIEW)))){
_sharedObject.data.visState = _visState;
};
if (_playerMode == MODE_AUDIOVIEW){
_sharedObject.data.transitionTime = transitionTime;
_sharedObject.data.volume = _audio.volume;
};
_sharedObject.flush();
}
private function updatePos(_arg1:Event=null):void{
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local8:uint;
var _local9:uint;
_local2 = (getTimer() - t);
_frameCount++;
_frameTime = (_frameTime + (_local2 / 1000));
if (_frameCount == 10){
_fps = (_frameCount / _frameTime);
_frameCount = (_frameTime = 0);
};
if (visMenu){
_visMenuAccum = (_visMenuAccum + (_local2 / 1000));
while (_visMenuAccum >= 0.01) {
if (_menuShowing){
_visMenuPos = (_visMenuPos + ((1 - _visMenuPos) / 8));
visMenu.visible = true;
if (_visMenuPos >= 0.995){
_visMenuPos = 1;
};
} else {
_visMenuPos = (_visMenuPos + ((0 - _visMenuPos) / 8));
if (_visMenuPos <= 0.005){
visMenu.visible = false;
_visMenuPos = 0;
if (_menuSelectedText){
visList.x = -((((_menuSelectedText.x + (_menuSelectedText.width / 2)) - visMenu.visListMask.x) - (visMenu.visListMask.width / 2)));
};
};
};
if (!_visListScrolling){
_visListSpeed = (_visListSpeed * 0.95);
};
if (Math.abs(_visListSpeed) < 0.1){
_visListSpeed = 0;
};
visList.x = (visList.x + (_visListSpeed * 10));
if (visList.x < _visListMinX){
visList.x = _visListMinX;
};
if (visList.x > _visListMaxX){
visList.x = _visListMaxX;
};
_visMenuAccum = (_visMenuAccum - 0.01);
};
visMenu.y = (visMask2.y - ((1 - _visMenuPos) * visMenu.height));
visMenu.fpsText.text = Math.round(_fps).toString();
};
if (!_audio.status){
stopMusic();
};
t = (t + _local2);
_local3 = _audio.position;
_local4 = Math.floor((_local3 / 1000));
_local5 = Math.ceil((_audio.length / 1000));
if (txtSongPos){
_local6 = (_local4 / 60);
_local7 = (_local4 % 60);
_local8 = (_local5 / 60);
_local9 = (_local5 % 60);
txtSongPos.text = ((((((((_local6)<10) ? ("0" + _local6) : _local6 + ":") + ((_local7)<10) ? ("0" + _local7) : _local7) + " / ") + ((_local8)<10) ? ("0" + _local8) : _local8) + ":") + ((_local9)<10) ? ("0" + _local9) : _local9);
};
if (slider){
slider.ready = _audio.lengthDownloaded;
slider.max = _audio.length;
slider.value = _local3;
};
}
public function loadMusic(_arg1:String, _arg2:uint=0):void{
_audio.music = _arg1;
if (_arg2){
_audio.length = _arg2;
};
btnPlay.visible = true;
if (btnPause){
btnPause.visible = false;
} else {
btnStop.visible = false;
};
if (autoPlay){
playMusic();
};
}
public function set artistName(_arg1:String):void{
_artistName = _arg1;
if (txtArtistName){
txtArtistName.text = _arg1;
};
}
private function initVis(_arg1:String=null):void{
if (_visState == STATE_INACTIVE){
return;
};
_vis = new AudioVisualizer(Math.ceil(visMask.width), Math.ceil(visMask.height), _visPlaylistClasses, _arg1);
_vis.x = 0;
_vis.y = 0;
if (visMenu){
_vis.addEventListener(MouseEvent.CLICK, toggleVisMenu);
_vis.addEventListener(AudioVisualizer.VIS_CHANGED, visChanged);
_vis.buttonMode = true;
};
_vis.alpha = 1;
_vis.transitionTime = _transitionTime;
_vis.resetBeatDetection();
visContainer.addChild(_vis);
}
private function transitionSliderUpdate(_arg1:Event):void{
if (visMenu.transitionSlider.value > 5){
transitionTime = visMenu.transitionSlider.value;
} else {
transitionTime = 0;
};
}
public function init():void{
var _local1:uint;
_audio = new AudioManager();
_visMenuPos = 0;
_visMenuAccum = 0;
_visListSpeed = 0;
_visListScrolling = false;
_mouseHoverTime = 0;
_frameTime = (_frameCount = (_fps = 0));
visContainer.mask = visMask;
loadSettings();
initVis();
initUI();
readFlashVars();
if (AudioVisualizer.DEBUG){
if (AudioVisualizer.DEBUG_SONG == -1){
_local1 = uint((Math.random() * AudioVisualizer.DEBUG_SONGS.length));
} else {
_local1 = AudioVisualizer.DEBUG_SONG;
};
loadMusic(("songs/" + AudioVisualizer.DEBUG_SONGS[_local1]));
};
}
private function loadSettings():void{
_sharedObject = SharedObject.getLocal("AudioPlayerSettings");
if (_sharedObject.data.autoPlay == undefined){
_sharedObject.data.autoPlay = true;
};
if (_sharedObject.data.visState == undefined){
_sharedObject.data.visState = STATE_ACTIVE;
};
if (_sharedObject.data.transitionTime == undefined){
_sharedObject.data.transitionTime = 25;
};
if (_sharedObject.data.volume == undefined){
_sharedObject.data.volume = 1;
};
if (_playerMode == MODE_USERPAGE){
autoPlay = _sharedObject.data.autoPlay;
} else {
if (_playerMode == MODE_AUDIOVIEW){
autoPlay = true;
} else {
autoPlay = false;
};
};
if (_playerMode == MODE_AUDIOUPLOAD){
_visState = STATE_ACTIVE;
} else {
_visState = _sharedObject.data.visState;
};
if (_playerMode == MODE_AUDIOVIEW){
transitionTime = _sharedObject.data.transitionTime;
visMenu.transitionSlider.value = transitionTime;
_audio.volume = _sharedObject.data.volume;
} else {
transitionTime = 0;
};
saveSettings();
}
public function stopMusic(_arg1:Event=null):void{
if (_audio.status){
_audio.stop();
};
btnPlay.visible = true;
if (btnPause){
btnPause.visible = false;
} else {
btnStop.visible = false;
};
if (_vis){
_vis.resetBeatDetection();
};
autoPlay = false;
saveSettings();
}
private function volumeSliderUpdate(_arg1:Event):void{
_audio.volume = visMenu.volumeSlider.value;
saveSettings();
}
private function readFlashVars():void{
var _local1:String;
var _local2:String;
var _local3:Object;
_local3 = App.getInstance().loaderInfo.parameters;
looping = _local3.loop;
if (_local3.name){
songName = _local3.name;
} else {
songName = "";
};
if (_local3.artist){
artistName = _local3.artist;
} else {
artistName = "";
};
if (_local3.length){
_audio.length = (_local3.length * 1000);
};
if (_local3.filename){
loadMusic(_local3.filename, _audio.length);
};
}
public function get songName():String{
return (_songName);
}
public function playMusic(_arg1:Event=null):void{
_audio.play();
btnPlay.visible = false;
if (btnPause){
btnPause.visible = true;
} else {
btnStop.visible = true;
};
if (_vis){
_vis.unpauseBeatDetection();
};
autoPlay = true;
saveSettings();
}
public function set looping(_arg1:Boolean):void{
_audio.looping = _arg1;
if (btnLoop){
btnLoop.gotoAndStop((_arg1) ? 3 : 1);
};
}
public function set transitionTime(_arg1:uint):void{
_transitionTime = _arg1;
if (_vis){
_vis.transitionTime = _arg1;
};
if (visMenu){
if (_arg1){
visMenu.transitionTimeText.text = (_arg1 + " secs");
} else {
visMenu.transitionTimeText.text = "Off";
};
};
saveSettings();
}
private function hideVis(_arg1:MouseEvent=null):void{
if (_visState != STATE_ACTIVE){
return;
};
_vis.alpha = 0;
_vis.cleanup();
_vis.removeEventListener(MouseEvent.CLICK, toggleVisMenu);
visContainer.removeChild(_vis);
_visState = STATE_INACTIVE;
_menuShowing = false;
_menuSelectedText.textColor = 4289374890;
_menuSelectedText = TextField(Sprite(_arg1.target).getChildAt(0));
_menuSelectedText.textColor = 4294967295;
saveSettings();
}
private function initUI():void{
btnPlay.stop();
if (btnPause){
btnPause.stop();
};
btnStop.stop();
btnPlay.addEventListener("click", playMusic);
btnPlay.addEventListener("mouseOver", function (_arg1:Event):void{
btnPlay.gotoAndStop(2);
});
btnPlay.addEventListener("mouseOut", function (_arg1:Event):void{
btnPlay.gotoAndStop(1);
});
btnStop.addEventListener("click", pauseMusic);
btnStop.addEventListener("mouseOver", function (_arg1:Event):void{
btnStop.gotoAndStop(2);
});
btnStop.addEventListener("mouseOut", function (_arg1:Event):void{
btnStop.gotoAndStop(1);
});
if (btnPause){
btnPause.addEventListener("click", pauseMusic);
};
if (btnPause){
btnPause.addEventListener("mouseOver", function (_arg1:Event):void{
btnPause.gotoAndStop(2);
});
};
if (btnPause){
btnPause.addEventListener("mouseOut", function (_arg1:Event):void{
btnPause.gotoAndStop(1);
});
};
if (btnLoop){
btnLoop.stop();
btnLoop.addEventListener("click", function (_arg1:Event):void{
_audio.looping = !(_audio.looping);
btnLoop.gotoAndStop((_audio.looping) ? 4 : 2);
});
btnLoop.addEventListener("mouseOver", function (_arg1:Event):void{
btnLoop.gotoAndStop((_audio.looping) ? 4 : 2);
});
btnLoop.addEventListener("mouseOut", function (_arg1:Event):void{
btnLoop.gotoAndStop((_audio.looping) ? 3 : 1);
});
btnLoop.buttonMode = true;
btnLoop.useHandCursor = true;
};
if (btnPause){
btnPause.visible = false;
};
btnPlay.buttonMode = true;
if (btnPause){
btnPause.buttonMode = true;
};
btnStop.buttonMode = true;
btnPlay.useHandCursor = true;
if (btnPause){
btnPause.useHandCursor = true;
};
btnStop.useHandCursor = true;
addEventListener(Event.ENTER_FRAME, updatePos);
if (slider){
slider.addEventListener(Event.CHANGE, changePos);
slider.dragUpdate = true;
};
if ((((_playerMode == MODE_AUDIOVIEW)) && (visMenu))){
initVisMenu();
};
try {
ExternalInterface.addCallback("stopMusic", stopMusic);
ExternalInterface.addCallback("playMusic", playMusic);
ExternalInterface.addCallback("pauseMusic", pauseMusic);
ExternalInterface.addCallback("changeMusic", loadMusic);
} catch(e:Error) {
};
initContextMenu();
}
private function toggleVisMenu(_arg1:MouseEvent):void{
_menuShowing = !(_menuShowing);
}
public function pauseMusic(_arg1:Event=null):void{
_audio.pause();
if (btnPause){
btnPause.visible = true;
} else {
btnStop.visible = false;
};
btnPlay.visible = true;
if (_vis){
_vis.pauseBeatDetection();
};
autoPlay = false;
saveSettings();
}
public function get transitionTime():uint{
return (_transitionTime);
}
}
}//package mwelsh.audio
import flash.text.*;
class VisTextField extends TextField {
public var className:String;
private function VisTextField(){
}
}
Section 34
//MiniSlider (mwelsh.com.MiniSlider)
package mwelsh.com {
public dynamic class MiniSlider extends SimpleSlider {
}
}//package mwelsh.com
Section 35
//SimpleSlider (mwelsh.com.SimpleSlider)
package mwelsh.com {
import flash.display.*;
import flash.events.*;
public class SimpleSlider extends Sprite {
private var m_Dragging:Boolean;// = false
private var m_UseReadyBar:Boolean;// = false
public var sliderTab:MovieClip;
private var m_Ready:Number;// = 0
private var m_Clamp:Number;// = 0
private var m_Min:Number;// = 0
public var readyBar:Sprite;
private var m_Enabled:Boolean;// = true
private var m_DragUpdate:Boolean;// = false
private var m_Max:Number;// = 1
public var sliderBar:Sprite;
private var m_Value:Number;// = 0
public function SimpleSlider():void{
m_Min = 0;
m_Max = 1;
m_Value = 0;
m_Clamp = 0;
m_Enabled = true;
m_Dragging = false;
m_UseReadyBar = false;
m_Ready = 0;
m_DragUpdate = false;
super();
addEventListener("mouseDown", dragStart);
App.getInstance().addEventListener("mouseUp", dragStop);
App.getStage().addEventListener("mouseLeave", dragStop);
addEventListener("enterFrame", tick);
buttonMode = true;
useHandCursor = true;
sliderTab.buttonMode = true;
sliderTab.useHandCursor = true;
sliderTab.addEventListener("mouseOver", function (){
sliderTab.gotoAndStop(2);
});
sliderTab.addEventListener("mouseOut", function (){
if (!m_Dragging){
sliderTab.gotoAndStop(1);
};
});
}
public function get dragUpdate():Boolean{
return (m_DragUpdate);
}
public function setValue(_arg1:Number):void{
var _local2:Number;
if (m_Clamp){
m_Value = (Math.floor(((_arg1 + (m_Clamp / 2)) / m_Clamp)) * m_Clamp);
};
m_Value = Math.min(Math.max(m_Min, _arg1), (m_UseReadyBar) ? m_Ready : m_Max);
_local2 = (((m_Value - m_Min) / (m_Max - m_Min)) * sliderBar.width);
sliderTab.x = (_local2 - (sliderTab.width / 2));
}
public function get enabled():Boolean{
return (m_Enabled);
}
public function get min():Number{
return (m_Min);
}
private function dragStop(_arg1:Event):void{
if (m_Dragging){
m_Dragging = false;
sliderTab.gotoAndStop(1);
if (!m_DragUpdate){
dispatchEvent(new Event(Event.CHANGE));
};
};
}
public function get max():Number{
return (m_Max);
}
public function set clamp(_arg1:Number):void{
m_Clamp = _arg1;
setValue(m_Value);
}
public function set ready(_arg1:Number):void{
m_UseReadyBar = true;
m_Ready = _arg1;
readyBar.width = (sliderBar.width * (1 - (m_Ready / m_Max)));
}
public function set enabled(_arg1:Boolean):void{
m_Enabled = _arg1;
}
private function dragStart(_arg1:Event):void{
if (m_Enabled){
m_Dragging = true;
updateDrag();
sliderTab.gotoAndStop(2);
};
}
public function set dragUpdate(_arg1:Boolean):void{
m_DragUpdate = _arg1;
}
public function set min(_arg1:Number):void{
m_Min = _arg1;
setValue(m_Value);
}
private function updateDrag():void{
setValue((min + ((mouseX / sliderBar.width) * (max - min))));
if (m_DragUpdate){
dispatchEvent(new Event(Event.CHANGE));
};
}
function tick(_arg1:Event=null):void{
if (m_Dragging){
updateDrag();
};
}
public function get value():Number{
return (m_Value);
}
public function get ready():Number{
return (m_Ready);
}
public function get clamp():Number{
return (m_Clamp);
}
public function set max(_arg1:Number):void{
m_Max = _arg1;
setValue(m_Value);
}
public function set value(_arg1:Number):void{
setValue(_arg1);
}
}
}//package mwelsh.com
Section 36
//SongSlider (mwelsh.com.SongSlider)
package mwelsh.com {
public dynamic class SongSlider extends SimpleSlider {
}
}//package mwelsh.com
Section 37
//Matrix4x4 (mwelsh.math.Matrix4x4)
package mwelsh.math {
public class Matrix4x4 {
public var m31:Number;
public var m32:Number;
public var m33:Number;
public var m12:Number;
public var m13:Number;
public var m14:Number;
public var m11:Number;
public var m34:Number;
public var m41:Number;
public var m21:Number;
public var m22:Number;
public var m23:Number;
public var m24:Number;
public var m42:Number;
public var m43:Number;
public var m44:Number;
private static var identityMat:Matrix4x4 = new (Matrix4x4);
;
public function Matrix4x4(_arg1:Number=1, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=1, _arg7:Number=0, _arg8:Number=0, _arg9:Number=0, _arg10:Number=0, _arg11:Number=1, _arg12:Number=0, _arg13:Number=0, _arg14:Number=0, _arg15:Number=0, _arg16:Number=1){
m11 = _arg1;
m12 = _arg2;
m13 = _arg3;
m14 = _arg4;
m21 = _arg5;
m22 = _arg6;
m23 = _arg7;
m24 = _arg8;
m31 = _arg9;
m32 = _arg10;
m33 = _arg11;
m34 = _arg12;
m41 = _arg13;
m42 = _arg14;
m43 = _arg15;
m44 = _arg16;
}
public function multiply(_arg1:Matrix4x4):Matrix4x4{
var _local2:Matrix4x4;
_local2 = this;
return (new Matrix4x4(((((_local2.m11 * _arg1.m11) + (_local2.m12 * _arg1.m21)) + (_local2.m13 * _arg1.m31)) + (_local2.m14 * _arg1.m41)), ((((_local2.m11 * _arg1.m12) + (_local2.m12 * _arg1.m22)) + (_local2.m13 * _arg1.m32)) + (_local2.m14 * _arg1.m42)), ((((_local2.m11 * _arg1.m13) + (_local2.m12 * _arg1.m23)) + (_local2.m13 * _arg1.m33)) + (_local2.m14 * _arg1.m43)), ((((_local2.m11 * _arg1.m14) + (_local2.m12 * _arg1.m24)) + (_local2.m13 * _arg1.m34)) + (_local2.m14 * _arg1.m44)), ((((_local2.m21 * _arg1.m11) + (_local2.m22 * _arg1.m21)) + (_local2.m23 * _arg1.m31)) + (_local2.m24 * _arg1.m41)), ((((_local2.m21 * _arg1.m12) + (_local2.m22 * _arg1.m22)) + (_local2.m23 * _arg1.m32)) + (_local2.m24 * _arg1.m42)), ((((_local2.m21 * _arg1.m13) + (_local2.m22 * _arg1.m23)) + (_local2.m23 * _arg1.m33)) + (_local2.m24 * _arg1.m43)), ((((_local2.m21 * _arg1.m14) + (_local2.m22 * _arg1.m24)) + (_local2.m23 * _arg1.m34)) + (_local2.m24 * _arg1.m44)), ((((_local2.m31 * _arg1.m11) + (_local2.m32 * _arg1.m21)) + (_local2.m33 * _arg1.m31)) + (_local2.m34 * _arg1.m41)), ((((_local2.m31 * _arg1.m12) + (_local2.m32 * _arg1.m22)) + (_local2.m33 * _arg1.m32)) + (_local2.m34 * _arg1.m42)), ((((_local2.m31 * _arg1.m13) + (_local2.m32 * _arg1.m23)) + (_local2.m33 * _arg1.m33)) + (_local2.m34 * _arg1.m43)), ((((_local2.m31 * _arg1.m14) + (_local2.m32 * _arg1.m24)) + (_local2.m33 * _arg1.m34)) + (_local2.m34 * _arg1.m44)), ((((_local2.m41 * _arg1.m11) + (_local2.m42 * _arg1.m21)) + (_local2.m43 * _arg1.m31)) + (_local2.m44 * _arg1.m41)), ((((_local2.m41 * _arg1.m12) + (_local2.m42 * _arg1.m22)) + (_local2.m43 * _arg1.m32)) + (_local2.m44 * _arg1.m42)), ((((_local2.m41 * _arg1.m13) + (_local2.m42 * _arg1.m23)) + (_local2.m43 * _arg1.m33)) + (_local2.m44 * _arg1.m43)), ((((_local2.m41 * _arg1.m14) + (_local2.m42 * _arg1.m24)) + (_local2.m43 * _arg1.m34)) + (_local2.m44 * _arg1.m44))));
}
public function scale(_arg1:Number, _arg2:Number, _arg3:Number):void{
m11 = (m11 * _arg1);
m21 = (m21 * _arg1);
m31 = (m31 * _arg1);
m12 = (m12 * _arg2);
m22 = (m22 * _arg2);
m32 = (m32 * _arg2);
m13 = (m13 * _arg3);
m23 = (m23 * _arg3);
m33 = (m33 * _arg3);
}
public function det():Number{
return (((((((((((((((((((((((((((m14 * m23) * m32) * m41) - (((m13 * m24) * m32) * m41)) - (((m14 * m22) * m33) * m41)) + (((m12 * m24) * m33) * m41)) + (((m13 * m22) * m34) * m41)) - (((m12 * m23) * m34) * m41)) - (((m14 * m23) * m31) * m42)) + (((m13 * m24) * m31) * m42)) + (((m14 * m21) * m33) * m42)) - (((m11 * m24) * m33) * m42)) - (((m13 * m21) * m34) * m42)) + (((m11 * m23) * m34) * m42)) + (((m14 * m22) * m31) * m43)) - (((m12 * m24) * m31) * m43)) - (((m14 * m21) * m32) * m43)) + (((m11 * m24) * m32) * m43)) + (((m12 * m21) * m34) * m43)) - (((m11 * m22) * m34) * m43)) - (((m13 * m22) * m31) * m44)) + (((m12 * m23) * m31) * m44)) + (((m13 * m21) * m32) * m44)) - (((m11 * m23) * m32) * m44)) - (((m12 * m21) * m33) * m44)) + (((m11 * m22) * m33) * m44)));
}
public function clone():Matrix4x4{
return (new Matrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44));
}
public function rotateZ(_arg1:Number):void{
m21 = ((m11 * Math.cos(_arg1)) - (m21 * Math.sin(_arg1)));
m22 = ((m12 * Math.cos(_arg1)) - (m22 * Math.sin(_arg1)));
m23 = ((m13 * Math.cos(_arg1)) - (m23 * Math.sin(_arg1)));
m24 = ((m14 * Math.cos(_arg1)) - (m24 * Math.sin(_arg1)));
m21 = ((m11 * Math.sin(_arg1)) + (m21 * Math.cos(_arg1)));
m22 = ((m12 * Math.sin(_arg1)) + (m22 * Math.cos(_arg1)));
m23 = ((m13 * Math.sin(_arg1)) + (m23 * Math.cos(_arg1)));
m24 = ((m14 * Math.sin(_arg1)) + (m24 * Math.cos(_arg1)));
}
public function translate(_arg1:Number, _arg2:Number, _arg3:Number):void{
m14 = (m14 + _arg1);
m24 = (m24 + _arg2);
m34 = (m34 + _arg3);
}
public function reset():void{
m11 = 1;
m12 = 0;
m13 = 0;
m14 = 0;
m21 = 0;
m22 = 1;
m23 = 0;
m24 = 0;
m31 = 0;
m32 = 0;
m33 = 1;
m34 = 0;
m41 = 0;
m42 = 0;
m43 = 0;
m44 = 1;
}
public function rotateX(_arg1:Number):void{
m21 = ((m21 * Math.cos(_arg1)) - (m31 * Math.sin(_arg1)));
m22 = ((m22 * Math.cos(_arg1)) - (m32 * Math.sin(_arg1)));
m23 = ((m23 * Math.cos(_arg1)) - (m33 * Math.sin(_arg1)));
m24 = ((m24 * Math.cos(_arg1)) - (m34 * Math.sin(_arg1)));
m31 = ((m21 * Math.sin(_arg1)) + (m31 * Math.cos(_arg1)));
m32 = ((m22 * Math.sin(_arg1)) + (m32 * Math.cos(_arg1)));
m33 = ((m23 * Math.sin(_arg1)) + (m33 * Math.cos(_arg1)));
m34 = ((m24 * Math.sin(_arg1)) + (m34 * Math.cos(_arg1)));
}
public function rotateY(_arg1:Number):void{
m11 = ((m11 * Math.cos(_arg1)) + (m31 * Math.sin(_arg1)));
m12 = ((m12 * Math.cos(_arg1)) + (m32 * Math.sin(_arg1)));
m13 = ((m13 * Math.cos(_arg1)) + (m33 * Math.sin(_arg1)));
m14 = ((m14 * Math.cos(_arg1)) + (m34 * Math.sin(_arg1)));
m31 = ((-(m11) * Math.sin(_arg1)) + (m31 * Math.cos(_arg1)));
m32 = ((-(m12) * Math.sin(_arg1)) + (m32 * Math.cos(_arg1)));
m33 = ((-(m13) * Math.sin(_arg1)) + (m33 * Math.cos(_arg1)));
m34 = ((-(m14) * Math.sin(_arg1)) + (m34 * Math.cos(_arg1)));
}
public function inverse():Matrix4x4{
var _local1:Number;
_local1 = det();
if (!_local1){
return (null);
};
return (new Matrix4x4(((((((((-(m24) * m33) * m42) + ((m23 * m34) * m42)) + ((m24 * m32) * m43)) - ((m22 * m34) * m43)) - ((m23 * m32) * m44)) + ((m22 * m33) * m44)) / _local1), ((((((((m14 * m33) * m42) - ((m13 * m34) * m42)) - ((m14 * m32) * m43)) + ((m12 * m34) * m43)) + ((m13 * m32) * m44)) - ((m12 * m33) * m44)) / _local1), ((((((((-(m14) * m23) * m42) + ((m13 * m24) * m42)) + ((m14 * m22) * m43)) - ((m12 * m24) * m43)) - ((m13 * m22) * m44)) + ((m12 * m23) * m44)) / _local1), ((((((((m14 * m23) * m32) - ((m13 * m24) * m32)) - ((m14 * m22) * m33)) + ((m12 * m24) * m33)) + ((m13 * m22) * m34)) - ((m12 * m23) * m34)) / _local1), ((((((((m24 * m33) * m41) - ((m23 * m34) * m41)) - ((m24 * m31) * m43)) + ((m21 * m34) * m43)) + ((m23 * m31) * m44)) - ((m21 * m33) * m44)) / _local1), ((((((((-(m14) * m33) * m41) + ((m13 * m34) * m41)) + ((m14 * m31) * m43)) - ((m11 * m34) * m43)) - ((m13 * m31) * m44)) + ((m11 * m33) * m44)) / _local1), ((((((((m14 * m23) * m41) - ((m13 * m24) * m41)) - ((m14 * m21) * m43)) + ((m11 * m24) * m43)) + ((m13 * m21) * m44)) - ((m11 * m23) * m44)) / _local1), ((((((((-(m14) * m23) * m31) + ((m13 * m24) * m31)) + ((m14 * m21) * m33)) - ((m11 * m24) * m33)) - ((m13 * m21) * m34)) + ((m11 * m23) * m34)) / _local1), ((((((((-(m24) * m32) * m41) + ((m22 * m34) * m41)) + ((m24 * m31) * m42)) - ((m21 * m34) * m42)) - ((m22 * m31) * m44)) + ((m21 * m32) * m44)) / _local1), ((((((((m14 * m32) * m41) - ((m12 * m34) * m41)) - ((m14 * m31) * m42)) + ((m11 * m34) * m42)) + ((m12 * m31) * m44)) - ((m11 * m32) * m44)) / _local1), ((((((((-(m14) * m22) * m41) + ((m12 * m24) * m41)) + ((m14 * m21) * m42)) - ((m11 * m24) * m42)) - ((m12 * m21) * m44)) + ((m11 * m22) * m44)) / _local1), ((((((((m14 * m22) * m31) - ((m12 * m24) * m31)) - ((m14 * m21) * m32)) + ((m11 * m24) * m32)) + ((m12 * m21) * m34)) - ((m11 * m22) * m34)) / _local1), ((((((((m23 * m32) * m41) - ((m22 * m33) * m41)) - ((m23 * m31) * m42)) + ((m21 * m33) * m42)) + ((m22 * m31) * m43)) - ((m21 * m32) * m43)) / _local1), ((((((((-(m13) * m32) * m41) + ((m12 * m33) * m41)) + ((m13 * m31) * m42)) - ((m11 * m33) * m42)) - ((m12 * m31) * m43)) + ((m11 * m32) * m43)) / _local1), ((((((((m13 * m22) * m41) - ((m12 * m23) * m41)) - ((m13 * m21) * m42)) + ((m11 * m23) * m42)) + ((m12 * m21) * m43)) - ((m11 * m22) * m43)) / _local1), ((((((((-(m13) * m22) * m31) + ((m12 * m23) * m31)) + ((m13 * m21) * m32)) - ((m11 * m23) * m32)) - ((m12 * m21) * m33)) + ((m11 * m22) * m33)) / _local1)));
}
public function toString():String{
return (((((((((((((((((((((((((((((((((((("[[\t" + m11) + "\t") + m12) + "\t") + m13) + "\t") + m14) + "\t]\n") + " [\t") + m21) + "\t") + m22) + "\t") + m23) + "\t") + m24) + "\t]\n") + " [\t") + m31) + "\t") + m32) + "\t") + m33) + "\t") + m34) + "\t]\n") + " [\t") + m41) + "\t") + m42) + "\t") + m43) + "\t") + m44) + "\t]]\n"));
}
public static function get identity():Matrix4x4{
return (identityMat.clone());
}
public static function fromArray(_arg1:Array):Matrix4x4{
return (new Matrix4x4(_arg1[1][1], _arg1[1][2], _arg1[1][3], _arg1[1][4], _arg1[2][1], _arg1[2][2], _arg1[2][3], _arg1[2][4], _arg1[3][1], _arg1[3][2], _arg1[3][3], _arg1[3][4], _arg1[4][1], _arg1[4][2], _arg1[4][3], _arg1[4][4]));
}
}
}//package mwelsh.math
Section 38
//Vector (mwelsh.math.Vector)
package mwelsh.math {
public class Vector {
public var w:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public function Vector(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=1){
x = _arg1;
y = _arg2;
z = _arg3;
w = _arg4;
}
public function length():Number{
return (Math.sqrt((((x * x) + (y * y)) + (z * z))));
}
public function length2():Number{
return ((((x * x) + (y * y)) + (z * z)));
}
public function normalize():void{
var _local1:Number;
_local1 = length();
x = (x / _local1);
y = (y / _local1);
z = (z / _local1);
}
public function transform(_arg1:Matrix4x4):Vector{
return (new Vector(((((_arg1.m11 * x) + (_arg1.m12 * y)) + (_arg1.m13 * z)) + (_arg1.m14 * w)), ((((_arg1.m21 * x) + (_arg1.m22 * y)) + (_arg1.m23 * z)) + (_arg1.m24 * w)), ((((_arg1.m31 * x) + (_arg1.m32 * y)) + (_arg1.m33 * z)) + (_arg1.m34 * w)), ((((_arg1.m41 * x) + (_arg1.m42 * y)) + (_arg1.m43 * z)) + (_arg1.m44 * w))));
}
public function clone():Vector{
return (new Vector(x, y, z, w));
}
public static function sub(_arg1:Vector, _arg2:Vector):Vector{
return (new Vector((_arg1.x - _arg2.x), (_arg1.y - _arg2.y), (_arg1.z - _arg2.z)));
}
public static function add(_arg1:Vector, _arg2:Vector):Vector{
return (new Vector((_arg1.x + _arg2.x), (_arg1.y + _arg2.y), (_arg1.z + _arg2.z)));
}
public static function dot(_arg1:Vector, _arg2:Vector):Number{
return ((((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)) + (_arg1.z * _arg2.z)));
}
public static function scale(_arg1:Number, _arg2:Vector):Vector{
return (new Vector((_arg1 * _arg2.x), (_arg1 * _arg2.y), (_arg1 * _arg2.z)));
}
public static function cross(_arg1:Vector, _arg2:Vector):Vector{
return (new Vector(((_arg1.y * _arg2.z) - (_arg1.z * _arg2.y)), ((_arg1.z * _arg2.x) - (_arg1.x * _arg2.z)), ((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x))));
}
}
}//package mwelsh.math
Section 39
//Object3D (mwelsh.thunder3d.geom3d.Object3D)
package mwelsh.thunder3d.geom3d {
import mwelsh.math.*;
public class Object3D {
public var verts:Array;
public var scale:Vector;
public var backfaceCulling:Boolean;// = true
public var polys:Array;
public var rot:Vector;
public var worldTransform:Matrix4x4;
public var pos:Vector;
public function Object3D():void{
var _local1:uint;
backfaceCulling = true;
super();
verts = [];
polys = [];
pos = new Vector();
scale = new Vector(1, 1, 1);
rot = new Vector();
}
public function transformVerts(_arg1:Matrix4x4):void{
var _local2:uint;
var _local3:uint;
var _local4:Vertex;
_local2 = verts.length;
_local3 = 0;
while (_local3 < _local2) {
_local4 = verts[_local3];
_local4.tPos = new Vector(((((_arg1.m11 * _local4.tPos.x) + (_arg1.m12 * _local4.tPos.y)) + (_arg1.m13 * _local4.tPos.z)) + (_arg1.m14 * _local4.tPos.w)), ((((_arg1.m21 * _local4.tPos.x) + (_arg1.m22 * _local4.tPos.y)) + (_arg1.m23 * _local4.tPos.z)) + (_arg1.m24 * _local4.tPos.w)), ((((_arg1.m31 * _local4.tPos.x) + (_arg1.m32 * _local4.tPos.y)) + (_arg1.m33 * _local4.tPos.z)) + (_arg1.m34 * _local4.tPos.w)), ((((_arg1.m41 * _local4.tPos.x) + (_arg1.m42 * _local4.tPos.y)) + (_arg1.m43 * _local4.tPos.z)) + (_arg1.m44 * _local4.tPos.w)));
_local3++;
};
}
public function get numPolys():uint{
return (polys.length);
}
public function transformInitialVerts(_arg1:Matrix4x4):void{
var _local2:uint;
var _local3:uint;
var _local4:Vertex;
_local2 = verts.length;
_local3 = 0;
while (_local3 < _local2) {
_local4 = verts[_local3];
_local4.tPos.x = ((((_arg1.m11 * _local4.pos.x) + (_arg1.m12 * _local4.pos.y)) + (_arg1.m13 * _local4.pos.z)) + (_arg1.m14 * _local4.pos.w));
_local4.tPos.y = ((((_arg1.m21 * _local4.pos.x) + (_arg1.m22 * _local4.pos.y)) + (_arg1.m23 * _local4.pos.z)) + (_arg1.m24 * _local4.pos.w));
_local4.tPos.z = ((((_arg1.m31 * _local4.pos.x) + (_arg1.m32 * _local4.pos.y)) + (_arg1.m33 * _local4.pos.z)) + (_arg1.m34 * _local4.pos.w));
_local4.tPos.w = ((((_arg1.m41 * _local4.pos.x) + (_arg1.m42 * _local4.pos.y)) + (_arg1.m43 * _local4.pos.z)) + (_arg1.m44 * _local4.pos.w));
_local3++;
};
}
public function get numVerts():uint{
return (verts.length);
}
public function tick(_arg1:Number):void{
calcTransformMatrix();
}
public function calcTransformMatrix():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local1 = Math.cos(rot.x);
_local2 = Math.cos(rot.y);
_local3 = Math.cos(rot.z);
_local4 = Math.sin(rot.x);
_local5 = Math.sin(rot.y);
_local6 = Math.sin(rot.z);
worldTransform = new Matrix4x4(((scale.x * _local3) * _local2), ((-(scale.y) * _local6) * _local2), (scale.z * _local5), pos.x, (scale.x * (((_local3 * _local5) * _local4) + (_local6 * _local1))), (scale.y * ((_local3 * _local1) - ((_local6 * _local5) * _local4))), ((-(scale.z) * _local2) * _local4), pos.y, (scale.x * ((_local6 * _local4) - ((_local3 * _local5) * _local1))), (scale.y * (((_local6 * _local5) * _local1) + (_local4 * _local3))), ((scale.z * _local2) * _local1), pos.z, 0, 0, 0, 1);
}
}
}//package mwelsh.thunder3d.geom3d
Section 40
//Polygon (mwelsh.thunder3d.geom3d.Polygon)
package mwelsh.thunder3d.geom3d {
import mwelsh.math.*;
public class Polygon {
private const LEFT:uint = 0;
private const NEAR:uint = 4;
private const BOTTOM:uint = 3;
private const TOP:uint = 2;
private const FAR:uint = 5;
private const RIGHT:uint = 1;
public var lineColor:uint;
public var lineThickness:uint;
public var verts:Array;
public var cverts:Array;
public var fillColor:uint;
public function Polygon(_arg1:Array):void{
lineColor = 0xFFFFFF;
if (_arg1){
this.verts = _arg1;
} else {
this.verts = new Array();
};
}
public function get v2():Vertex{
return (verts[2]);
}
public function set v3(_arg1:Vertex):void{
verts[3] = _arg1;
}
public function get numVerts():uint{
return (verts.length);
}
private function intersect(_arg1:Vector, _arg2:Vector, _arg3:uint):Number{
var _local4:Number;
switch (_arg3){
case LEFT:
_local4 = ((-(_arg1.w) - _arg1.x) / (((_arg2.x - _arg1.x) + _arg2.w) - _arg1.w));
break;
case RIGHT:
_local4 = ((_arg1.w - _arg1.x) / (((_arg2.x - _arg1.x) - _arg2.w) + _arg1.w));
break;
case BOTTOM:
_local4 = ((-(_arg1.w) - _arg1.y) / (((_arg2.y - _arg1.y) + _arg2.w) - _arg1.w));
break;
case TOP:
_local4 = ((_arg1.w - _arg1.y) / (((_arg2.y - _arg1.y) - _arg2.w) + _arg1.w));
break;
case NEAR:
_local4 = ((-(_arg1.w) - _arg1.z) / (((_arg2.z - _arg1.z) + _arg2.w) - _arg1.w));
break;
case FAR:
_local4 = ((_arg1.w - _arg1.z) / (((_arg2.z - _arg1.z) - _arg2.w) + _arg1.w));
break;
};
return (_local4);
}
public function get z():Number{
var _local1:uint;
var _local2:Number;
var _local3:uint;
_local1 = verts.length;
_local2 = 0;
_local3 = 0;
while (_local3 < _local1) {
_local2 = (_local2 + Vertex(verts[_local3]).tPos.z);
_local3++;
};
return ((_local2 / _local1));
}
public function get normal():Vector{
var _local1:Vector;
_local1 = Vector.cross(Vector.sub(Vertex(verts[1]).tPos, Vertex(verts[0]).tPos), Vector.sub(Vertex(verts[(verts.length - 1)]).tPos, Vertex(verts[0]).tPos));
_local1.normalize();
return (_local1);
}
public function clip():Array{
var _local1:Array;
var _local2:uint;
var _local3:uint;
_local1 = clipToPlane(TOP, verts);
_local1 = clipToPlane(BOTTOM, _local1);
_local1 = clipToPlane(LEFT, _local1);
_local1 = clipToPlane(RIGHT, _local1);
_local1 = clipToPlane(NEAR, _local1);
_local1 = clipToPlane(FAR, _local1);
cverts = _local1;
_local1 = [];
_local2 = cverts.length;
_local3 = 0;
while (_local3 < _local2) {
if (Vertex(cverts[_local3]).clipped){
_local1.push(cverts[_local3]);
};
_local3++;
};
return (_local1);
}
public function clone():Polygon{
return (new Polygon(verts.concat()));
}
private function inside(_arg1:Vector, _arg2:uint):Boolean{
switch (_arg2){
case LEFT:
return ((_arg1.x >= -(_arg1.w)));
case RIGHT:
return ((_arg1.x <= _arg1.w));
case BOTTOM:
return ((_arg1.y >= -(_arg1.w)));
case TOP:
return ((_arg1.y <= _arg1.w));
case NEAR:
return ((_arg1.z >= -(_arg1.w)));
case FAR:
return ((_arg1.z <= _arg1.w));
};
return (false);
}
private function clipToPlane(_arg1:uint, _arg2:Array):Array{
var _local3:Vertex;
var _local4:Vertex;
var _local5:uint;
var _local6:uint;
var _local7:Vertex;
var _local8:Boolean;
var _local9:Boolean;
var _local10:Array;
var _local11:Number;
if ((((_arg2 == null)) || ((_arg2.length < 1)))){
return ([]);
};
_local6 = _arg2.length;
_local10 = [];
_local3 = _arg2[(_local6 - 1)];
_local8 = inside(_local3.tPos, _arg1);
if (numVerts == 2){
if (_local8){
_local10.push(_local3);
};
_local6 = 1;
};
_local5 = 0;
while (_local5 < _local6) {
_local4 = _arg2[_local5];
_local9 = inside(_local4.tPos, _arg1);
if (_local8 != _local9){
_local7 = new Vertex(new Vector(), _local4.color);
_local10.push(_local7);
_local11 = intersect(_local3.tPos, _local4.tPos, _arg1);
_local7.tPos = Vector.add(_local3.tPos, Vector.scale(_local11, Vector.sub(_local4.tPos, _local3.tPos)));
_local7.tPos.w = (_local3.tPos.w + (_local11 * (_local4.tPos.w - _local3.tPos.w)));
_local7.tColor = Vector.add(_local3.tColor, Vector.scale(_local11, Vector.sub(_local4.tColor, _local3.tColor)));
if (((((_local7.norm.x) || (_local7.norm.y))) || (_local7.norm.z))){
_local7.norm = Vector.add(_local3.norm, Vector.scale(_local11, Vector.sub(_local4.norm, _local3.norm)));
};
_local7.clipped = true;
};
if (_local9){
_local10.push(_local4);
};
_local3 = _local4;
_local8 = _local9;
_local5++;
};
return (_local10);
}
public function set v0(_arg1:Vertex):void{
verts[0] = _arg1;
}
public function set v1(_arg1:Vertex):void{
verts[1] = _arg1;
}
public function get v0():Vertex{
return (verts[0]);
}
public function get v1():Vertex{
return (verts[1]);
}
public function get v3():Vertex{
return (verts[3]);
}
public function set v2(_arg1:Vertex):void{
verts[2] = _arg1;
}
}
}//package mwelsh.thunder3d.geom3d
Section 41
//Vertex (mwelsh.thunder3d.geom3d.Vertex)
package mwelsh.thunder3d.geom3d {
import mwelsh.math.*;
public class Vertex {
public var tPos:Vector;
public var color:Vector;
public var numPolys:uint;
public var pos:Vector;
public var tColor:Vector;
public var norm:Vector;
public var clipped:Boolean;
public function Vertex(_arg1:Vector=null, _arg2:Vector=null, _arg3:Vector=null):void{
clipped = false;
if (_arg1){
this.pos = _arg1;
} else {
this.pos = new Vector();
};
if (_arg2){
this.color = _arg2;
} else {
this.color = new Vector();
};
if (norm){
this.norm = norm;
} else {
this.norm = new Vector();
};
tPos = new Vector();
tColor = new Vector();
}
public function copy(_arg1:Vertex):void{
pos = _arg1.pos.clone();
color = _arg1.color.clone();
norm = _arg1.norm.clone();
}
public function clone():Vertex{
return (new Vertex(pos.clone(), color.clone(), norm.clone()));
}
}
}//package mwelsh.thunder3d.geom3d
Section 42
//RasterRenderer (mwelsh.thunder3d.RasterRenderer)
package mwelsh.thunder3d {
import flash.display.*;
import flash.geom.*;
import mwelsh.thunder3d.geom3d.*;
import flash.utils.*;
public class RasterRenderer extends Renderer {
private var steppedX:Number;
private var midY:int;
private var pixels:ByteArray;
private var zBuffer:Array;
private var gradB:Number;
private var gradG:Number;
private var gradL:Number;
private var minY:int;
private var gradV:Number;
private var gradW:Number;
private var gradR:Number;
private var gradZ:Number;
private var gradU:Number;
private var spans:Array;
private var prestep:Number;
private var screenRect:Rectangle;
private var maxY:int;
private var zBufShift:uint;
public function RasterRenderer(_arg1:uint=320, _arg2:uint=240){
super(_arg1, _arg2);
shading = SHADING_GOURAUD;
}
private function generateSpans(_arg1:Vertex, _arg2:Vertex, _arg3:Vertex):void{
var _local4:Vertex;
var _local5:Number;
var _local6:uint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Span;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:int;
var _local39:int;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
if (_arg3.tPos.y < _arg2.tPos.y){
_local4 = _arg3;
_arg3 = _arg2;
_arg2 = _local4;
};
if (_arg2.tPos.y < _arg1.tPos.y){
_local4 = _arg2;
_arg2 = _arg1;
_arg1 = _local4;
};
if (_arg3.tPos.y < _arg2.tPos.y){
_local4 = _arg3;
_arg3 = _arg2;
_arg2 = _local4;
};
_local16 = (1 / (_arg2.tPos.y - _arg1.tPos.y));
_local17 = (1 / (_arg3.tPos.y - _arg2.tPos.y));
_local18 = (1 / (_arg3.tPos.y - _arg1.tPos.y));
_local19 = _arg1.tPos.x;
_local20 = ((_arg2.tPos.x - _arg1.tPos.x) * _local16);
_local21 = ((_arg3.tPos.x - _arg2.tPos.x) * _local17);
_local22 = ((_arg3.tPos.x - _arg1.tPos.x) * _local18);
_local23 = ((_arg2.tPos.w - _arg1.tPos.w) * _local16);
_local24 = ((_arg3.tPos.w - _arg2.tPos.w) * _local17);
_local25 = ((_arg3.tPos.w - _arg1.tPos.w) * _local18);
_local26 = ((_arg2.tPos.z - _arg1.tPos.z) * _local16);
_local27 = ((_arg3.tPos.z - _arg2.tPos.z) * _local17);
_local28 = ((_arg3.tPos.z - _arg1.tPos.z) * _local18);
_local29 = ((_arg2.tColor.x - _arg1.tColor.x) * _local16);
_local30 = ((_arg3.tColor.x - _arg2.tColor.x) * _local17);
_local31 = ((_arg3.tColor.x - _arg1.tColor.x) * _local18);
_local32 = ((_arg2.tColor.y - _arg1.tColor.y) * _local16);
_local33 = ((_arg3.tColor.y - _arg2.tColor.y) * _local17);
_local34 = ((_arg3.tColor.y - _arg1.tColor.y) * _local18);
_local35 = ((_arg2.tColor.z - _arg1.tColor.z) * _local16);
_local36 = ((_arg3.tColor.z - _arg2.tColor.z) * _local17);
_local37 = ((_arg3.tColor.z - _arg1.tColor.z) * _local18);
if (_arg1.tPos.x != _arg3.tPos.x){
_local42 = _local22;
_local43 = (_arg1.tPos.y - (_arg1.tPos.x / _local42));
_local19 = ((_arg2.tPos.y - _local43) * _local42);
};
minY = Math.ceil(_arg1.tPos.y);
midY = Math.ceil(_arg2.tPos.y);
maxY = (Math.ceil(_arg3.tPos.y) - 1);
if (_arg2.tPos.x < _local19){
_local40 = (1 / (_local19 - _arg2.tPos.x));
_local41 = (_arg2.tPos.y - _arg1.tPos.y);
gradW = ((((_local25 * _local41) + _arg1.tPos.w) - _arg2.tPos.w) * _local40);
gradR = ((((_local31 * _local41) + _arg1.tColor.x) - _arg2.tColor.x) * _local40);
gradG = ((((_local34 * _local41) + _arg1.tColor.y) - _arg2.tColor.y) * _local40);
gradB = ((((_local37 * _local41) + _arg1.tColor.z) - _arg2.tColor.z) * _local40);
_local38 = minY;
_local39 = (midY - 1);
prestep = (_local38 - _arg1.tPos.y);
_local5 = (_arg1.tPos.x + (prestep * _local20));
_local10 = (_arg1.tPos.w + (prestep * _local23));
_local12 = (_arg1.tColor.x + (prestep * _local29));
_local13 = (_arg1.tColor.y + (prestep * _local32));
_local14 = (_arg1.tColor.z + (prestep * _local35));
_local6 = _local38;
while (_local6 <= _local39) {
_local15 = spans[_local6];
_local15.xLeft = Math.ceil(_local5);
_local15.wLeft = _local10;
_local15.zInvLeft = _local11;
_local15.rLeft = _local12;
_local15.gLeft = _local13;
_local15.bLeft = _local14;
_local6++;
_local5 = (_local5 + _local20);
_local10 = (_local10 + _local23);
_local12 = (_local12 + _local29);
_local13 = (_local13 + _local32);
_local14 = (_local14 + _local35);
};
_local38 = midY;
_local39 = maxY;
prestep = (_local38 - _arg2.tPos.y);
_local5 = (_arg2.tPos.x + (prestep * _local21));
_local10 = (_arg2.tPos.w + (prestep * _local24));
_local12 = (_arg2.tColor.x + (prestep * _local30));
_local13 = (_arg2.tColor.y + (prestep * _local33));
_local14 = (_arg2.tColor.z + (prestep * _local36));
_local6 = _local38;
while (_local6 <= _local39) {
_local15 = spans[_local6];
_local15.xLeft = Math.ceil(_local5);
_local15.lLeft = _local7;
_local15.wLeft = _local10;
_local15.zInvLeft = _local11;
_local15.rLeft = _local12;
_local15.gLeft = _local13;
_local15.bLeft = _local14;
_local6++;
_local5 = (_local5 + _local21);
_local10 = (_local10 + _local24);
_local11 = (_local11 + _local27);
_local12 = (_local12 + _local30);
_local13 = (_local13 + _local33);
_local14 = (_local14 + _local36);
};
_local38 = minY;
prestep = (_local38 - _arg1.tPos.y);
_local5 = (_arg1.tPos.x + (prestep * _local22));
_local6 = _local38;
while (_local6 <= _local39) {
_local15 = spans[_local6];
_local15.xRight = (Math.ceil(_local5) - 1);
_local6++;
_local5 = (_local5 + _local22);
};
} else {
_local40 = (1 / (_arg2.tPos.x - _local19));
_local41 = (_arg2.tPos.y - _arg1.tPos.y);
gradW = (((_arg2.tPos.w - (_local25 * _local41)) - _arg1.tPos.w) * _local40);
gradR = (((_arg2.tColor.x - (_local31 * _local41)) - _arg1.tColor.x) * _local40);
gradG = (((_arg2.tColor.y - (_local34 * _local41)) - _arg1.tColor.y) * _local40);
gradB = (((_arg2.tColor.z - (_local37 * _local41)) - _arg1.tColor.z) * _local40);
_local38 = minY;
_local39 = maxY;
prestep = (_local38 - _arg1.tPos.y);
_local5 = (_arg1.tPos.x + (prestep * _local22));
_local10 = (_arg1.tPos.w + (prestep * _local25));
_local12 = (_arg1.tColor.x + (prestep * _local31));
_local13 = (_arg1.tColor.y + (prestep * _local34));
_local14 = (_arg1.tColor.z + (prestep * _local37));
_local6 = _local38;
while (_local6 <= _local39) {
_local15 = spans[_local6];
_local15.xLeft = Math.ceil(_local5);
_local15.lLeft = _local7;
_local15.wLeft = _local10;
_local15.zInvLeft = _local11;
_local15.rLeft = _local12;
_local15.gLeft = _local13;
_local15.bLeft = _local14;
_local6++;
_local5 = (_local5 + _local22);
_local10 = (_local10 + _local25);
_local11 = (_local11 + _local28);
_local12 = (_local12 + _local31);
_local13 = (_local13 + _local34);
_local14 = (_local14 + _local37);
};
_local39 = (midY - 1);
_local5 = (_arg1.tPos.x + (prestep * _local20));
_local6 = _local38;
while (_local6 <= _local39) {
_local15 = spans[_local6];
_local15.xRight = (Math.ceil(_local5) - 1);
_local6++;
_local5 = (_local5 + _local20);
};
_local38 = midY;
_local39 = maxY;
prestep = (_local38 - _arg2.tPos.y);
_local5 = (_arg2.tPos.x + (prestep * _local21));
_local6 = _local38;
while (_local6 <= _local39) {
_local15 = spans[_local6];
_local15.xRight = (Math.ceil(_local5) - 1);
_local6++;
_local5 = (_local5 + _local21);
};
};
}
override protected function createWindow():void{
var _local1:uint;
var _local2:uint;
super.createWindow();
spans = new Array(screenHeight);
_local1 = 0;
while (_local1 < screenHeight) {
spans[_local1] = new Span();
_local1++;
};
zBuffer = new Array(sWsH);
zBuffer = new Array(screenWidth);
_local1 = 0;
while (_local1 < screenWidth) {
zBuffer[_local1] = new Array();
_local2 = 0;
while (_local2 < screenHeight) {
zBuffer[_local1][_local2] = 999;
_local2++;
};
_local1++;
};
zBufShift = 0;
screenRect = new Rectangle(0, 0, screenWidth, screenHeight);
}
override public function render(_arg1:BitmapData):void{
var _local2:uint;
var _local3:uint;
var _local4:Number;
var _local5:uint;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Span;
var _local11:uint;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Vertex;
var _local17:Vertex;
var _local18:Vertex;
var _local19:uint;
var _local20:Polygon;
polys.sort(sortPolys);
_arg1.lock();
for each (_local20 in polys) {
_local19 = 0;
while (_local19 < (_local20.cverts.length - 2)) {
_local16 = _local20.cverts[0];
_local17 = _local20.cverts[(_local19 + 1)];
_local18 = _local20.cverts[(_local19 + 2)];
generateSpans(_local16, _local17, _local18);
_local3 = minY;
while (_local3 <= maxY) {
_local10 = spans[_local3];
_local2 = _local10.xLeft;
_local7 = _local10.wLeft;
_local8 = _local10.uLeft;
_local9 = _local10.vLeft;
_local13 = _local10.rLeft;
_local14 = _local10.gLeft;
_local15 = _local10.bLeft;
_local4 = _local10.zInvLeft;
while (_local2 <= _local10.xRight) {
_arg1.setPixel(_local2, _local3, (((uint(_local13) << 16) | (uint(_local14) << 8)) | uint(_local15)));
_local2++;
_local7 = (_local7 + gradW);
_local8 = (_local8 + gradU);
_local9 = (_local9 + gradV);
_local4 = (_local4 + gradZ);
_local13 = (_local13 + gradR);
_local14 = (_local14 + gradG);
_local15 = (_local15 + gradB);
};
_local3++;
};
_local19++;
};
};
_arg1.unlock();
}
override public function clearScreen(_arg1:BitmapData, _arg2:uint=4278190080):void{
_arg1.fillRect(screenRect, _arg2);
}
}
}//package mwelsh.thunder3d
Section 43
//Renderer (mwelsh.thunder3d.Renderer)
package mwelsh.thunder3d {
import flash.display.*;
import mwelsh.math.*;
import mwelsh.thunder3d.geom3d.*;
public class Renderer {
public var camPos:Vector;
public var camRot:Vector;
protected var projection:Matrix4x4;
public var drawObj:Function;
public var camLook:Vector;
protected var shadingMode:uint;
public var up:Vector;
public var lightPos:Vector;
protected var verts:Array;
protected var polys:Array;
protected var screenHeight:uint;
protected var sWsH:uint;
protected var screenWidth:uint;
public static const SHADING_GOURAUD:uint = 2;
public static const SHADING_NONE:uint = 0;
public static const SHADING_FLAT:uint = 1;
public function Renderer(_arg1:uint=320, _arg2:uint=240){
screenWidth = _arg1;
screenHeight = _arg2;
buildProjectionMatrix(1, (screenWidth / screenHeight));
createWindow();
camPos = new Vector(0, 0, 5);
camRot = new Vector();
up = new Vector(0, 1, 0);
lightPos = new Vector(1, 1, 5);
polys = [];
verts = [];
shading = SHADING_FLAT;
}
public function drawObjFlatShading(_arg1:Array):void{
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:Polygon;
var _local6:Vector;
var _local7:Number;
var _local8:Vector;
var _local9:uint;
var _local10:Matrix4x4;
var _local11:Object3D;
var _local12:Vertex;
polys = [];
verts = [];
_local10 = createCamTransformMatrix();
for each (_local11 in _arg1) {
_local11.transformInitialVerts(_local11.worldTransform);
_local4 = _local11.polys.length;
_local2 = 0;
while (_local2 < _local4) {
_local5 = _local11.polys[_local2];
if (_local5.numVerts < 3){
polys.push(_local5);
} else {
_local6 = _local5.normal;
if (((!(_local11.backfaceCulling)) || ((Vector.dot(_local6, Vector.sub(camPos, _local5.v0.tPos)) > 0)))){
_local8 = Vector.sub(lightPos, _local5.verts[_local3].tPos);
_local8.normalize();
_local7 = (Math.abs(Vector.dot(_local8, _local6)) * 0xFF);
_local5.fillColor = (((uint((_local7 * _local5.v0.color.x)) << 16) | (uint((_local7 * _local5.v0.color.y)) << 8)) | uint((_local7 * _local5.v0.color.z)));
polys.push(_local5);
};
};
_local2++;
};
_local4 = polys.length;
_local11.transformVerts(_local10);
_local2 = 0;
while (_local2 < _local4) {
verts = verts.concat(Polygon(polys[_local2]).clip());
_local2++;
};
};
_local4 = verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local12 = verts[_local2];
_local12.tPos.w = (1 / _local12.tPos.w);
_local12.tPos.z = (_local12.tPos.z * _local12.tPos.w);
_local12.tPos.x = ((screenWidth / 2) * ((_local12.tPos.x * _local12.tPos.w) + 1));
_local12.tPos.y = ((screenHeight / 2) * (1 - (_local12.tPos.y * _local12.tPos.w)));
_local2++;
};
for each (_local11 in _arg1) {
_local4 = _local11.verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local12 = _local11.verts[_local2];
_local12.tPos.w = (1 / _local12.tPos.w);
_local12.tPos.z = (_local12.tPos.z * _local12.tPos.w);
_local12.tPos.x = ((screenWidth / 2) * ((_local12.tPos.x * _local12.tPos.w) + 1));
_local12.tPos.y = ((screenHeight / 2) * (1 - (_local12.tPos.y * _local12.tPos.w)));
_local2++;
};
};
}
protected function createWindow():void{
sWsH = (screenWidth * screenHeight);
}
public function drawObjGouraudShading(_arg1:Array):void{
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:Polygon;
var _local6:Vector;
var _local7:Vertex;
var _local8:Number;
var _local9:Vector;
var _local10:uint;
var _local11:Matrix4x4;
var _local12:Object3D;
polys = [];
verts = [];
_local11 = createCamTransformMatrix();
for each (_local12 in _arg1) {
_local12.transformInitialVerts(_local12.worldTransform);
_local4 = _local12.verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local7 = _local12.verts[_local2];
_local7.norm.x = 0;
_local7.norm.y = 0;
_local7.norm.z = 0;
_local7.numPolys = 0;
_local2++;
};
_local4 = _local12.polys.length;
_local2 = 0;
while (_local2 < _local4) {
_local5 = _local12.polys[_local2];
if (_local5.numVerts < 3){
polys.push(_local5);
} else {
_local6 = _local5.normal;
if (((!(_local12.backfaceCulling)) || ((Vector.dot(_local6, Vector.sub(camPos, _local5.v0.tPos)) > 0)))){
_local10 = _local5.numVerts;
_local3 = 0;
while (_local3 < _local10) {
_local7 = _local5.verts[_local3];
_local7.norm = Vector.add(_local7.norm, _local6);
_local7.numPolys++;
_local3++;
};
polys.push(_local5);
};
};
_local2++;
};
_local4 = _local12.verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local7 = _local12.verts[_local2];
_local7.norm = Vector.scale((1 / _local7.numPolys), _local7.norm);
_local9 = Vector.sub(lightPos, _local7.tPos);
_local9.normalize();
_local8 = (Math.abs(Vector.dot(_local9, _local7.norm)) * 0xFF);
_local7.tColor = Vector.scale(_local8, _local7.color);
_local2++;
};
_local12.transformVerts(_local11);
_local4 = polys.length;
_local2 = 0;
while (_local2 < _local4) {
verts = verts.concat(Polygon(polys[_local2]).clip());
_local2++;
};
};
_local4 = verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local7 = verts[_local2];
_local7.tPos.w = (1 / _local7.tPos.w);
_local7.tPos.z = (_local7.tPos.z * _local7.tPos.w);
_local7.tPos.x = (((screenWidth - 1) / 2) * ((_local7.tPos.x * _local7.tPos.w) + 1));
_local7.tPos.y = (((screenHeight - 1) / 2) * (1 - (_local7.tPos.y * _local7.tPos.w)));
_local2++;
};
for each (_local12 in _arg1) {
_local4 = _local12.verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local7 = _local12.verts[_local2];
_local7.tPos.w = (1 / _local7.tPos.w);
_local7.tPos.z = (_local7.tPos.z * _local7.tPos.w);
_local7.tPos.x = (((screenWidth - 1) / 2) * ((_local7.tPos.x * _local7.tPos.w) + 1));
_local7.tPos.y = (((screenHeight - 1) / 2) * (1 - (_local7.tPos.y * _local7.tPos.w)));
_local2++;
};
};
}
public function set shading(_arg1:uint):void{
shadingMode = _arg1;
if (shadingMode == SHADING_NONE){
drawObj = drawObjNoShading;
} else {
if (shadingMode == SHADING_FLAT){
drawObj = drawObjFlatShading;
} else {
drawObj = drawObjGouraudShading;
};
};
}
public function clearScreen(_arg1:BitmapData, _arg2:uint=4278190080):void{
_arg1.fillRect(_arg1.rect, _arg2);
}
public function render(_arg1:BitmapData):void{
var _local2:uint;
var _local3:uint;
var _local4:Polygon;
_local3 = polys.length;
_local2 = 0;
while (_local2 < _local3) {
_local4 = polys[_local2];
_local2++;
};
}
public function createCamTransformMatrix():Matrix4x4{
var _local1:Matrix4x4;
var _local2:Vector;
var _local3:Vector;
var _local4:Vector;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Matrix4x4;
var _local12:Matrix4x4;
var _local13:Matrix4x4;
if (camLook){
_local2 = Vector.sub(camPos, camLook);
_local2.normalize();
_local3 = Vector.cross(_local2, up);
_local4 = Vector.cross(_local3, _local2);
_local1 = new Matrix4x4(_local3.x, _local4.x, _local2.x, camPos.x, _local3.y, _local4.y, _local2.y, camPos.y, _local3.z, _local4.z, _local2.z, camPos.z, 0, 0, 0, 1);
_local1 = _local1.inverse();
} else {
_local5 = Math.cos(camRot.x);
_local6 = Math.sin(camRot.x);
_local7 = Math.cos(camRot.y);
_local8 = Math.sin(camRot.y);
_local9 = Math.cos(camRot.z);
_local10 = Math.sin(camRot.z);
_local11 = new Matrix4x4(1, 0, 0, -(camPos.x), 0, _local5, _local6, ((-(camPos.y) * _local5) - (camPos.z * _local6)), 0, -(_local6), _local5, ((camPos.y * _local6) - (camPos.z * _local5)), 0, 0, 0, 1);
_local12 = new Matrix4x4(_local7, 0, -(_local8), 0, 0, 1, 0, 0, _local8, 0, _local7, 0, 0, 0, 0, 1);
_local13 = new Matrix4x4(_local9, _local10, 0, 0, -(_local10), _local9, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
_local1 = _local13.multiply(_local12.multiply(_local11));
};
return (projection.multiply(_local1));
}
public function get shading():uint{
return (shadingMode);
}
public function drawObjNoShading(_arg1:Array):void{
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:Polygon;
var _local6:Vector;
var _local7:Number;
var _local8:Vector;
var _local9:uint;
var _local10:Matrix4x4;
var _local11:Object3D;
var _local12:Vertex;
polys = [];
verts = [];
_local10 = createCamTransformMatrix();
for each (_local11 in _arg1) {
_local11.transformInitialVerts(_local11.worldTransform);
_local4 = _local11.polys.length;
_local2 = 0;
while (_local2 < _local4) {
_local5 = _local11.polys[_local2];
if (_local5.numVerts < 3){
polys.push(_local5);
} else {
_local6 = _local5.normal;
if (((!(_local11.backfaceCulling)) || ((Vector.dot(_local6, Vector.sub(camPos, _local5.v0.tPos)) > 0)))){
_local5.fillColor = (((uint(_local5.v0.color.x) << 16) | (uint(_local5.v0.color.y) << 8)) | uint(_local5.v0.color.z));
polys.push(_local5);
};
};
_local2++;
};
_local4 = polys.length;
_local11.transformVerts(_local10);
_local2 = 0;
while (_local2 < _local4) {
verts = verts.concat(Polygon(polys[_local2]).clip());
_local2++;
};
};
_local4 = verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local12 = verts[_local2];
_local12.tPos.w = (1 / _local12.tPos.w);
_local12.tPos.z = (_local12.tPos.z * _local12.tPos.w);
_local12.tPos.x = ((screenWidth / 2) * ((_local12.tPos.x * _local12.tPos.w) + 1));
_local12.tPos.y = ((screenHeight / 2) * (1 - (_local12.tPos.y * _local12.tPos.w)));
_local2++;
};
for each (_local11 in _arg1) {
_local4 = _local11.verts.length;
_local2 = 0;
while (_local2 < _local4) {
_local12 = _local11.verts[_local2];
_local12.tPos.w = (1 / _local12.tPos.w);
_local12.tPos.z = (_local12.tPos.z * _local12.tPos.w);
_local12.tPos.x = ((screenWidth / 2) * ((_local12.tPos.x * _local12.tPos.w) + 1));
_local12.tPos.y = ((screenHeight / 2) * (1 - (_local12.tPos.y * _local12.tPos.w)));
_local2++;
};
};
}
protected function sortPolys(_arg1:Polygon, _arg2:Polygon):int{
var _local3:Number;
var _local4:Number;
_local3 = _arg1.z;
_local4 = _arg2.z;
if (_local3 < _local4){
return (1);
};
if (_local3 > _local4){
return (-1);
};
return (0);
}
private function buildProjectionMatrix(_arg1:Number, _arg2:Number, _arg3:Number=0.5, _arg4:Number=128):void{
projection = new Matrix4x4(_arg1, 0, 0, 0, 0, _arg2, 0, 0, 0, 0, ((_arg4 + _arg3) / (_arg3 - _arg4)), (((2 * _arg3) * _arg4) / (_arg3 - _arg4)), 0, 0, -1, 0);
}
}
}//package mwelsh.thunder3d
Section 44
//Span (mwelsh.thunder3d.Span)
package mwelsh.thunder3d {
public class Span {
public var y:uint;
public var xRight:int;
public var zInvRight:Number;
public var vRight:Number;
public var bLeft:Number;
public var gradR:Number;
public var uzLeft:Number;
public var zInvLeft:Number;
public var gLeft:Number;
public var lRight:Number;
public var lLeft:Number;
public var rLeft:Number;
public var vLeft:Number;
public var wLeft:Number;
public var xLeft:int;
public var uLeft:Number;
public var wRight:Number;
public var uRight:Number;
public var gradB:Number;
public var vzRight:Number;
public var gradG:Number;
public function Span():void{
xLeft = 999999;
xRight = 0;
}
}
}//package mwelsh.thunder3d
Section 45
//VectorRenderer (mwelsh.thunder3d.VectorRenderer)
package mwelsh.thunder3d {
import flash.display.*;
import mwelsh.thunder3d.geom3d.*;
public class VectorRenderer extends Renderer {
protected var vectors:Shape;
public function VectorRenderer(_arg1:uint=320, _arg2:uint=240){
super(_arg1, _arg2);
this.vectors = new Shape();
}
override public function render(_arg1:BitmapData):void{
var _local2:Graphics;
var _local3:uint;
var _local4:uint;
var _local5:uint;
var _local6:uint;
var _local7:Polygon;
var _local8:uint;
var _local9:uint;
polys.sort(sortPolys);
_local2 = vectors.graphics;
_local2.clear();
_local2.lineStyle(0, 0, 0);
_local3 = polys.length;
for each (_local7 in polys) {
if (!_local7.cverts){
return;
};
_local9 = _local7.cverts.length;
if (_local9 >= 3){
_local2.moveTo(Vertex(_local7.cverts[(_local9 - 1)]).tPos.x, Vertex(_local7.cverts[(_local9 - 1)]).tPos.y);
_local2.beginFill(_local7.fillColor);
_local8 = 0;
while (_local8 < _local9) {
_local2.lineTo(Vertex(_local7.cverts[_local8]).tPos.x, Vertex(_local7.cverts[_local8]).tPos.y);
_local8++;
};
_local2.endFill();
} else {
if (_local9 == 2){
_local2.lineStyle(1, (((uint((Vertex(_local7.verts[0]).color.x * 0xFF)) << 16) | (uint((Vertex(_local7.verts[0]).color.y * 0xFF)) << 8)) | uint((Vertex(_local7.verts[0]).color.z * 0xFF))));
_local2.moveTo(_local7.v0.tPos.x, _local7.v0.tPos.y);
_local2.lineTo(_local7.v1.tPos.x, _local7.v1.tPos.y);
} else {
if (_local9 == 1){
_local2.lineStyle(0, 0, 0);
_local2.beginFill((((uint((Vertex(_local7.cverts[0]).color.x * 0xFF)) << 16) | (uint((Vertex(_local7.cverts[0]).color.y * 0xFF)) << 8)) | uint((Vertex(_local7.cverts[0]).color.z * 0xFF))));
_local2.drawCircle(_local7.v0.tPos.x, _local7.v0.tPos.y, (_local7.v0.tPos.z + 1));
_local2.endFill();
};
};
};
};
_arg1.lock();
_arg1.draw(vectors);
_arg1.unlock();
polys = [];
}
}
}//package mwelsh.thunder3d
Section 46
//App (App)
package {
import flash.display.*;
public class App extends Sprite {
private static var m_Instance:App;
public function App():void{
m_Instance = this;
}
public static function getStage():Stage{
return (m_Instance.stage);
}
public static function getInstance():App{
return (m_Instance);
}
}
}//package
Section 47
//AudioViewPlayer (AudioViewPlayer)
package {
import mwelsh.audio.visualizer.visualizations.*;
import mwelsh.audio.*;
public class AudioViewPlayer extends App {
private var m_Audio:AudioPlayer;
public function AudioViewPlayer():void{
m_Audio = new AudioPlayer(AudioPlayer.MODE_AUDIOVIEW, [["AgnryFaic", "AgnryFaicVisualization"], ["Badger", "BadgerVisualization"], ["Corona", "CoronaVisualization"], ["Cyclotron", "CyclotronVisualization"], ["DietSoda", "DietCokeVisualization"], ["Hypno", "HypnoVisualization"], ["Lavaberry", "LavaberryVisualization"], ["Mobius", "MobiusStripVisualization"], ["NeonTide", "NeonTideVisualization"], ["Portal", "Portal3DVisualization"], ["Puddle", "Fountain3DVisualization"], ["Sauron", "SauronVisualization"], ["SimpleWave", "SimpleWaveVisualization"], ["Spectrum", "SimpleSpectrumVisualization"], ["SpinArt", "SpinArtVisualization"], ["Tank", "TankLogoVisualization"]]);
addChild(m_Audio);
}
private function dummy():void{
var _local1:Visualization;
_local1 = new AboutVisualization(1, 1);
_local1 = new AgnryFaicVisualization(1, 1);
_local1 = new BadgerVisualization(1, 1);
_local1 = new CoronaVisualization(1, 1);
_local1 = new CyclotronVisualization(1, 1);
_local1 = new DietCokeVisualization(1, 1);
_local1 = new Fountain3DVisualization(1, 1);
_local1 = new HypnoVisualization(1, 1);
_local1 = new SpinArtVisualization(1, 1);
_local1 = new LavaberryVisualization(1, 1);
_local1 = new MobiusStripVisualization(1, 1);
_local1 = new NeonTideVisualization(1, 1);
_local1 = new Portal3DVisualization(1, 1);
_local1 = new SauronVisualization(1, 1);
_local1 = new SimpleSpectrumVisualization(1, 1);
_local1 = new SimpleWaveVisualization(1, 1);
_local1 = new TankLogoVisualization(1, 1);
}
}
}//package