-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.html
145 lines (145 loc) · 4.63 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="./lib/demo/demo.css">
<link rel="stylesheet" type="text/css" href="./lib/demo/prism.css">
</head>
<body>
<section class='heading'>
<h1 class='title'>beet.js</h1>
<p class='desc'>
Beet.js is a polyrhythmic sequencer library for Web Audio API.<br>
The sequencer can have multiple layers where each layer can have an independent tempo and step count.<br>This feature allows you to create complex rhythmic sequences such as polyrhythms and euclidean rhythms using a simple API.<br>
<div class='links'>
<a href="https://github.com/zya/beet.js" target="_blank" class="fa fa-github github"></a>
</div>
</p>
</section>
<hr>
<section class='example' id='59'>
<h1 class='text' class='text'>Simple Euclidean Rhythm - 5/9</h1>
<i class="fa fa-play icon" id="play"></i>
<div class="code-container">
<pre class="language-javascript"><code>
var Beet = require('beet.js');
var context = new AudioContext();
var beet = new Beet({
context: context
});
var pattern = beet.pattern(5, 9); // returns 101110111
var layer = beet.layer(pattern, callback);
beet.add(layer).start();
</code></pre>
</div>
</section>
<hr>
<section class='example' id='913'>
<h1 class='text'>Euclidean Rhythm - 9/13</h1>
<i class="fa fa-play icon" id="play"></i>
<div class="code-container">
<pre class="language-javascript"><code>
var Beet = require('beet.js');
var context = new AudioContext();
var beet = new Beet({
context: context
});
var pattern = beet.pattern(9, 13); // returns 1011011011011
var layer = beet.layer(pattern, callback);
beet.add(layer).start();
</code></pre>
</div>
</section>
<hr>
<section class='example' id='poly1'>
<h1 class='text'>Polyrhythm - 5 over 4 - Two Layers</h1>
<i class="fa fa-play icon" id="play"></i>
<div class="code-container">
<pre class="language-javascript"><code>
var Beet = require('beet.js');
var context = new AudioContext();
var beet = new Beet({
context: context
});
var fours = beet.pattern(4); // returns 1111
var layer1 = beet.layer(fours, foursCallback);
var fives = beet.pattern(5); // returns 11111
var layer2 = beet.layer(fives, fivesCallback);
beet.add(layer1);
beet.add(layer2);
beet.start();
</code></pre>
</div>
</section>
<hr>
<section class='example' id='layered'>
<h1 class='text'>Multiple Layers With Different Tempos</h1>
<i class="fa fa-play icon" id="play"></i><br>
<p class='text tips'>each layer can have an independent speed. the tempo can also be changed in real-time</p>
<div class="code-container">
<pre class="language-javascript"><code>
var Beet = require('beet.js');
var context = new AudioContext();
var beet = new Beet({
context: context
});
var pattern1 = beet.pattern(4, 8); // returns 10101010
var layer1 = beet.layer(pattern1, callback1);
layer1.tempo = 120;
var pattern2 = beet.pattern(3, 8); // returns 10100100
var layer2 = beet.layer(pattern2, callback2);
layer2.tempo = 60;
var pattern3 = beet.pattern(3, 4); // returns 1111
var laye3 = beet.layer(pattern3, callback3);
layer2.tempo = 40;
beet.add(layer1);
beet.add(layer2);
beet.add(layer3);
beet.start();
</code></pre>
</div>
</section>
<hr>
<section class='example' id='off'>
<h1 class='text'>On/Off Callbacks</h1>
<i class="fa fa-play icon" id="play"></i><br>
<p class='text tips'>each layer takes two callbacks. one for 'on' steps and one for 'off' steps.</p>
<div class="code-container">
<pre class="language-javascript"><code>
var Beet = require('beet.js');
var context = new AudioContext();
var beet = new Beet({
context: context
});
var pattern = beet.pattern(4, 9);
// callbackOn will be called on the green slots
// callbackOff will be called on the grey slots
var layer = beet.layer(pattern, callbackOn, callbackOff);
beet.add(layer).start();
</code></pre>
</div>
</section>
<hr>
<section class='example' id='custom'>
<h1 class='text'>Custom String Patterns</h1>
<i class="fa fa-play icon" id="play"></i><br>
<p class='text tips'>a pattern can be genrated by passing a custom string instead of numbers</p>
<div class="code-container">
<pre class="language-javascript"><code>
var Beet = require('beet.js');
var context = new AudioContext();
var beet = new Beet({
context: context
});
var pattern = beet.pattern('1000101010');
var layer = beet.layer(pattern, callbackOn);
beet.add(layer).start();
</code></pre>
</div>
</section>
<br><br>
</body>
<script type="text/javascript" src="build/demo.js"></script>
</html>