Skip to content

Commit

Permalink
Move band-pass fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pcprince committed Jul 17, 2024
1 parent 17df0d0 commit f65c718
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 0 additions & 10 deletions scripts/butterworth.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,6 @@ function applyBandPassFilter (input, inputLength, output, sampleRate, freq1, fre

}

if (freq2 >= sampleRate / 2) {

console.log('Applying high-pass filter as band-pass top value = Nyquist');

applyHighPassFilter(input, inputLength, output, sampleRate, freq1);

return;

}

const filterCoefficients = designFilter(BUTTERWORTH_FILTER_BAND, sampleRate, freq1, freq2);

const filter = {
Expand Down
12 changes: 11 additions & 1 deletion scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,17 @@ function getRenderSamples (reapplyFilter, updateThresholdedSampleArray, recalcul
bandPassFilterValue1 = Math.max(...bandPassFilterSlider.getValue());
console.log('Applying band-pass filter between', bandPassFilterValue0, 'and', bandPassFilterValue1, 'Hz');

applyBandPassFilter(downsampledUnfilteredSamples, sampleCount, filteredSamples, getSampleRate(), bandPassFilterValue0, bandPassFilterValue1);
if (bandPassFilterValue1 < sampleRate / 2) {

applyBandPassFilter(downsampledUnfilteredSamples, sampleCount, filteredSamples, getSampleRate(), bandPassFilterValue0, bandPassFilterValue1);

} else {

console.log('Applying high-pass filter as band-pass top value = Nyquist');

applyHighPassFilter(downsampledUnfilteredSamples, sampleCount, filteredSamples, getSampleRate(), bandPassFilterValue1);

}

break;

Expand Down

0 comments on commit f65c718

Please sign in to comment.