Replace a few doubles with floats. According to the raspberry-pi-pico-c-sdk manual, doubles are around 3 times slower than floats.
This commit is contained in:
parent
dbf35e8b60
commit
ea043f76c5
|
@ -136,7 +136,7 @@ bool validate_filter_configuration(filter_configuration_tlv *filters)
|
|||
printf("Error! Not enough data left for filter6 (%d)\n", remaining);
|
||||
return false;
|
||||
}
|
||||
if (args->a0 == 0.0) {
|
||||
if (args->a0 == 0.0f) {
|
||||
printf("Error! The a0 co-efficient of an IIR filter must not be 0.\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ void apply_filter_configuration(filter_configuration_tlv *filters) {
|
|||
uint32_t checksum = 0;
|
||||
for (int i = 0; i < sizeof(filter6) / 4; i++) checksum ^= ((uint32_t*) args)[i];
|
||||
if (checksum != bqf_filter_checksum[filter_stages]) {
|
||||
bqf_filters_left[filter_stages].a0 = fix3_28_from_dbl(1.0);
|
||||
bqf_filters_left[filter_stages].a0 = fix16_one;
|
||||
bqf_filters_left[filter_stages].a1 = fix3_28_from_dbl(args->a1/args->a0);
|
||||
bqf_filters_left[filter_stages].a2 = fix3_28_from_dbl(args->a2/args->a0);
|
||||
bqf_filters_left[filter_stages].b0 = fix3_28_from_dbl(args->b0/args->a0);
|
||||
|
@ -315,7 +315,7 @@ bool apply_configuration(tlv_header *config) {
|
|||
#ifndef TEST_TARGET
|
||||
case PREPROCESSING_CONFIGURATION: {
|
||||
preprocessing_configuration_tlv* preprocessing_config = (preprocessing_configuration_tlv*) tlv;
|
||||
preprocessing.preamp = fix3_28_from_dbl(1.0 + preprocessing_config->preamp);
|
||||
preprocessing.preamp = fix3_28_from_flt(1.0f + preprocessing_config->preamp);
|
||||
preprocessing.reverse_stereo = preprocessing_config->reverse_stereo;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ static inline fix3_28_t norm_fix3_28_from_s16sample(int16_t);
|
|||
|
||||
static inline int16_t norm_fix3_28_to_s16sample(fix3_28_t);
|
||||
|
||||
static inline fix3_28_t fix3_28_from_flt(float);
|
||||
|
||||
static inline fix3_28_t fix3_28_from_dbl(double);
|
||||
|
||||
static inline fix3_28_t fix16_mul(fix3_28_t, fix3_28_t);
|
||||
|
|
|
@ -74,6 +74,12 @@ static inline int16_t norm_fix3_28_to_s16sample(fix3_28_t a) {
|
|||
return (a >> 12);
|
||||
}
|
||||
|
||||
static inline fix3_28_t fix3_28_from_flt(float a) {
|
||||
float temp = a * fix16_one;
|
||||
temp += ((temp >= 0) ? 0.5f : -0.5f);
|
||||
return (fix3_28_t)temp;
|
||||
}
|
||||
|
||||
static inline fix3_28_t fix3_28_from_dbl(double a) {
|
||||
double temp = a * fix16_one;
|
||||
temp += (double)((temp >= 0) ? 0.5f : -0.5f);
|
||||
|
|
|
@ -291,6 +291,7 @@ void setup() {
|
|||
* IF YOU DO, YOU COULD BLOW UP YOUR HARDWARE! *
|
||||
* YOU WERE WARNED!!!!!!!!!!!!!!!! *
|
||||
****************************************************************************/
|
||||
// TODO: roundf will be much faster than round, but it might mess with timings
|
||||
void configure_neg_switch_pwm() {
|
||||
gpio_set_function(NEG_SWITCH_PWM_PIN, GPIO_FUNC_PWM);
|
||||
uint slice_num = pwm_gpio_to_slice_num(NEG_SWITCH_PWM_PIN);
|
||||
|
|
Loading…
Reference in New Issue