mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
change gain reduction logic
This commit is contained in:
2
.vscode/.server-controller-port.log
vendored
2
.vscode/.server-controller-port.log
vendored
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"port": 13452,
|
"port": 13452,
|
||||||
"time": 1743282530729,
|
"time": 1743284210487,
|
||||||
"version": "0.0.3"
|
"version": "0.0.3"
|
||||||
}
|
}
|
||||||
14
src/fm95.c
14
src/fm95.c
@@ -527,11 +527,15 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
float mpower = measure_mpx(&power, output[i] * 75000);
|
float mpower = measure_mpx(&power, output[i] * 75000);
|
||||||
if (mpower > mpx_power) {
|
if (mpower > mpx_power) {
|
||||||
float excess = mpower - mpx_power;
|
float excess_power = mpower - mpx_power;
|
||||||
float attenuation_db = excess * 0.75f;
|
float reduction_factor_db = excess_power;
|
||||||
float attenuation_linear = dbr_to_deviation(attenuation_db)/75000;
|
|
||||||
output[i] *= attenuation_linear;
|
float reduction_factor_linear = powf(10.0f, -reduction_factor_db / 20.0f);
|
||||||
printf("Overpower! %f*%f/%f\n", mpower, attenuation_linear, mpx_power);
|
|
||||||
|
output[i] *= reduction_factor_linear;
|
||||||
|
|
||||||
|
mpower = measure_mpx(&power, output[i] * 75000);
|
||||||
|
printf("Reduced overpower: %f -> %f (target: %f)\n", mpower + excess_power, mpower, mpx_power);
|
||||||
}
|
}
|
||||||
|
|
||||||
output[i] *= master_volume;
|
output[i] *= master_volume;
|
||||||
|
|||||||
Reference in New Issue
Block a user