-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
47 lines (36 loc) · 950 Bytes
/
test.js
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
/**
* test
*/
import note from 'opendsp/note';
import env from 'opendsp/envelope';
import { Tri, Saw, Sqr } from 'opendsp/wavetable-osc';
import { sin } from 'opendsp/osc';
import Chord from './index';
var base = oct(0.5);
var chord = Chord(Saw, 16, true);
var progr = [
['f4','a4','c5','d#5'].map(note).map(base),
['a4','c5','d#5','f5'].map(note).map(base),
['c5','d#5','f5','a5'].map(note).map(base),
['d#5','f5','a5','c6'].map(note).map(base),
];
export function dsp(t){
t *= 1;
var kick = Math.sin(67 * env(t*2, 1/4, 28, 1.5));
var c = progr[3-(t%4|0)];
var mix = (
.5 * chord(c.map(vibrato(t,4,4))) * env(t+1/8, 1/16, 3, 2) * env(t+3/4, 1/4, 2, 1) * env(t+3/8, 1/2, 1, 3)
+ .7 * kick
);
return mix;
}
function vibrato(t, f, n){
return function(x){
return x + (sin(t, f) * n);
};
}
function oct(x){
return function(f){
return f * x;
};
}