mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
try to measure mpx power
This commit is contained in:
23
lib/bs412.c
Normal file
23
lib/bs412.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "bs412.h"
|
||||
|
||||
void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) {
|
||||
mpx->i = 0;
|
||||
mpx->sample = 0;
|
||||
mpx->sample_rate = sample_rate;
|
||||
}
|
||||
|
||||
float measure_mpx(MPXPowerMeasurement* mpx, int deviation) {
|
||||
mpx->sample += 20*log10f(deviation/19);
|
||||
mpx->i++;
|
||||
|
||||
if (mpx->i >= mpx->sample_rate) {
|
||||
float modulation_power = mpx->sample/mpx->i;
|
||||
|
||||
mpx->sample = 0.0f;
|
||||
mpx->i = 0;
|
||||
|
||||
return modulation_power;
|
||||
} else {
|
||||
return mpx->sample/mpx->i;
|
||||
}
|
||||
}
|
||||
13
lib/bs412.h
Normal file
13
lib/bs412.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int i;
|
||||
int sample_rate;
|
||||
float sample;
|
||||
} MPXPowerMeasurement;
|
||||
|
||||
void init_modulation_power_measure(MPXPowerMeasurement *mpx, int sample_rate);
|
||||
|
||||
float measure_mpx(MPXPowerMeasurement *mpx, int deviation);
|
||||
Reference in New Issue
Block a user