[lpf] add low pass filter per channel

This commit is contained in:
thibaud keller 2024-10-30 19:51:40 +00:00
parent 01077168dd
commit 0bcd3b7822
3 changed files with 23 additions and 2 deletions

View file

@ -1,3 +1,5 @@
#include <ranges>
#include <Gamma/scl.h>
#include "Senior.hpp"
@ -13,11 +15,15 @@ void Senior::prepare(setup info)
skipped_frames.resize(info.input_channels);
fms.resize(info.input_channels);
lpfs.resize(info.input_channels);
for (auto& fm : fms)
for (auto [fm, lpf] : std::views::zip(fms, lpfs))
{
fm.set_sample_rate(info.rate);
fm.maxDelay(0.1);
lpf.set_sample_rate(info.rate);
lpf.type(gam::LOW_PASS);
}
phases.resize(info.output_channels);
@ -98,8 +104,16 @@ void Senior::operator()(tick t)
phases[i] = lfo.phase();
}
else
out_frame = current_frame;
out[j] = out_frame;
if (inputs.filter < 1.f)
{
lpfs[i].freq(inputs.filter * 2920. + 80.);
out[j] = lpfs[i](out_frame);
}
else
out[j] = out_frame;
}
}
}

View file

@ -5,6 +5,7 @@
#include <Gamma/Oscillator.h>
#include <Gamma/Delay.h>
#include <Gamma/Filter.h>
#include <halp/compat/gamma.hpp>
#include <halp/audio.hpp>
@ -31,6 +32,7 @@ public:
{
halp::dynamic_audio_bus<"Input", double> audio;
halp::knob_f32<"SAMPLE RATE", halp::range{.min = .1, .max = 1., .init = 1.}> s_rate;
halp::knob_f32<"FILTER", halp::range{.min = 0., .max = 1., .init = 1.}> filter;
using log_map = halp::log_mapper<std::ratio<95, 100>>;
struct : halp::knob_f32<"BITS", halp::range{.min = 3, .max = BITS, .init = BITS}>
@ -83,6 +85,10 @@ private:
gam::ipl::Linear,
halp::compat::gamma_domain>> fms;
std::vector<gam::OnePole<double,
double,
halp::compat::gamma_domain>> lpfs;
void set_bit_factor();
double crush(const double& f);
};

View file

@ -17,6 +17,7 @@ struct Senior::ui
{
halp_meta(layout, hbox)
halp::item<&ins::bits> bits;
halp::item<&ins::filter> filter;
halp::item<&ins::s_rate> s_rate;
} res;