03-10-2018, 12:11 PM
(03-10-2018, 11:43 AM)Jacob_ Wrote: 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.Do you think you could make this so it doesn't affect percussion?
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();
}