X-Git-Url: https://git.sesse.net/?p=c64tapwav;a=blobdiff_plain;f=level.cpp;h=504cf0bbf7549170600674140fff7460c14c85f9;hp=46a494f8ca7070ec26f5d7bd0042331531bab954;hb=8abf7912f0cc520302437221265484c83bb857e5;hpb=4a894453d8e0e92c452689fbea07cdfb34869a83 diff --git a/level.cpp b/level.cpp index 46a494f..504cf0b 100644 --- a/level.cpp +++ b/level.cpp @@ -8,11 +8,6 @@ #include "filter.h" -// The frequency to filter on, in Hertz. Larger values makes the -// compressor react faster, but if it is too large, you'll -// ruin the waveforms themselves. -#define LPFILTER_FREQ 50.0 - // A final scalar to get the audio within approximately the right range. // Increase to _lower_ overall volume. #define DAMPENING_FACTOR 5.0 @@ -20,7 +15,7 @@ // 6dB/oct per round. #define FILTER_DEPTH 4 -std::vector level_samples(const std::vector &pcm, float min_level, int sample_rate) +std::vector level_samples(const std::vector &pcm, float min_level, float lpfilter_freq, int sample_rate) { // filter forwards, then backwards (perfect phase filtering) std::vector filtered_samples, refiltered_samples, leveled_samples; @@ -28,7 +23,7 @@ std::vector level_samples(const std::vector &pcm, float min_level, refiltered_samples.resize(pcm.size()); leveled_samples.resize(pcm.size()); - Filter filter = Filter::lpf(2.0 * M_PI * LPFILTER_FREQ / sample_rate); + Filter filter = Filter::lpf(2.0 * M_PI * lpfilter_freq / sample_rate); for (unsigned i = 0; i < pcm.size(); ++i) { filtered_samples[i] = filter.update(fabs(pcm[i])); }