サウンドを生成する練習
♥0 |
Line 26 |
Modified 2009-06-22 19:23:59 |
MIT License
archived:2017-03-20 14:55:28
ActionScript3 source code
/**
* Copyright yasnis ( http://wonderfl.net/user/yasnis )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/nJ4D
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.SampleDataEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import com.flashdynamix.utils.SWFProfiler;
[SWF(backgroundColor=0x000000, frameRate=60)]
public class FlashTest extends Sprite {
private var sound:Sound = new Sound();
private var channel:SoundChannel;
private var count:int = 0;
public function FlashTest() {
SWFProfiler.init(this);
// write as3 code here..
sound.addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
channel = sound.play();
}
private function onSampleData(e:SampleDataEvent):void{
return;
for ( var c:int=0; c<8192; c++ ) {
e.data.writeFloat(Math.sin((Number(c+e.position)/Math.PI/2))*0.25);
e.data.writeFloat(Math.sin((Number(c+e.position)/Math.PI/2))*0.25);
}
}
}
}