Created
August 9, 2020 08:02
-
-
Save walmik/2460f014daf10af5b6570296dcb2cf8f to your computer and use it in GitHub Desktop.
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
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