Day037 — Make Music

Jacky Tsang
1 min readAug 9, 2017

--

https://github.com/jacky-ttt

It is an short but interesting talk about how to use Javascript to generate electronic dance music. It is presented by Walmik Deshpande who is the author of scribbletune.

Scribbletune uses the most minimalistic api to generate music, as simple as below code.

const scribble = require('scribbletune');
let clip = scribble.clip({
notes: ['c4'],
pattern: 'x-x-x-x-x-x-x-x-',
});
scribble.midi(clip);

The “clip” function takes a single object as it argument. That object contains “notes”, which is an array of sting, and “pattern”, which is a string. Then, the clip is passed to the “midi” function to generate a midi file. That file can then be used to import to a music software like Garage band or Ableton to form a track.

Frist, navigate to your project directory using cd command.

cd /Users/{user_name}/{project_name}

Then, download “scribbletune” with below command (assume you have nodejs installed)

npm install scribbletune

Create a file named “app.js” containing

const scribble = require('scribbletune');
let clip = scribble.clip({
notes: ['c4'],
pattern: 'x-x-x-x-x-x-x-x-',
});
scribble.midi(clip);

run below command to execute the js.

node app.js

“music.mid” will be generated in the project root directory.

--

--

No responses yet