BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

experiments.hpp (1056B)


      1 #pragma once
      2 
      3 #include "filters/filter.hpp"
      4 
      5 namespace bogaudio {
      6 namespace dsp {
      7 
      8 struct ComplexBiquadFilter : BiquadFilter<float> {
      9 	float _gain = 1.0f;
     10 	float _zeroRadius = 1.0f;
     11 	float _zeroTheta = M_PI;
     12 	float _poleRadius = 0.9f;
     13 	float _poleTheta = 0.0f;
     14 
     15 	ComplexBiquadFilter() {
     16 		updateParams();
     17 	}
     18 
     19 	void setComplexParams(
     20 		float gain,
     21 		float zeroRadius,
     22 		float zeroTheta,
     23 		float poleRadius,
     24 		float poleTheta
     25 	);
     26 	void updateParams();
     27 };
     28 
     29 struct MultipoleFilter : Filter {
     30 	enum Type {
     31 		LP_TYPE,
     32 		HP_TYPE
     33 	};
     34 
     35 	static constexpr int maxPoles = 20;
     36 	static constexpr float maxRipple = 0.29f;
     37 	Type _type = LP_TYPE;
     38 	int _poles = 1;
     39 	float _sampleRate = 0.0f;
     40 	float _cutoff = 0.0f;
     41 	float _ripple = 0.0f;
     42 	BiquadFilter<double> _biquads[maxPoles / 2];
     43 
     44 	MultipoleFilter() {}
     45 
     46 	void setParams(
     47 		Type type,
     48 		int poles,
     49 		float sampleRate,
     50 		float cutoff,
     51 		float ripple // FIXME: using this with more than two poles creates large gain, need compensation.
     52 	);
     53 	float next(float sample) override;
     54 };
     55 
     56 } // namespace dsp
     57 } // namespace bogaudio