Last active
July 17, 2022 22:04
-
-
Save ricardoalcocer/1399abab69306a811159dfc17be9218b to your computer and use it in GitHub Desktop.
Chord Progression Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can run this at https://jsbin.com/lohoval/7/edit?js,console | |
var progression = function(){ | |
var currentKey = ""; | |
var chords = { | |
"A" : ["A", "Bmin", "C#min", "D", "E", "F#min", "G#°"], | |
"B" : ["B", "C#min", "D#min", "E", "F", "G#min", "A#°"], | |
"C" : ["C", "Dmin", "Emin", "F", "G", "Amin", "B°"], | |
"D" : ["D", "Emin", "F#min", "G", "A", "Bmin", "C#°"], | |
"E" : ["E", "F#min", "G#min", "A", "B", "C#min", "D#°"], | |
"F" : ["F", "Gmin", "Amin", "Bb", "C", "Dmin", "E°"], | |
"G" : ["G", "Amin", "Bmin", "C", "D", "Emin", "F#°"], | |
"Amin" : ["Amin", "B°", "C", "Dmin", "Emin", "F", "G"], | |
"Bmin" : ["Bmin", "C#°", "D", "Emin", "F#min", "G", "A"], | |
"Cmin" : ["Cmin", "D°", "Eb", "Fmin", "Gmin", "Ab", "Bb"], | |
"Dmin" : ["Dmin", "E°", "F", "Gmin", "Amin", "Bb", "C"], | |
"Emin" : ["Emin", "F#°", "G", "Amin", "Bmin", "C", "D"], | |
"Fmin" : ["Fmin", "G°", "Abmin", "Bbmin", "Cmin", "Db", "Eb"], | |
"Gmin" : ["Gmin", "A°", "Bb", "Cmin", "Dmin", "Eb", "F"] | |
}; | |
return { | |
getNumber : function(){ | |
return Math.floor(Math.random() * chords[this.currentKey].length) + 1 | |
}, | |
generate : function (thisKey){ | |
this.currentKey = thisKey; | |
var degrees = [1,this.getNumber(),this.getNumber(),this.getNumber()]; | |
degrees.forEach(element => { | |
console.log(chords[this.currentKey][element-1]); | |
}) | |
var baseURL = "https://www.songtive.com/en/chords/guitar/standard/"; | |
console.log("Full chord charts at " + baseURL + this.currentKey); | |
} | |
} | |
}(); | |
// ##### LOOK HERE. JUST CHANGE THE KEY | |
// FOR A MAJOR use 'A', FOR A MINOR use 'Amin' | |
progression.generate('C'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output for key of C: