Actionscript:
-
// number of notes in chord
-
var noteNum:int = 3;
-
var lowNote:Number = 0;
-
var highNote:Number = 4;
-
// delay between chords
-
var delay:int = 2000;
-
////////////////////////////////////////
-
var chord:String = "";
-
highNote += 1;
-
var tab:TextField = TextField(addChild(new TextField()));
-
tab.x = tab.y = 20;
-
tab.defaultTextFormat = new TextFormat("Courier", 12);
-
tab.multiline = true;
-
tab.width = 200;
-
-
changeChord();
-
setInterval(changeChord, delay);
-
-
function changeChord():void{
-
var strings:Array = [];
-
strings[0] = "e|---------------\n"
-
strings[1] = "B|---------------\n"
-
strings[2] = "G|---------------\n"
-
strings[3] = "D|---------------\n"
-
strings[4] = "A|---------------\n"
-
strings[5] = "E|---------------\n"
-
-
for (var i:int = 0; i<3; i++){
-
var place:int = 5 + i * 4;
-
var choices:Array = [0,1,2,3,4,5];
-
for (var j:int = 0; j<noteNum; j++){
-
var ii:int = int(Math.random()*choices.length);
-
var index:int = choices[ii];
-
strings[index] = strings[index].slice(0, place) + (int(Math.random()*highNote)+lowNote) + strings[index].substring(place+1);
-
choices.splice(ii, 1);
-
}
-
}
-
chord = strings.join("");
-
tab.text = chord;
-
}
I'm working on a small program to help me practice guitar. It randomly generates guitar tabs. The idea for the program is similar to a program that helps you learn to type (like Mavis Beacon).
I wrote this snippet today as a proof of concept - just to help me start thinking about what kind of features I want the program to have. There are settings at the top so that you can tweak the number of notes in the chord and the delay between chords etc....
It generates three chords at a time... here are some stills:
6 Comments
Ha! This is brilliant - really looking forwards to your updates on it.
If it comes together well, I’d like to make it stream from right to left, so you can play along with it - and I’ve been working on midi-out from flash too - so you could have it auto playing along with you. Sounds like a fun project to me
Thanks How’s your midi-out stuff coming? I just recently started learning about the structure of the midi file format….
I’ve got a really basic Flash to midi setup working which I’m quite happy with - but it has a lot of limitations. The main one being, it works through an intermediate processing app - but it’s fun to play with none-the-less.
Joa Ebert (one of the guys behind the Hobnox Audiotool) has some interesting suggestions if you’re looking into Flash + Midi stuff. In the comments here -
http://blog.joa-ebert.com/2009/02/11/rasselbock-loves-the-lemur/
Let me know if you get any midi stuff working - it would be great to see Flash Midi instruments running in browser - or as Air Apps.
Cool. Makes sense that the audio tool uses java for that… I’ll let you know if I get any midi stuff working… I’m currently interested in reading and writing midi files - writing a midi file should be somewhat easy… reading it and playing it back could be a bit trickier… but this and related pages seem like they may be a good place to start
Check this out as well – MIDI in Flash http://code.google.com/p/miditoflash/
Thanks Og2t! I saw this project a while ago, but didn’t realise they had shared the source. Great!