mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 11:22:00 +01:00
change bs412 gain reduction logic, still issue #2 should be unchanged
This commit is contained in:
12
dsp/bs412.c
12
dsp/bs412.c
@@ -1,5 +1,7 @@
|
||||
#include "bs412.h"
|
||||
|
||||
#define BS412_RMS
|
||||
|
||||
#define LOG2_19000 log2f(19000.0f)
|
||||
|
||||
inline float dbr_to_deviation(float dbr) {
|
||||
@@ -21,11 +23,19 @@ void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) {
|
||||
}
|
||||
|
||||
float measure_mpx(MPXPowerMeasurement* mpx, float deviation) {
|
||||
#ifdef BS412_RMS
|
||||
mpx->sample += deviation * deviation; // rmS
|
||||
#else
|
||||
mpx->sample += fabsf(deviation);
|
||||
#endif
|
||||
mpx->sample_counter++;
|
||||
|
||||
float inv_counter = 1.0f / mpx->sample_counter;
|
||||
#ifdef BS412_RMS
|
||||
float avg_deviation = sqrtf(mpx->sample * inv_counter); // RMs
|
||||
#else
|
||||
float avg_deviation = mpx->sample * inv_counter; // RMs
|
||||
#endif
|
||||
float modulation_power = deviation_to_dbr(avg_deviation);
|
||||
|
||||
#ifdef BS412_DEBUG
|
||||
@@ -38,7 +48,7 @@ float measure_mpx(MPXPowerMeasurement* mpx, float deviation) {
|
||||
#ifdef BS412_DEBUG
|
||||
debug_printf("Resetting MPX power measurement\n");
|
||||
#endif
|
||||
mpx->sample = avg_deviation * avg_deviation;
|
||||
mpx->sample = deviation * deviation;
|
||||
mpx->sample_counter = 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user