mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-07-30 16:29:15 +02:00
measure power for mpx with no audio too
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ float measure_mpx(MPXPowerMeasurement* mpx, float deviation) {
|
|||||||
mpx->sample += deviation * deviation; // rmS
|
mpx->sample += deviation * deviation; // rmS
|
||||||
mpx->i++;
|
mpx->i++;
|
||||||
|
|
||||||
float avg_deviation = sqrtf(mpx->sample / mpx->i);
|
float avg_deviation = sqrtf(mpx->sample / mpx->i); // RMs
|
||||||
float modulation_power = deviation_to_dbr(avg_deviation);
|
float modulation_power = deviation_to_dbr(avg_deviation);
|
||||||
|
|
||||||
if (mpx->i >= mpx->sample_rate * 60) {
|
if (mpx->i >= mpx->sample_rate * 60) {
|
||||||
|
|||||||
+4
-1
@@ -451,6 +451,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
MPXPowerMeasurement power;
|
MPXPowerMeasurement power;
|
||||||
init_modulation_power_measure(&power, sample_rate);
|
init_modulation_power_measure(&power, sample_rate);
|
||||||
|
MPXPowerMeasurement mpx_only_power;
|
||||||
|
init_modulation_power_measure(&mpx_only_power, sample_rate);
|
||||||
|
|
||||||
signal(SIGINT, stop);
|
signal(SIGINT, stop);
|
||||||
signal(SIGTERM, stop);
|
signal(SIGTERM, stop);
|
||||||
@@ -540,9 +542,10 @@ int main(int argc, char **argv) {
|
|||||||
if(mpx_on) mpx += hard_clip(current_mpx_in, MPX_CLIPPER_THRESHOLD)*MPX_VOLUME;
|
if(mpx_on) mpx += hard_clip(current_mpx_in, MPX_CLIPPER_THRESHOLD)*MPX_VOLUME;
|
||||||
if(sca_on) mpx += modulate_fm(&sca_mod, hard_clip(current_sca_in, sca_clipper_threshold))*SCA_VOLUME;
|
if(sca_on) mpx += modulate_fm(&sca_mod, hard_clip(current_sca_in, sca_clipper_threshold))*SCA_VOLUME;
|
||||||
|
|
||||||
|
float mpx_only = measure_mpx(&mpx_only_power, mpx * mpx_deviation);
|
||||||
float mpower = measure_mpx(&power, (audio+mpx) * mpx_deviation);
|
float mpower = measure_mpx(&power, (audio+mpx) * mpx_deviation);
|
||||||
if (mpower > mpx_power) {
|
if (mpower > mpx_power) {
|
||||||
float excess_power = mpower - mpx_power;
|
float excess_power = mpower - mpx_power - mpx_only_power;
|
||||||
audio *= (dbr_to_deviation(-excess_power)/mpx_deviation);
|
audio *= (dbr_to_deviation(-excess_power)/mpx_deviation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user