/* * Brickworks * * Copyright (C) 2023 Orastron Srl unipersonale * * Brickworks is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * Brickworks is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Brickworks. If not, see . * * File author: Stefano D'Angelo */ #ifndef BWPP_ONE_POLE_H #define BWPP_ONE_POLE_H #include #include namespace Brickworks { template class OnePole { public: OnePole(); void setSampleRate(float sampleRate); void reset(float y_z1 = 0.f); void process( std::array x, std::array y, int nSamples); void setCutoff(float value); void setCutoffUp(float value); void setCutoffDown(float value); void setTau(float value); void setTauUp(float value); void setTauDown(float value); void setStickyThresh(float value); void setStickyMode(bw_one_pole_sticky_mode value); float getYZ1(BW_SIZE_T channel); private: bw_one_pole_coeffs coeffs; bw_one_pole_state states[N_CHANNELS]; bw_one_pole_state *statesP[N_CHANNELS]; }; template OnePole::OnePole() { bw_one_pole_init(&coeffs); for (BW_SIZE_T i = 0; i < N_CHANNELS; i++) statesP[i] = states + i; } template void OnePole::setSampleRate(float sampleRate) { bw_one_pole_set_sample_rate(&coeffs, sampleRate); } template void OnePole::reset(float y_z1) { bw_one_pole_reset_coeffs(&coeffs); for (BW_SIZE_T i = 0; i < N_CHANNELS; i++) bw_one_pole_reset_state(&coeffs, states + i, y_z1); } template void OnePole::process( std::array x, std::array y, int nSamples) { bw_one_pole_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); } template void OnePole::setCutoff(float value) { bw_one_pole_set_cutoff(&coeffs, value); } template void OnePole::setCutoffUp(float value) { bw_one_pole_set_cutoff_up(&coeffs, value); } template void OnePole::setCutoffDown(float value) { bw_one_pole_set_cutoff_down(&coeffs, value); } template void OnePole::setTau(float value) { bw_one_pole_set_tau(&coeffs, value); } template void OnePole::setTauUp(float value) { bw_one_pole_set_tau_up(&coeffs, value); } template void OnePole::setTauDown(float value) { bw_one_pole_set_tau_down(&coeffs, value); } template void OnePole::setStickyThresh(float value) { bw_one_pole_set_sticky_thresh(&coeffs, value); } template void OnePole::setStickyMode(bw_one_pole_sticky_mode value) { bw_one_pole_set_sticky_mode(&coeffs, value); } template float OnePole::getYZ1(BW_SIZE_T channel) { return bw_one_pole_get_y_z1(states + channel); } } #endif