Increase config buffer size, and make the bqf_transform function inline
This commit is contained in:
parent
635dac208a
commit
5bdae0fc3c
|
@ -467,21 +467,6 @@ void bqf_highshelf_config(double fs, double f0, double dBgain, double Q,
|
||||||
coefficients->a2 = fix3_28_from_dbl(a2);
|
coefficients->a2 = fix3_28_from_dbl(a2);
|
||||||
}
|
}
|
||||||
|
|
||||||
fix3_28_t bqf_transform(fix3_28_t x, bqf_coeff_t *coefficients, bqf_mem_t *memory) {
|
|
||||||
fix3_28_t y = fix16_mul(coefficients->b0, x) -
|
|
||||||
fix16_mul(coefficients->a1, memory->y_1) +
|
|
||||||
fix16_mul(coefficients->b1, memory->x_1) -
|
|
||||||
fix16_mul(coefficients->a2, memory->y_2) +
|
|
||||||
fix16_mul(coefficients->b2, memory->x_2);
|
|
||||||
|
|
||||||
memory->x_2 = memory->x_1;
|
|
||||||
memory->x_1 = x;
|
|
||||||
memory->y_2 = memory->y_1;
|
|
||||||
memory->y_1 = y;
|
|
||||||
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bqf_memreset(bqf_mem_t *memory) {
|
void bqf_memreset(bqf_mem_t *memory) {
|
||||||
memory->x_1 = fix16_zero;
|
memory->x_1 = fix16_zero;
|
||||||
memory->x_2 = fix16_zero;
|
memory->x_2 = fix16_zero;
|
||||||
|
|
|
@ -65,7 +65,8 @@ void bqf_peaking_config(double, double, double, double, bqf_coeff_t *);
|
||||||
void bqf_lowshelf_config(double, double, double, double, bqf_coeff_t *);
|
void bqf_lowshelf_config(double, double, double, double, bqf_coeff_t *);
|
||||||
void bqf_highshelf_config(double, double, double, double, bqf_coeff_t *);
|
void bqf_highshelf_config(double, double, double, double, bqf_coeff_t *);
|
||||||
|
|
||||||
fix3_28_t bqf_transform(fix3_28_t, bqf_coeff_t *, bqf_mem_t *);
|
static inline fix3_28_t bqf_transform(fix3_28_t, bqf_coeff_t *, bqf_mem_t *);
|
||||||
void bqf_memreset(bqf_mem_t *);
|
void bqf_memreset(bqf_mem_t *);
|
||||||
|
|
||||||
|
#include "bqf.inl"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2022 Colin Lam, Ploopy Corporation
|
||||||
|
*
|
||||||
|
* This program 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, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* SPECIAL THANKS TO:
|
||||||
|
* Robert Bristow-Johnson, a.k.a. RBJ
|
||||||
|
* for his exceptional work on biquad formulae as applied to digital
|
||||||
|
* audio filtering, summarised in his pamphlet, "Audio EQ Cookbook".
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline fix3_28_t bqf_transform(fix3_28_t x, bqf_coeff_t *coefficients, bqf_mem_t *memory) {
|
||||||
|
fix3_28_t y = fix16_mul(coefficients->b0, x) -
|
||||||
|
fix16_mul(coefficients->a1, memory->y_1) +
|
||||||
|
fix16_mul(coefficients->b1, memory->x_1) -
|
||||||
|
fix16_mul(coefficients->a2, memory->y_2) +
|
||||||
|
fix16_mul(coefficients->b2, memory->x_2);
|
||||||
|
|
||||||
|
memory->x_2 = memory->x_1;
|
||||||
|
memory->x_1 = x;
|
||||||
|
memory->y_2 = memory->y_1;
|
||||||
|
memory->y_1 = y;
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
|
@ -74,7 +74,7 @@ const uint8_t *user_configuration = (const uint8_t *) (XIP_BASE + USER_CONFIGURA
|
||||||
* should handle merging configurations where, for example, only a new
|
* should handle merging configurations where, for example, only a new
|
||||||
* filter_configuration_tlv was received.
|
* filter_configuration_tlv was received.
|
||||||
*/
|
*/
|
||||||
#define CFG_BUFFER_SIZE 256
|
#define CFG_BUFFER_SIZE 512
|
||||||
static uint8_t working_configuration[2][CFG_BUFFER_SIZE];
|
static uint8_t working_configuration[2][CFG_BUFFER_SIZE];
|
||||||
static uint8_t inactive_working_configuration = 0;
|
static uint8_t inactive_working_configuration = 0;
|
||||||
static uint8_t result_buffer[CFG_BUFFER_SIZE] = { U16_TO_U8S_LE(NOK), U16_TO_U8S_LE(0) };
|
static uint8_t result_buffer[CFG_BUFFER_SIZE] = { U16_TO_U8S_LE(NOK), U16_TO_U8S_LE(0) };
|
||||||
|
|
|
@ -133,9 +133,10 @@ static void __no_inline_not_in_flash_func(_as_audio_packet)(struct usb_endpoint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < samples; i++)
|
for (int i = 0; i < samples; i++) {
|
||||||
out[i] = fix16_mul(norm_fix3_28_from_s16sample(in[i]), preprocessing.preamp);
|
out[i] = fix16_mul(norm_fix3_28_from_s16sample(in[i]), preprocessing.preamp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
multicore_fifo_push_blocking(samples);
|
multicore_fifo_push_blocking(samples);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue