"outstretchedarm" <outstretchedarm@hotmail.comwrote in message
news:1158085941.600562.148170@i42g2000cwa.googlegr oups.com...
[snip]
Quote:
what I want to do is:
>
1) enable the user to select a "starting note" (that is the key)
>
2) enable the user to select a scale, that is, a "path" through these
notes. If the user selects major, the program will, starting from the
selected starter note, choose thenext notes according to this pattern:
>
Root (the key selected) + 2 + 2 + 1 + 2 + 2 + 2 + 1
>
so if the user selects "C" and "major scale," it will print:
C, D, E, F, G, A, B, C
>
3) I want the program to "create" chords from the notes in the scale
generated.
>
like this:
>
I = 1 + 3 + 5 = C chord = C + E + G
II = 2 + 4 + 6 = D chord = D + F + A
III = 3 + 5 + 7 = E chord = E + G + B
IV = 4 + 6 + 1 = F chord = F + A + C
V = 5 + 7 + 2 = G chord = G + B + D
VI = 6 + 1 + 3 = A chord = A + C + E
VII= 7 + 2 + 4 = B chord = B + D + F
>
I need help with:
>
a) can somebody give me hints on how to code the algorithms that would
do this?
>
b) could somebody point me in the directions of a set of snippets that
might help me on this? Have mercy, I am a n00b, not begging for a
handout, but for help.
Here's a start. Watch for word-wrap.
<html>
<head>
<title>Notes.htm</title>
<script type="text/javascript">
var arr1 = new Array();
var arr2 = new Array();
function build() {
var note = "C,Db,D,Eb,E,F,Gb,G,Ab,A,Bb,B";
var html = "<form name='form1'>";
html += "Notes: <select name='Notes'>\n";
html += "<option value=''></option>\n";
var itm1 = note.split(",");
for (var i=0; i<itm1.length; i++) {
arr1[i] = itm1[i];
html += "<option value='" + i + "'>" + arr1[i] + "</option>\n";
}
var itm2 = (note+","+note+","+note).split(",");
for (var j=0; j<itm2.length; j++) {
arr2[j] = itm2[j];
}
html += "</select>\n";
html += " \n";
html += "Scale: <select name='Scale'>\n";
html += "<option value=''></option>\n";
// html += "<option value='1'>Minor</option>\n";
html += "<option value='2'>Major</option>\n";
html += "</select>\n";
html += " \n";
html += "<input type='button' value='Chords' onclick='chords()'>\n";
html += "</form>\n";
document.getElementById("html").innerHTML = html;
}
function chords() {
var form = document.form1;
var valu = form.Notes.options[form.Notes.selectedIndex].value;
// var scal = form.Scale.options[form.Scale.selectedIndex].value;
var next = parseInt(valu,10);
var what = arr1[next];
if (what == "") return;
var patt = [2,2,1,2,2,2,1];
for (var k=0; k<patt.length; k++) {
next += patt[k];
what += " " + arr2[next];
}
alert(what);
}
window.onload=build;
</script>
</head>
<body>
<div id="html"></div>
</body>
</html>
The "Scale" dropdown does nothing -- yet.
You lost me with:
Quote:
3) I want the program to "create" chords from the notes in the scale
generated.
>
like this:
>
I = 1 + 3 + 5 = C chord = C + E + G
II = 2 + 4 + 6 = D chord = D + F + A
III = 3 + 5 + 7 = E chord = E + G + B
IV = 4 + 6 + 1 = F chord = F + A + C
V = 5 + 7 + 2 = G chord = G + B + D
VI = 6 + 1 + 3 = A chord = A + C + E
VII= 7 + 2 + 4 = B chord = B + D + F