Skip to content

Instantly share code, notes, and snippets.

@Fannon
Created November 12, 2023 07:00
Show Gist options
  • Save Fannon/8b44fa9ba91fdf461ae398fc2a9d2179 to your computer and use it in GitHub Desktop.
Save Fannon/8b44fa9ba91fdf461ae398fc2a9d2179 to your computer and use it in GitHub Desktop.
Create all modal scales from the same pattern
const halfStepPattern = [2, 2, 1, 2, 2, 2, 1]
const modes = ["Ionian", "Dorian", "Phrygian", "Lydian", "Mixolydian", "Aeolian", "Locrian"]
const notes = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
const notesDoubled = notes.concat(notes) // double the array to get a cheap "ring buffer"
const patternDoubled = halfStepPattern.concat(halfStepPattern)
notes.forEach((note, noteIndex) => {
modes.forEach((mode, modeIndex) => {
let currentStep = 0
const scaleNotes = []
for (let stepIndex = 0; stepIndex < halfStepPattern.length; stepIndex++) {
scaleNotes.push(notesDoubled[noteIndex + currentStep])
currentStep += patternDoubled[modeIndex + stepIndex]
}
console.log(`${note} ${mode}: ${scaleNotes.join(', ')}`)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment