//コード名生成用
let pitch_names = ["A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"];
let major_intervals = [ 2, 4, 5, 7, 9, 11 ];
let diatonic_chords = ["M7", "m7", "m7", "M7", "7", "m7", "m7(b5)"];
let digree_names = ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ"];
//コード進行
let chord_progs = [ [2, 5, 1, 6],
[4, 5, 6, 1],
[4, 5, 3, 6],
[1, 4, 5, 1]];
//カウント用
let cnt = 0;
let cnt_string = ["○ ○ ○ ○", "● ○ ○ ○", "● ● ○ ○", "● ● ● ○", "● ● ● ●"];
let key; // key = C
let scale = [];
// 現在の状態
let current_key = 3;
let current_prog_num = 0;
let current_num = 0;
init( current_key, current_prog_num );
function init( key_num, prog_num ){
key = key_num;
current_num = 0;
create_scale();
print_key();
print_chord_prog( prog_num );
print_chord( prog_num, 0);
print_next_chord( prog_num, 1);
print_diatonic_chord();
}
function create_scale(){
scale = [];
scale.push(pitch_names[key]);
for(let i=0; i < major_intervals.length; i++){
let next = key + major_intervals[i];
if(next > 11){
next = next - 12;
}
scale.push(pitch_names[next]);
}
}
// キーを表示
function print_key(){
document.getElementById("key").innerText = "key = " + pitch_names[ key ];
}
// コード進行をディグリーネームで表示
// コード進行を配列で渡す
function print_chord_prog( num ){
let chord_prog_str = "";
for(let i=0; i new Promise( resolve => setTimeout(resolve, waitTime) );
//print_pitch_name(0);
print_cnt_string(0);
const loop = () => sleep( 1000 )
.then( () => {
cnt++;
if (cnt >= 5){
cnt = 1;
current_num++;
if (current_num == chord_progs[current_prog_num].length)
current_num = 0;
print_chord(current_prog_num, current_num);
let next_num = current_num + 1;
if (next_num == chord_progs[current_prog_num].length)
next_num = 0;
print_next_chord(current_prog_num, next_num);
}
print_cnt_string(cnt);
loop();
});
loop();