Skip to content

Instantly share code, notes, and snippets.

@nandoflorestan
Created August 2, 2020 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nandoflorestan/6a8bb79098fbc0bb1d5a1420e27a7701 to your computer and use it in GitHub Desktop.
Save nandoflorestan/6a8bb79098fbc0bb1d5a1420e27a7701 to your computer and use it in GitHub Desktop.
Instead of starting from a blank page, compose from the suggestion of a moron
/** @prettier */
"use strict";
// Usage: node composing-moron.mjs
const notes = [
"A ",
"B♭",
"B ",
"C ",
"D♭",
"D ",
"E♭",
"E ",
"F ",
"G♭",
"G ",
"A♭",
];
const chordTypes = ["Maj ", "min ", "dim ", "aug ", "sus4", "sus2"];
const additions = ["+M6", "+m6", "+M7", "+m7"];
const melodicDevices = [
"passing note",
"appogiatura",
"suspension",
"escapada",
"bordadura",
"trill",
"gruppeto",
"acciacatura",
"dotted rhythm",
"staccato",
"step",
"skip",
"leap",
"inversion",
"syncopation",
"hemiola",
];
const compositionalDevices = [
"ostinato",
"contrary motion",
"parallel motion",
"oblique motion",
"ground bass",
"variation",
"sequence",
"imitation",
"fugue",
"pedal",
"counter melody",
"call and response",
];
const instruments = [
"recorder",
"flute",
"clarinet",
"oboe",
"bassoon",
"trumpet",
"horn",
"trombone",
"tuba",
"timpani",
"vibraphone",
"xylophone",
"glockenspiel",
"celesta",
"piano",
"electric piano",
"high strings",
"low strings",
"guitar",
"banjo",
"harmonica",
"whistle",
"snare",
"triangle",
"cymbals",
"bongos",
"synth",
"pad",
"lead",
"drumset",
"voice",
"ondes martenot",
"theremin",
];
function choice(array) {
return array[Math.floor(Math.random() * array.length)];
}
export function getRandomChord() {
return [
choice(notes),
choice(chordTypes),
choice(additions),
"/",
choice(notes),
];
}
console.log("This section could have:");
console.log("Device: ", choice(compositionalDevices));
console.log("Main line: ", choice(instruments));
console.log("Secondary line: ", choice(instruments));
console.log("Accompaniment: ", choice(instruments));
console.log("\n");
console.log("Weird chord progression for you to change until you like it:");
for (var i = 0; i < 20; i++) {
console.log(getRandomChord().join(" "));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment