Skip to content

Instantly share code, notes, and snippets.

@walmik
Created August 9, 2020 08:02
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 walmik/2460f014daf10af5b6570296dcb2cf8f to your computer and use it in GitHub Desktop.
Save walmik/2460f014daf10af5b6570296dcb2cf8f to your computer and use it in GitHub Desktop.
const _ = require('lodash');
const scribble = require('scribbletune');
const setOfNotes = scribble
.scale('C3 lydian')
.concat(scribble.scale('C4 lydian')); // or simply scribble.scale('C3 major') OR manually set the notes
const pattern = 'x__[xx]x_x_'.repeat(8); // or a simple one 'x___'.repeat(4)
const count = pattern.replace(/[^x]/g, '').length;
const notes = [];
for (let i = 0; i < count; i++) {
notes.push(_.sampleSize([...setOfNotes], 3));
}
scribble.midi(
scribble.clip({
notes,
pattern,
})
);
// This will generate a file called music.mid at the same location as this script is run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment