0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00

make bs412 measure output

This commit is contained in:
2026-01-23 22:39:49 +01:00
parent 13dcf3c726
commit f938e26c80
2 changed files with 5 additions and 1 deletions

View File

@@ -22,13 +22,14 @@ void init_bs412(BS412Compressor* mpx, uint32_t mpx_deviation, float target_power
mpx->gain = 0.0f;
mpx->can_compress = 0;
mpx->second_counter = 0;
mpx->last_output = 0.0f;
#ifdef BS412_DEBUG
debug_printf("Initialized MPX power measurement with sample rate: %d\n", sample_rate);
#endif
}
float bs412_compress(BS412Compressor* mpx, float sample) {
mpx->avg_power += mpx->alpha * ((sample * sample * mpx->mpx_deviation * mpx->mpx_deviation) - mpx->avg_power);
mpx->avg_power += mpx->alpha * ((mpx->last_output * mpx->last_output * mpx->mpx_deviation * mpx->mpx_deviation) - mpx->avg_power);
float avg_deviation = sqrtf(mpx->avg_power);
float modulation_power = deviation_to_dbr(avg_deviation);
@@ -84,5 +85,7 @@ float bs412_compress(BS412Compressor* mpx, float sample) {
}
mpx->sample_counter++;
mpx->last_output = output_sample;
return output_sample;
}

View File

@@ -24,6 +24,7 @@ typedef struct
double alpha;
uint8_t can_compress : 1;
uint8_t second_counter;
float last_output;
} BS412Compressor;
float dbr_to_deviation(float dbr);