forked from: SiON example
forked from SiON example (diff: 26)
the simplest example
ActionScript3 source code
/**
* Copyright Mingchoi ( http://wonderfl.net/user/Mingchoi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sD4U
*/
// forked from mash's SiON example
// the simplest example
package {
import flash.text.TextField;
import flash.display.Sprite;
import org.si.sion.*;
public class RandomNote extends Sprite {
public var driver:SiONDriver = new SiONDriver();
function RandomNote() {
var TF:TextField = new TextField();
TF.width = TF.height = 450;
addChild(TF);
TF.text = (genrandomNote(8));
playNote(numNoteToSION(TF.text));
//driver.play("t100 l8 bdfa4 aed6");
//driver.play("t100 l1 aaaaaaaa");
}
private function genrandomNote(length:int):String{
var str:String = "";
for (var i:int = 0; i < length; i++)
str += int(Math.random()*7) + 1;
return str;
}
private function numNoteToSION(notes:String):String{
return notes.replace(/1/g,"c").replace(/2/g,"d").replace(/3/g,"e").replace(/4/g,"f").replace(/5/g,"g").replace(/6/g,"a").replace(/7/g,"b");
}
private function playNote(notes:String):void{
driver.play("t100 l8 " + notes);
}
}
}
