Skip to content

Instantly share code, notes, and snippets.

@walmik
Last active July 19, 2019 20:22
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/8c20b24492661f8ee5c1b7d6e9434108 to your computer and use it in GitHub Desktop.
Save walmik/8c20b24492661f8ee5c1b7d6e9434108 to your computer and use it in GitHub Desktop.
This a simple script that will create a few MIDI files with a slight variation each time you run it with nodejs on the terminal
// Make sure you have Node version 8+ installed locally and you have run `npm install scribbletune` before running this script
const scribble = require('scribbletune');
const ptn = 'xxxx'.repeat(7);
const A = 'xxx[x[RR]]';
const B = 'xx[x[RR]][x[RR]]';
const C = 'x-[x[RR]]';
const kick = scribble.clip({
pattern: ptn + A + ptn + B + ptn + A + ptn + C,
notes: 'c4',
});
scribble.midi(kick, 'kick.mid');
const ch = scribble.clip({
pattern: '[xR][[x[xR]]]'.repeat(16),
notes: 'c4',
sizzle: 'sin',
sizzleReps: 32,
});
scribble.midi(ch, 'ch.mid');
const bass = scribble.clip({
notes: 'Bb2',
pattern: '[-xRx][-xRR][-xRx][-xxR]'.repeat(2),
randomNotes: scribble.scale('Bb2 minor').slice(1),
accent: '--x-',
});
const bassEnd = scribble.clip({
notes: 'G#2',
pattern: '[-xRx][-xRR][-xRx][-xxR]'.repeat(2),
randomNotes: scribble.scale('Bb2 harmonic minor').slice(2, 5),
accent: '--x-',
});
scribble.midi(bass.concat(bassEnd), 'bass.mid');
const sA = '-x-x';
const sB = '-[xR]-[Rx]';
const snare = scribble.clip({
notes: 'c4',
pattern: (sA + sA + sB + sA + sA + sB + sA + sA).repeat(4),
});
scribble.midi(snare, 'snare.mid');
const oh = scribble.clip({
notes: 'c4',
pattern: '[-x][Rx][Rx][Rx]'.repeat(8),
});
scribble.midi(oh, 'oh.mid');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment