So I’ve been messing around with ChatGPT and had it write a code for 30 different scales and with the different keys.
I’m trying to create a harp inside Openstage control and have it only play the notes depending on the scale and key selected. Unfortunately I have music knowledge but no scripting skills. Perhaps someone smarter here can assist in pointing me in the right direction.
Here is the script
const { Midi } = require('@tonejs/midi');
const SCALE_NAMES = [
'major',
'minor',
'dorian',
'phrygian',
'lydian',
'mixolydian',
'locrian',
'harmonic minor',
'melodic minor',
'blues',
'pentatonic major',
'pentatonic minor',
'pentatonic blues',
'pentatonic neutral',
'prometheus',
'tritone',
'whole tone',
'augmented',
'bebop dominant',
'bebop major',
'bebop minor',
'chromatic',
'double harmonic',
'enigmatic',
'flamenco',
'gypsy',
'half-whole',
'hindu',
'hungarian minor',
'japanese',
];
const KEY_NAMES = [
'C',
'C#',
'D',
'D#',
'E',
'F',
'F#',
'G',
'G#',
'A',
'A#',
'B',
];
function generateScale(scaleName, keyName) {
const scale = Midi.Scales.get(scaleName);
const key = Midi.Key.fromKeyName(keyName);
const notes = scale.notes.map(note => Midi.Note.fromFrequency(key.noteToFrequency(note)));
return new Midi().addTrack().addNotes(notes, 0, notes.length);
}
for (let i = 0; i < SCALE_NAMES.length; i++) {
for (let j = 0; j < KEY_NAMES.length; j++) {
const scale = generateScale(SCALE_NAMES[i], KEY_NAMES[j]);
Midi.writeToFile(scale, scale_${SCALE_NAMES[i].replace(' ', '_')}_${KEY_NAMES[j]}.mid
);
}
}