Skip to content

Instantly share code, notes, and snippets.

@smuuf
Last active April 22, 2016 15:51
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 smuuf/f5d505e85227cfdeeab12641b461cf25 to your computer and use it in GitHub Desktop.
Save smuuf/f5d505e85227cfdeeab12641b461cf25 to your computer and use it in GitHub Desktop.
// Prepare some stuff.
var bpm = 135;
var loopInterval = (60 * 1000) / bpm / 4;
// Master channel.
__().compressor({id: "master"}).dac();
__().sine({id: "kick", frequency: 60})
.overdrive({drive: 0.05})
.adsr({id: "kickA"})
.gain(0.8)
.highpass(20)
.connect("#master");
__().white({id: "clap"})
.adsr({id: "clapA"})
.gain(0.5)
.highpass(300)
.lowpass({frequency: 2500, q: 6})
.connect("#master");
__().white({id: "hihat"})
.adsr({id: "hihatA"})
.gain(0.2)
.highpass(8000)
.lowpass({frequency: 20000, q: 3})
.connect("#master");
// Loop
__.loop({steps: 16, interval: loopInterval});
// Patterns
__('#kick,#kickA').bind("step", function(i, v, a) {
if (v) {
__.ramp(40, .1, "frequency", 140);
__.adsr("trigger", [0, 0.3, 0.2, 0.2]);
}
}, [1,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0]);
__('#clap,#clapA').bind("step", function(i, v, a) {
if (v) {
__.adsr("trigger", [0, 0.20, 0.1, 0.05]);
}
}, [0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0]);
__('#hihat,#hihatA').bind("step", function(i, v, a) {
if (v) __.adsr("trigger", [0, 0.08, 0, 0]);
}, [0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1]);
// Hrej!
__.loop("start");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment