/* * Brickworks * * Copyright (C) 2025 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 */ /*! * module_type {{{ utility }}} * version {{{ 1.0.0 }}} * requires {{{ bw_common bw_math }}} * description {{{ * XXX * }}} * changelog {{{ * * }}} */ #ifndef BW_IIR1_H #define BW_IIR1_H #ifdef BW_INCLUDE_WITH_QUOTES # include "bw_common.h" #else # include #endif #if !defined(BW_CXX_NO_EXTERN_C) && defined(__cplusplus) extern "C" { #endif /*** Public API ***/ /*! api {{{ * #### bw_iir1_reset() * ```>>> */ static inline void bw_iir1_reset( float x_0, float * BW_RESTRICT y_0, float * BW_RESTRICT s_0, float b0, float b1, float a1); /*! <<<``` * XXX. * * #### bw_iir1_reset_multi() * ```>>> */ static inline void bw_iir1_reset_multi( const float * x_0, float * y_0, float * BW_RESTRICT s_0, float b0, float b1, float a1, size_t n_channels); /*! <<<``` * XXX. * * #### bw_iir1_process1() * ```>>> */ static inline void bw_iir1_process1( float x, float * BW_RESTRICT y, float * BW_RESTRICT s, float b0, float b1, float a1); /*! <<<``` * XXX. * * #### bw_iir1_process() * ```>>> */ static inline void bw_iir1_process( const float * x, float * y, float * BW_RESTRICT s, float b0, float b1, float a1, size_t n_samples); /*! <<<``` * XXX * * #### bw_iir1_process_multi() * ```>>> */ static inline void bw_iir1_process_multi( const float * const * x, float * const * y, float * BW_RESTRICT s, float b0, float b1, float a1, size_t n_channels, size_t n_samples); /*! <<<``` * XXX * * #### bw_iir1_coeffs_ap1() * ```>>> */ static inline void bw_iir1_coeffs_ap1( float sample_rate, float cutoff, float prewarp_freq, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_hp1() * ```>>> */ static inline void bw_iir1_coeffs_hp1( float sample_rate, float cutoff, float prewarp_freq, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_hs1_lin() * ```>>> */ static inline void bw_iir1_coeffs_hs1_lin( float sample_rate, float cutoff, float prewarp_freq, float high_gain_lin, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_hs1_dB() * ```>>> */ static inline void bw_iir1_coeffs_hs1_dB( float sample_rate, float cutoff, float prewarp_freq, float high_gain_dB, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_lp1() * ```>>> */ static inline void bw_iir1_coeffs_lp1( float sample_rate, float cutoff, float prewarp_freq, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_ls1_lin() * ```>>> */ static inline void bw_iir1_coeffs_ls1_lin( float sample_rate, float cutoff, float prewarp_freq, float dc_gain_lin, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_ls1_dB() * ```>>> */ static inline void bw_iir1_coeffs_ls1_dB( float sample_rate, float cutoff, float prewarp_freq, float dc_gain_dB, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * * #### bw_iir1_coeffs_mm1() * ```>>> */ static inline void bw_iir1_coeffs_mm1( float sample_rate, float cutoff, float prewarp_freq, float coeff_x, float coeff_lp, float * BW_RESTRICT b0, float * BW_RESTRICT b1, float * BW_RESTRICT a1); /*! <<<``` * XXX * }}} */ #if !defined(BW_CXX_NO_EXTERN_C) && defined(__cplusplus) } #endif /*** Implementation ***/ /* WARNING: This part of the file is not part of the public API. Its content may * change at any time in future versions. Please, do not use it directly. */ #ifdef BW_INCLUDE_WITH_QUOTES # include "bw_math.h" #else # include #endif #if !defined(BW_CXX_NO_EXTERN_C) && defined(__cplusplus) extern "C" { #endif static void bw_iir1_reset( float x_0, float * BW_RESTRICT y_0, float * BW_RESTRICT s_0, float b0, float b1, float a1) { // -1 # endif namespace Brickworks { /*** Public C++ API ***/ /*! api_cpp {{{ * ##### Brickworks::iir1Reset * ```>>> */ template void iir1Reset( const float * x0, float * y0, float * BW_RESTRICT s0, float b0, float b1, float a1); # ifndef BW_CXX_NO_ARRAY template void iir1Reset( std::array x0, std::array * BW_RESTRICT y0, std::array * BW_RESTRICT s0, float b0, float b1, float a1); # endif template void iir1Process( const float * const * x, float * const * y, float * BW_RESTRICT s, float b0, float b1, float a1, size_t nSamples); # ifndef BW_CXX_NO_ARRAY template void iir1Process( std::array x, std::array y, std::array * BW_RESTRICT s, float b0, float b1, float a1, size_t nSamples); # endif /*! <<<``` * }}} */ /*** Implementation ***/ /* WARNING: This part of the file is not part of the public API. Its content may * change at any time in future versions. Please, do not use it directly. */ template inline void iir1Reset( const float * x0, float * y0, float * BW_RESTRICT s0, float b0, float b1, float a1) { bw_iir1_reset_multi(x0, y0, s0, b0, b1, a1, N_CHANNELS); } # ifndef BW_CXX_NO_ARRAY template inline void iir1Reset( std::array x0, std::array * BW_RESTRICT y0, std::array * BW_RESTRICT s0, float b0, float b1, float a1) { iir1Reset(x0.data(), y0 != nullptr ? y0.data() : nullptr, s0 != nullptr ? s0.data() : nullptr, b0, b1, a1); } # endif template inline void iir1Process( const float * const * x, float * const * y, float * BW_RESTRICT s, float b0, float b1, float a1, size_t nSamples) { bw_iir1_process_multi(x, y, s, b0, b1, a1, N_CHANNELS, nSamples); } # ifndef BW_CXX_NO_ARRAY template inline void iir1Process( std::array x, std::array y, std::array * BW_RESTRICT s, float b0, float b1, float a1, size_t nSamples) { iir1Process(x.data(), y.data(), s.data(), b0, b1, a1, nSamples); } # endif } #endif #endif