topical media & game development
actionscript-omr-lib-Staff.ax
actionscript-omr-lib-Staff.ax
[swf]
flex
package
{
public class @ax-actionscript-omr-lib-Staff
{
private var row:int;
private var scale:int;
private var toneGenerator:actionscript_omr_lib_ToneGenerator
private var tonePlayer:actionscript_omr_lib_TonePlayer
private var notes:Array;
private var currentNote:int;
public function @ax-actionscript-omr-lib-Staff(rowp:int,scalep:int)
{
toneGenerator = new actionscript_omr_lib_ToneGenerator(this);
tonePlayer = new actionscript_omr_lib_TonePlayer(this);
currentNote=0;
notes = new Array();
row = rowp;
scale = scalep;
}
public function addNote(x:int,y:int):void{
//forget about half steps for now, use 7 where 4 is the B line
notes.push(new actionscript_omr_lib_Note(y,1));
}
//Use piano samples, todo implement queue
public function playPiano():void{
//just one note
// do for each
while(currentNote<notes.length){
var note:actionscript_omr_lib_Note = notes[currentNote];
tonePlayer.play(note.getPitch());
currentNote++;
}
}
public function play():void{
//no sleep function
//use events
var note:actionscript_omr_lib_Note = notes[currentNote];
//trace("should play note with frequency" +note.getPitch().getFrequency());
toneGenerator.play(note.getPitch().getFrequency());
currentNote++;
//var sleepInt=setInterval(goToSleep,1000); // wait 1000 milliseconds
}
public function playNotes():void{
if(currentNote<notes.length){
var note:actionscript_omr_lib_Note = notes[currentNote];
toneGenerator.play(note.getPitch().getFrequency());
currentNote++;
}
}
public function getRow():int{
return row;
}
public function getScale():int{
return scale;
}
private function goToSleep():void{
//clearInterval(sleepInt);
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.