Skip to content

Instantly share code, notes, and snippets.

@jacksonwillis
Created November 30, 2011 15:48
Show Gist options
  • Save jacksonwillis/1409553 to your computer and use it in GitHub Desktop.
Save jacksonwillis/1409553 to your computer and use it in GitHub Desktop.
Paradiddle - generate snare drum rudimental patterns in javascript.
<!DOCTYPE html>
<html>
<head>
<title> Paradiddle </title>
<script src="paradiddle.js"></script>
<link href="paradiddle.css" rel="stylesheet">
</head>
<body>
<h1> Paradiddle </h1>
<div id="paradiddle"></div>
</body>
</html>
Paradiddle =
Note: (value) ->
### Generates a random integer between 0 and 4 ###
@random_value = () ->
Math.round Math.random() * 4
### Set @value to func. argument OR a random_value() ###
@value = parseInt(value)
@value ||= @random_value()
Song: (notes) ->
var Paradiddle;
Paradiddle = {
Note: function(value) {
/* Generates a random integer between 0 and 4
*/ this.random_value = function() {
return Math.round(Math.random() * 4);
};
/* Set @value to func. argument OR a random_value()
*/
this.value = parseInt(value);
return this.value || (this.value = this.random_value());
},
Song: function(notes) {}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment