diff --git a/firmware/code/bqf.c b/firmware/code/bqf.c index 2c936b4..6e0b8e0 100644 --- a/firmware/code/bqf.c +++ b/firmware/code/bqf.c @@ -483,8 +483,8 @@ fix16_t bqf_transform(fix16_t x, bqf_coeff_t *coefficients, bqf_mem_t *memory) { } void bqf_memreset(bqf_mem_t *memory) { - memory->x_1 = fix16_from_dbl(0.0); - memory->x_2 = fix16_from_dbl(0.0); - memory->y_1 = fix16_from_dbl(0.0); - memory->y_2 = fix16_from_dbl(0.0); + memory->x_1 = fix16_zero; + memory->x_2 = fix16_zero; + memory->y_1 = fix16_zero; + memory->y_2 = fix16_zero; } diff --git a/firmware/code/configuration_manager.c b/firmware/code/configuration_manager.c index 6c13070..7b0f37b 100644 --- a/firmware/code/configuration_manager.c +++ b/firmware/code/configuration_manager.c @@ -140,17 +140,17 @@ void apply_filter_configuration(filter_configuration_tlv *filters) { uint8_t *ptr = (uint8_t *)filters->header.value; const uint8_t *end = (uint8_t *)filters + filters->header.length; filter_stages = 0; + bool type_changed = false; while ((ptr + 4) < end) { const uint8_t type = *ptr; // If you reset the memory, you can hear it when you move the sliders on the UI, - // is it perhaps OK to leave these and let the old values drop off over time? - // Ensure we at least clear the memory if the filter type changes, as this can sound bad. - static uint8_t bqf_filter_types[MAX_FILTER_STAGES] = { 0xFF }; + // so try to preserve our remembered values. + // If a filter type changes, we do a memory reset. + static uint8_t bqf_filter_types[MAX_FILTER_STAGES] = { }; if (type != bqf_filter_types[filter_stages]) { - bqf_memreset(&bqf_filters_mem_left[filter_stages]); - bqf_memreset(&bqf_filters_mem_right[filter_stages]); bqf_filter_types[filter_stages] = type; + type_changed = true; } switch (type) { @@ -168,6 +168,13 @@ void apply_filter_configuration(filter_configuration_tlv *filters) { } filter_stages++; } + + if (type_changed) { + for (int i=0; i