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 {
290 if (
p_io !=
nullptr) {
307 const T
vsa = EqDenormalGuard<T>::value();
345 int16_t* p_dataT = (int16_t*)data;
346 size_t sample_count = len /
sizeof(int16_t);
349 p_dataT[j + ch] = EqSampleConverter<int16_t, T>::fromEqType(
350 sample(
state[ch], EqSampleConverter<int16_t, T>::toEqType(
351 p_dataT[j + ch], 16)),
358 size_t sample_count = len /
sizeof(
int24_t);
361 p_dataT[j + ch] = EqSampleConverter<int24_t, T>::fromEqType(
362 sample(
state[ch], EqSampleConverter<int24_t, T>::toEqType(
363 p_dataT[j + ch], 24)),
369 int32_t* p_dataT = (int32_t*)data;
370 size_t sample_count = len /
sizeof(int32_t);
373 p_dataT[j + ch] = EqSampleConverter<int32_t, T>::fromEqType(
374 sample(
state[ch], EqSampleConverter<int32_t, T>::toEqType(
375 p_dataT[j + ch], 32)),
410 m = es.
sdm3 - (h + l);
443template <
typename T =
float>
514 state[j].
lf = eqAssignCoeff<T>(
518 state[j].
hf = eqAssignCoeff<T>(
542 if (channel >= 0 && channel < p_cfg->channels && !
freq_low.
empty()) {
547 if (
state !=
nullptr) {
548 state[channel].
lf = eqAssignCoeff<T>(
552 state[channel].
hf = eqAssignCoeff<T>(
566 float gain_high_val) {
568 if (channel >= 0 && channel < p_cfg->channels && !
gain_low.
empty()) {
581 int& freq_high_val) {
582 if (channel >= 0 && channel < p_cfg->channels && !
freq_low.
empty()) {
597 float& gain_high_val) {
598 if (channel >= 0 && channel < p_cfg->channels && !
gain_low.
empty()) {
611 size_t write(
const uint8_t* data,
size_t len)
override {
630 if (
p_io !=
nullptr) {
647 const T
vsa = EqDenormalGuard<T>::value();
699 for (
int i = 0; i < num_channels; i++) {
715 int16_t* p_dataT = (int16_t*)data;
716 size_t sample_count = len /
sizeof(int16_t);
719 p_dataT[j + ch] = EqSampleConverter<int16_t, T>::fromEqType(
720 sample(ch, EqSampleConverter<int16_t, T>::toEqType(
721 p_dataT[j + ch], 16)),
728 size_t sample_count = len /
sizeof(
int24_t);
731 p_dataT[j + ch] = EqSampleConverter<int24_t, T>::fromEqType(
732 sample(ch, EqSampleConverter<int24_t, T>::toEqType(
733 p_dataT[j + ch], 24)),
739 int32_t* p_dataT = (int32_t*)data;
740 size_t sample_count = len /
sizeof(int32_t);
743 p_dataT[j + ch] = EqSampleConverter<int32_t, T>::fromEqType(
744 sample(ch, EqSampleConverter<int32_t, T>::toEqType(
745 p_dataT[j + ch], 32)),
785 m = es.
sdm3 - (h + l);
795 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 void flush()
Definition Arduino.h:130
virtual size_t readBytes(uint8_t *data, size_t len)
Definition Arduino.h:140
virtual int available()
Definition Arduino.h:139