Permalink
Browse files

Cleanup

  • Loading branch information...
1 parent 1959ae4 commit a110671496608541e3a83d8573261ab269275665 @jussi-kalliokoski committed Apr 24, 2012
View
@@ -53,7 +53,8 @@ function Automation (fx, parameter, automation, amount, type) {
fx.append = Automation.bufferEffectAppend; break;
}
}
- var automation = new AutomationClass(parameter, automation, amount, type);
+
+ automation = new AutomationClass(parameter, automation, amount, type);
fx.automation.push(automation);
return automation;
}
@@ -50,12 +50,12 @@ UIControl.prototype = {
setValue: function (value) {
this.schedule.push({
v: value,
- t: ~~((+new Date - this.clock) / 1000 * this.sampleRate)
+ t: ~~((+new Date() - this.clock) / 1000 * this.sampleRate)
});
},
reset: function (value) {
this.value = isNaN(value) ? this.value : value;
- this.clock = +new Date;
+ this.clock = +new Date();
}
};
View
@@ -20,7 +20,7 @@
* @param {number} a2 Biquadratic difference equation parameter
*/
function BiquadFilter (sampleRate, b0, b1, b2, a1, a2) {
- this.reset.apply(this, arguments)
+ this.reset.apply(this, arguments);
}
/**
@@ -13,12 +13,15 @@
function BitCrusher (sampleRate, bits) {
var self = this,
sample = 0.0;
+
self.sampleRate = sampleRate;
self.resolution = bits ? Math.pow(2, bits-1) : Math.pow(2, 8-1); // Divided by 2 for signed samples (8bit range = 7bit signed)
+
self.pushSample = function (s) {
- sample = Math.floor(s*self.resolution+0.5)/self.resolution
+ sample = Math.floor(s * self.resolution + 0.5) / self.resolution;
return sample;
};
+
self.getMix = function () {
return sample;
};
View
@@ -38,45 +38,53 @@ function Freeverb (sampleRate, channelCount, wet, dry, roomSize, damping, tuning
}());
self.CFs = (function () {
- var combs = [],
+ var combs = [],
channel = [],
num = self.tuning.combCount,
damp = self.damping * self.tuning.scaleDamping,
feed = self.roomSize * self.tuning.scaleRoom + self.tuning.offsetRoom,
sizes = self.tuning.combTuning,
i, c;
+
for (c=0; c<self.channelCount; c++) {
for(i=0; i<num; i++) {
channel.push(new audioLib.CombFilter(self.sampleRate, sizes[i] + c * self.tuning.stereoSpread, feed, damp));
}
+
combs.push(channel);
channel = [];
}
+
return combs;
}());
+
self.numCFs = self.CFs[0].length;
self.APFs = (function () {
- var apfs = [],
+ var apfs = [],
channel = [],
num = self.tuning.allPassCount,
feed = self.tuning.allPassFeedback,
sizes = self.tuning.allPassTuning,
i, c;
+
for (c=0; c<self.channelCount; c++) {
for (i=0; i<num; i++) {
channel.push(new Freeverb.AllPassFilter(self.sampleRate, sizes[i] + c * self.tuning.stereoSpread, feed));
}
+
apfs.push(channel);
channel = [];
}
+
return apfs;
}());
+
self.numAPFs = self.APFs[0].length;
}
Freeverb.prototype = {
- channelCount: 2,
+ channelCount: 2,
sample: [0.0, 0.0],
wet: 0.5,
@@ -230,4 +238,4 @@ Freeverb.AllPassFilter.prototype = {
this.sample = 0.0;
this.buffer = new Float32Array(this.bufferSize);
}
-}
+};
View
@@ -64,6 +64,8 @@ Limiter.prototype = {
case 'attack':
case 'release':
this._amplitude[param] = value;
+ this[param] = value;
+ break;
default:
this[param] = value;
}
@@ -62,7 +62,7 @@ Sampler.prototype = {
self.voices.push(note);
while (self.voices.length > self.maxVoices) {
end = self.voices.shift();
- end.onend && end.onend();
+ if (end.onend) end.onend();
}
return note;
},
@@ -75,7 +75,10 @@ Sampler.prototype = {
for (i=0; i<voices.length; i++) {
voice = voices[i];
voice.p += voice.s;
- voice.p > voice.l && voices.splice(i--, 1) && voice.onend && voice.onend();
+
+ if (voice.p > voice.l && voices.splice(i--, 1) && voice.onend) {
+ voice.onend();
+ }
}
},
/**
View
@@ -15,15 +15,22 @@ function inject () {
audioLib.AudioWorker = function (code, injectable) {
var worker = 'var audioLib=(' + String(AUDIOLIB) + ').call({},this,Math,Object,Array);\n',
i;
+
for (i=0; i < audioLib.plugins._pluginList.length; i++) {
worker += '(' + String(audioLib.plugins._pluginList[url]) + '());\n';
}
- injectable && (worker += 'this.addEventListener("message",function(e){e.data&&e.data.type==="injection"&&Function(e.data.code).call(this)},true);\n');
+
+ if (injectable) {
+ worker += 'this.addEventListener("message",function(e){e.data&&e.data.type==="injection"&&Function(e.data.code).call(this)},true);\n';
+ }
+
worker += (code instanceof Function ? '(' + String(code) + ').call(this);' : code.textContent || code);
worker = Sink.inlineWorker(worker);
+
if (injectable) {
worker.inject = inject;
}
+
return worker;
};
Oops, something went wrong.

0 comments on commit a110671

Please sign in to comment.