soundtest030 fp11
音を読み込んでないので、
youtubeやらニコ動やらを開いて~
iTunesとかは無理よ~
他のブラウザで開いてるのもだめよ~
/**
* Copyright gaina ( http://wonderfl.net/user/gaina )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/78hf
*/
// forked from gaina's soundtest023
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.GlowFilter;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundLoaderContext;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.utils.ByteArray;
public class Main extends Sprite
{
private var snd:Sound;
private var point_array:Array;
function Main()
{
point_array = points();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void {
var bytes:ByteArray = new ByteArray();
SoundMixer.computeSpectrum(bytes, false, 0);
Drawing(bytes, 512);
}
private function Drawing(_bytes:ByteArray = null, num:int = 512, count:int = 2):void
{
graphics.clear();
graphics.beginFill(0)
graphics.drawRect(0,0,465,465);
graphics.endFill();
graphics.lineStyle(1, 0xFFFFFF);
var d:Number = 0;
var n:uint;
var i:uint;
for (n = 0; n < count; n++) {
for (i = 0; i < num / count; i++) {
var p:PointPlus = point_array[n][i] as PointPlus;
var data:Number = _bytes.readFloat();
if (n == 0) {
p.vx = p.x * data ;
p.vy = p.y * data ;
}else {
p.vx = p.x * data * -1 ;
p.vy = p.y * data;
}
if (i == 0) {
graphics.moveTo(p.x, p.y);
}else {
graphics.curveTo(point_array[n][i-1].x, point_array[n][i-1].y, p.x + p.vx, p.y + p.vy);
}
d += data;
}
}
graphics.endFill();
}
private function points():Array
{
var container_array:Array = [];
var i:int;
var j:int;
for (i = 0; i < 2; i++) {
var _array:Array = [];
for (j = 0; j < 256; j++) {
var p:PointPlus = new PointPlus();
p.x = stage.stageWidth / 2;
p.y = j * stage.stageHeight / 256;
_array.push(p);
}
container_array.push(_array);
}
return container_array;
}
}
}
class PointPlus
{
public var x:int;
public var y:int;
public var vx:int;
public var vy:int;
public function PointPlus() {}
}