0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00

make bs412 a dynamic compressor (boosts, and attunuates instead of just attenuating dynamically)

This commit is contained in:
2025-07-10 20:11:52 +02:00
parent 4146110e6e
commit 668dfea9f2

View File

@@ -48,12 +48,11 @@ float bs412_compress(BS412Compressor* mpx, float sample) {
mpx->average_counter = 1;
}
float target_gain = mpx->target / modulation_power;
if (modulation_power > mpx->target) {
float target_gain = mpx->target / modulation_power;
mpx->gain = mpx->attack * mpx->gain + (1.0f - mpx->attack) * target_gain;
} else {
mpx->gain = mpx->release * mpx->gain + (1.0f - mpx->release) * 1.0f;
mpx->gain = mpx->release * mpx->gain + (1.0f - mpx->release) * target_gain;
}
mpx->gain = fminf(mpx->max, mpx->gain);