SiONを使ったランダム音生成 ※音量ポケモン注意!
@author maxcaffy
SiONを使ったランダム音生成と、ランダム座標にlineTo!
ポケモン症候群注意!
マウス座標で線の色がかわります!
突貫で作ったからコメントがぐちゃぐちゃだよ!ご了承!
package
{
import flash.display.SpreadMethod;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import org.si.sion.*;
import org.si.sion.events.SiONEvent;
/*
@author maxcaffy
//SiONを使ったランダム音生成と、ランダム座標にlineTo!
//ポケモン症候群注意!
//マウス座標で線の色がかわります!
//突貫で作ったからコメントがぐちゃぐちゃだよ!ご了承!
*/
public class randomSounds extends Sprite
{
private var sion_voice:SiONVoice;
private var sion_drive:SiONDriver;
private var sion_random:int;
private var sion_mouse_point:Array = new Array(2);
private var dance_graphics:Sprite = new Sprite();
private var i:int = 0;
private var dance_result:Array = new Array(2);
private var stage_graphics:Sprite = new Sprite();
private var red_flag:Boolean = false;
public function randomSounds()
{
initFunc();
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveFunc);
addEventListener(Event.ENTER_FRAME, mainFunc);
}
public function mainFunc(event:Event):void {
sion_random = Math.floor(Math.random() * 100);
drawSpriteFunc((Math.floor(sion_mouse_point[0])*25000).toString(16), sion_mouse_point);
sion_drive.noteOn(sion_random, sion_voice, 1, 0);
}
public function mouseMoveFunc(event:MouseEvent):void {
sion_mouse_point = [mouseX, mouseY];
trace(sion_mouse_point);
}
public function drawSpriteFunc(color:String, lineto:Array):void {
if (red_flag == true) {
stage_graphics.graphics.clear();
stage_graphics.graphics.beginFill(0x555555, 1);
stage_graphics.graphics.drawRect(0, 0, 550, 400);
}
dance_graphics.graphics.clear();
dance_graphics.graphics.lineStyle(1, uint(color), 1);
dance_graphics.graphics.moveTo(dance_result[0],dance_result[1]);
for (i = 1; i <= 20; i++) {
dance_result = [dance_result[0] + (Math.random() * 100 - 50) , dance_result[1] + (Math.random() * 100 - 50) ];
if (dance_result[0] < 0) {
dance_result[0] += 0 - dance_result[0];
}else if (dance_result[0] > 550) {
dance_result[0] += - dance_result[0];
stage_graphics.graphics.clear();
stage_graphics.graphics.beginFill(0xFF0000, 1);
stage_graphics.graphics.drawRect(0, 0, 550, 400);
red_flag = true;
}if (dance_result[1] < 0) {
dance_result[1] += 0 - dance_result[1];
}else if (dance_result[1] > 400) {
dance_result[1] += 400 - dance_result[1];
}
dance_graphics.graphics.lineTo(dance_result[0],dance_result[1]);
}
}
public function initFunc():void {
stage.frameRate = 60;
dance_result = [275, 200];
// stage.scaleMode = StageScaleMode.NO_SCALE;
// stage.align = StageAlign.TOP_LEFT;
// stage.quality = StageQuality.BEST;
stage_graphics.graphics.beginFill(0x555555, 1);
stage_graphics.graphics.drawRect(0, 0, 550, 400);
addChild(stage_graphics);
addChild(dance_graphics);
initSionFunc();
}
private function initSionFunc():void {
//SiON再生準備
sion_drive = new SiONDriver();
sion_drive.play();
//SiONの音色定義
sion_voice = new SiONVoice(5, 3);//sinWave
sion_mouse_point = [0, 0];
}
}
}