Created
November 30, 2011 15:48
-
-
Save jacksonwillis/1409553 to your computer and use it in GitHub Desktop.
Paradiddle - generate snare drum rudimental patterns in javascript.
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
<!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> |
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
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) -> |
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
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