mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
configure the bs412 max
This commit is contained in:
@@ -11,7 +11,7 @@ inline float deviation_to_dbr(float deviation) {
|
||||
return 10.0f * (log2f(deviation) - LOG2_19000) * 0.30103f;
|
||||
}
|
||||
|
||||
void init_bs412(BS412Compressor* mpx, float mpx_deviation, float target_power, float attack, float release, int sample_rate) {
|
||||
void init_bs412(BS412Compressor* mpx, float mpx_deviation, float target_power, float attack, float release, float max, int sample_rate) {
|
||||
mpx->mpx_deviation = mpx_deviation;
|
||||
mpx->average_counter = 0;
|
||||
mpx->average = 0;
|
||||
@@ -20,6 +20,7 @@ void init_bs412(BS412Compressor* mpx, float mpx_deviation, float target_power, f
|
||||
mpx->release = expf(-1.0f / (release * sample_rate));
|
||||
mpx->target = target_power;
|
||||
mpx->gain = 1.0f;
|
||||
mpx->max = max;
|
||||
#ifdef BS412_DEBUG
|
||||
debug_printf("Initialized MPX power measurement with sample rate: %d\n", sample_rate);
|
||||
#endif
|
||||
@@ -51,7 +52,7 @@ float bs412_compress(BS412Compressor* mpx, float sample) {
|
||||
mpx->gain = mpx->gain * mpx->attack + (1.0f - mpx->attack) * gain_target;
|
||||
else
|
||||
mpx->gain = mpx->gain * mpx->release + (1.0f - mpx->release) * gain_target;
|
||||
mpx->gain = fminf(1.0f, mpx->gain);
|
||||
mpx->gain = fminf(mpx->max, mpx->gain);
|
||||
|
||||
return fminf(sample*mpx->gain, dbr_to_deviation(mpx->target*1.1f));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ typedef struct
|
||||
float target;
|
||||
float attack;
|
||||
float release;
|
||||
float max;
|
||||
float gain;
|
||||
double average;
|
||||
} BS412Compressor;
|
||||
|
||||
@@ -87,6 +87,7 @@ typedef struct
|
||||
float agc_min;
|
||||
float bs412_attack;
|
||||
float bs412_release;
|
||||
float bs412_max;
|
||||
} FM95_Config;
|
||||
|
||||
typedef struct
|
||||
@@ -167,7 +168,7 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) {
|
||||
init_preemphasis(&preemp_r, config.preemphasis, config.sample_rate, config.preemp_unity_freq);
|
||||
|
||||
BS412Compressor bs412;
|
||||
init_bs412(&bs412, config.mpx_deviation, config.mpx_power, config.bs412_attack, config.bs412_release, config.sample_rate);
|
||||
init_bs412(&bs412, config.mpx_deviation, config.mpx_power, config.bs412_attack, config.bs412_release, config.bs412_max, config.sample_rate);
|
||||
|
||||
TiltCorrectionFilter tilter;
|
||||
tilt_init(&tilter, config.tilt);
|
||||
@@ -353,6 +354,8 @@ static int config_handler(void* user, const char* section, const char* name, con
|
||||
pconfig->volumes.rds_step = strtof(value, NULL);
|
||||
} else if(MATCH("fm95", "tilt")) {
|
||||
pconfig->tilt = strtof(value, NULL);
|
||||
} else if(MATCH("advanced", "bs412_max")) {
|
||||
pconfig->bs412_max = strtof(value, NULL);
|
||||
} else {
|
||||
return 0; // Unknown section/name
|
||||
}
|
||||
@@ -461,6 +464,7 @@ int main(int argc, char **argv) {
|
||||
.agc_max = 1.75f,
|
||||
.bs412_attack = 0.03f,
|
||||
.bs412_release = 0.02,
|
||||
.bs412_max = 1.0f,
|
||||
};
|
||||
|
||||
FM95_DeviceNames dv_names = {
|
||||
|
||||
Reference in New Issue
Block a user