forked from: forked from: Sound Visualization sample 2(Wave plot)
♥0 |
Line 62 |
Modified 2016-04-22 23:33:35 |
MIT License
archived:2017-03-20 10:51:10
ActionScript3 source code
/**
* Copyright Antonio.Meneses ( http://wonderfl.net/user/Antonio.Meneses )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aVFON
*/
// forked from Robbie.Maglone's forked from: Sound Visualization sample 2(Wave plot)
// forked from J2kawa's Sound Visualization sample 2(Wave plot)
package {
//Via "learning Action Script 3.0"
//まだ超途中
//Loadしたmp3ファイルを再生して波形表示
import flash.display.*;
import flash.geom.Point;
import flash.net.*;
import flash.utils.*;
import flash.media.*;
import flash.events.*;
[SWF(width = "450", height = "450", backgroundColor=0xFFFFFF, frameRate="20")]
public class SoundWave extends Sprite {
private var sound:Sound = new Sound();
private var sch:SoundChannel = new SoundChannel();
private var waveView:Visualization;
private var mp3src:String = "http://caster.fnshosting.com:4155/live";
public function SoundWave() {
sound.addEventListener(Event.COMPLETE, onLoadComplete, false, 0, true);
var context:SoundLoaderContext = new SoundLoaderContext(5000, false);
sound.load(new URLRequest(mp3src), context);
}
private function onLoadComplete(evt:Event):void {
removeEventListener(Event.COMPLETE, onLoadComplete);
var waveObj:Object = new Object();
waveObj.waveHeight = 150;
waveObj.baseLine = 90;
waveObj.visLoc = new Point(20,0);
waveObj.visScale = 2;
waveObj.fft = false;
waveView = new Visualization( waveObj );
addChild( waveView );
waveView.stage.frameRate = 20;
}
}
}
import flash.display.*;
import flash.geom.Point;
import flash.media.SoundMixer;
import flash.utils.*;
import flash.events.*;
class Visualization extends Sprite{
private var timer:Timer;
private var bytes:ByteArray = new ByteArray();
private var visLoc:Point;
private var visScale:Number;
private var waveHeight:Number;
private var baseLine:Number;
private var fft:Boolean;
private var g:Graphics;
public function Visualization( obj:Object ){
waveHeight = obj.waveHeight;
baseLine = obj.baseLine;
visLoc = obj.visLoc;
visScale = obj.visScale;
}
public function addVisTimer( ):void {
if( timer==null ){
timer = new Timer( 50 );
timer.addEventListener( TimerEvent.TIMER, onVisualize );
timer.start( );
}
}
private function onVisualize( evt:TimerEvent ):void {
}
}