fix some filter weirdness
This commit is contained in:
parent
32b09bdf63
commit
5e141535ab
1 changed files with 3 additions and 5 deletions
8
xm.js
8
xm.js
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue