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

make bs412 fully rms

This commit is contained in:
Kuba
2025-04-18 22:32:11 +02:00
committed by GitHub
parent 20b61edd2b
commit 120296d8e2

View File

@@ -1,11 +1,11 @@
#include "bs412.h"
float dbr_to_deviation(float dbr) {
return (19000.0f * 0.70710678f) * powf(10.0f, dbr / 20.0f);
return 19000.0f * powf(10.0f, dbr / 20.0f);
}
float deviation_to_dbr(float deviation) {
return 20 * log10f((deviation + 1e-6f) / (19000.0f * 0.70710678f));
return 20 * log10f((deviation + 1e-6f) / 19000.0f);
}
void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) {
@@ -15,7 +15,7 @@ void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) {
}
float measure_mpx(MPXPowerMeasurement* mpx, float deviation) {
mpx->sample += deviation * deviation;
mpx->sample += deviation * deviation; // rmS
mpx->i++;
float avg_deviation = sqrtf(mpx->sample / mpx->i);