fix some filter weirdness

This commit is contained in:
Andy Sloane 2015-10-31 09:33:59 -07:00
commit 5e141535ab

8
xm.js
View file

@ -126,11 +126,9 @@ var tempo = 4;
// Return 2-pole Butterworth lowpass filter coefficients for // Return 2-pole Butterworth lowpass filter coefficients for
// center frequncy f_c (relative to sampling frequency) // center frequncy f_c (relative to sampling frequency)
function FilterCoeffs(f_c) { function FilterCoeffs(f_c) {
// if (f_c > 0.5) { // we can't lowpass above the nyquist frequency... if (f_c > 0.5) { // we can't lowpass above the nyquist frequency...
// return [1, 0, 0]; f_c = 0.5;
// } }
// what happens instead is the filter wraps around to an alias frequency,
// and that also works OK, though it isn't strictly right... FIXME
var wct = Math.sqrt(2) * Math.PI * f_c; var wct = Math.sqrt(2) * Math.PI * f_c;
var e = Math.exp(-wct); var e = Math.exp(-wct);
var c = e * Math.cos(wct); var c = e * Math.cos(wct);