/* * Brickworks * * Copyright (C) 2023 Orastron Srl unipersonale * * Brickworks is free software: you can redriveribute 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 driveributed 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_DRIVE_H #define BWPP_DRIVE_H #include #include namespace Brickworks { template class Drive { public: Drive(); void setSampleRate(float sampleRate); void reset(); void process( std::array x, std::array y, int nSamples); void setDrive(float value); void setTone(float value); void setVolume(float value); private: bw_drive_coeffs coeffs; bw_drive_state states[N_CHANNELS]; bw_drive_state *statesP[N_CHANNELS]; }; template Drive::Drive() { bw_drive_init(&coeffs); for (BW_SIZE_T i = 0; i < N_CHANNELS; i++) statesP[i] = states + i; } template void Drive::setSampleRate(float sampleRate) { bw_drive_set_sample_rate(&coeffs, sampleRate); } template void Drive::reset() { bw_drive_reset_coeffs(&coeffs); for (BW_SIZE_T i = 0; i < N_CHANNELS; i++) bw_drive_reset_state(&coeffs, states + i); } template void Drive::process( std::array x, std::array y, int nSamples) { bw_drive_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); } template void Drive::setDrive(float value) { bw_drive_set_drive(&coeffs, value); } template void Drive::setTone(float value) { bw_drive_set_tone(&coeffs, value); } template void Drive::setVolume(float value) { bw_drive_set_volume(&coeffs, value); } } #endif