This repository has been archived by the owner on Jun 9, 2019. It is now read-only.
/
delay.js
98 lines (82 loc) · 2.43 KB
/
delay.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
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
(function(T) {
"use strict";
var fn = T.fn;
var timevalue = T.timevalue;
var StereoDelay = T.modules.StereoDelay;
function DelayNode(_args) {
T.Object.call(this, 2, _args);
fn.fixAR(this);
var _ = this._;
_.time = T(100);
_.fb = T(0.2);
_.cross = T(false);
_.mix = 0.33;
_.delay = new StereoDelay(_.samplerate);
}
fn.extend(DelayNode);
var $ = DelayNode.prototype;
Object.defineProperties($, {
time: {
set: function(value) {
if (typeof value === "string") {
value = timevalue(value);
}
this._.time = T(value);
},
get: function() {
return this._.time;
}
},
fb: {
set: function(value) {
this._.fb = T(value);
},
get: function() {
return this._.fb;
}
},
cross: {
set: function(value) {
this._.cross = T(value);
},
get: function() {
return this._.cross;
}
},
mix: {
set: function(value) {
if (typeof value === "number") {
value = (value > 1) ? 1 : (value < 0) ? 0 : value;
this._.mix = value;
}
},
get: function() {
return this._.mix;
}
}
});
$.process = function(tickID) {
var _ = this._;
if (this.tickID !== tickID) {
this.tickID = tickID;
var time = _.time.process(tickID).cells[0][0];
var fb = _.fb.process(tickID).cells[0][0];
var cross = _.cross.process(tickID).cells[0][0] !== 0;
var mix = _.mix;
if (_.prevTime !== time || _.prevFb !== fb || _.prevCross !== cross || _.prevMix !== mix) {
_.prevTime = time;
_.prevFb = fb;
_.prevCross = cross;
_.prevMix = mix;
_.delay.setParams(time, fb, cross, mix);
}
fn.inputSignalAR(this);
if (!_.bypassed) {
_.delay.process(this.cells[1], this.cells[2]);
}
fn.outputSignalAR(this);
}
return this;
};
fn.register("delay", DelayNode);
})(timbre);