03-10-2018, 11:43 AM
Here's another one that flips the song between major/minor. Make sure you have the right key selected first since auto-detect will always detect major.
Code:
if (keySelect.selectedIndex == 0) {
message('Select a key first');
} else {
var inverseKeyIndex = (keySelect.selectedIndex + 12) % 24;
var inverseKey = settings.scales[inverseKeyIndex];
for (i = 0; i < song.notes.length; i++) {
var note = song.notes[i];
var octave = note.type.substring(note.type.length-1);
var noteInverseKeyIndex = scale.indexOf(note.type.substring(0, note.type.length-1));
if (noteInverseKeyIndex != -1) {
song.moveNote(note, note.instrument, note.instrument, note.time, note.time, note.type, inverseKey[noteInverseKeyIndex] + octave);
song.update(note);
}
}
keySelect.selectedIndex = inverseKeyIndex;
keySelect.onchange();
}