75T eqAssignCoeff(
float value,
const char* name) {
77 float roundtrip = (float)t;
78 if (fabs(roundtrip - value) > fabs(value) * 0.01f + 1e-4f) {
80 "Equalizer coefficient %s=%f does not fit in the range of T (stored "
81 "as %f) - the equalizer will be inaccurate",
82 name, value, roundtrip);
96struct EqDenormalGuard {
97 static T value() {
return T(0); }
100struct EqDenormalGuard<float> {
101 static float value() {
return 1.0f / 4294967295.0f; }
104struct EqDenormalGuard<double> {
105 static double value() {
return 1.0 / 4294967295.0; }
117template <
typename IntT,
typename T>
118struct EqSampleConverter {
119 static T toEqType(IntT sample,
int bits) {
120 return FilterSampleConverter<IntT, T>::toFilterType(sample);
122 static IntT fromEqType(T value,
int bits) {
123 return FilterSampleConverter<IntT, T>::fromFilterType(value);
126template <
typename IntT>
127struct EqSampleConverter<IntT, float> {
128 static float toEqType(IntT sample,
int bits) {
129 return NumberConverter::toFloat((int32_t)sample, bits);
131 static IntT fromEqType(
float value,
int bits) {
132 return (IntT)NumberConverter::fromFloat(value, bits);
171template <
typename T =
float>
243 state[j].
lf = eqAssignCoeff<T>(
247 state[j].
hf = eqAssignCoeff<T>(
271 size_t write(
const uint8_t* data,
size_t len)
override {
303 const T
vsa = EqDenormalGuard<T>::value();
341 int16_t* p_dataT = (int16_t*)data;
342 size_t sample_count = len /
sizeof(int16_t);
345 p_dataT[j + ch] = EqSampleConverter<int16_t, T>::fromEqType(
346 sample(
state[ch], EqSampleConverter<int16_t, T>::toEqType(
347 p_dataT[j + ch], 16)),
354 size_t sample_count = len /
sizeof(
int24_t);
357 p_dataT[j + ch] = EqSampleConverter<int24_t, T>::fromEqType(
358 sample(
state[ch], EqSampleConverter<int24_t, T>::toEqType(
359 p_dataT[j + ch], 24)),
365 int32_t* p_dataT = (int32_t*)data;
366 size_t sample_count = len /
sizeof(int32_t);
369 p_dataT[j + ch] = EqSampleConverter<int32_t, T>::fromEqType(
370 sample(
state[ch], EqSampleConverter<int32_t, T>::toEqType(
371 p_dataT[j + ch], 32)),
406 m = es.
sdm3 - (h + l);
439template <
typename T =
float>
510 state[j].
lf = eqAssignCoeff<T>(
514 state[j].
hf = eqAssignCoeff<T>(
538 if (channel >= 0 && channel < p_cfg->channels && !
freq_low.
empty()) {
543 if (
state !=
nullptr) {
544 state[channel].
lf = eqAssignCoeff<T>(
548 state[channel].
hf = eqAssignCoeff<T>(
562 float gain_high_val) {
564 if (channel >= 0 && channel < p_cfg->channels && !
gain_low.
empty()) {
577 int& freq_high_val) {
578 if (channel >= 0 && channel < p_cfg->channels && !
freq_low.
empty()) {
593 float& gain_high_val) {
594 if (channel >= 0 && channel < p_cfg->channels && !
gain_low.
empty()) {
607 size_t write(
const uint8_t* data,
size_t len)
override {
639 const T
vsa = EqDenormalGuard<T>::value();
691 for (
int i = 0; i < num_channels; i++) {
707 int16_t* p_dataT = (int16_t*)data;
708 size_t sample_count = len /
sizeof(int16_t);
711 p_dataT[j + ch] = EqSampleConverter<int16_t, T>::fromEqType(
712 sample(ch, EqSampleConverter<int16_t, T>::toEqType(
713 p_dataT[j + ch], 16)),
720 size_t sample_count = len /
sizeof(
int24_t);
723 p_dataT[j + ch] = EqSampleConverter<int24_t, T>::fromEqType(
724 sample(ch, EqSampleConverter<int24_t, T>::toEqType(
725 p_dataT[j + ch], 24)),
731 int32_t* p_dataT = (int32_t*)data;
732 size_t sample_count = len /
sizeof(int32_t);
735 p_dataT[j + ch] = EqSampleConverter<int32_t, T>::fromEqType(
736 sample(ch, EqSampleConverter<int32_t, T>::toEqType(
737 p_dataT[j + ch], 32)),
777 m = es.
sdm3 - (h + l);
787 es.
sdm1 = sample_val;
#define PI
Definition AudioEffectsSuite.h:28
#define LOGE(...)
Definition AudioLoggerIDF.h:30
virtual int availableForWrite()
Definition Arduino.h:128
virtual size_t write(const uint8_t *data, size_t len)
Definition Arduino.h:120
virtual size_t readBytes(uint8_t *data, size_t len)
Definition Arduino.h:140
virtual int available()
Definition Arduino.h:139