Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Last active July 17, 2022 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardoalcocer/1399abab69306a811159dfc17be9218b to your computer and use it in GitHub Desktop.
Save ricardoalcocer/1399abab69306a811159dfc17be9218b to your computer and use it in GitHub Desktop.
Chord Progression Generator
// 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');
@ricardoalcocer
Copy link
Author

Sample output for key of C:

C
Dmin
B°
G
Full chord charts at https://www.songtive.com/en/chords/guitar/standard/C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment