Move gain application to limit clipping

This commit is contained in:
Jan Hamal Dvořák 2024-07-22 20:39:40 +02:00
parent b52f772845
commit 5a9a0f7acc

View file

@ -404,7 +404,7 @@ inline static int next_sample(const uint32_t *buf, int *h)
h[1] = x3; h[1] = x3;
h[0] = x4; h[0] = x4;
return sample / 2260; return gain * sample / 2260;
} }
static void rf_rx(void) static void rf_rx(void)
@ -453,7 +453,6 @@ static void rf_rx(void)
int64_t Q = next_sample(cos_ptr + 2, prevQ); int64_t Q = next_sample(cos_ptr + 2, prevQ);
cos_ptr += 8; cos_ptr += 8;
I *= gain;
I -= (max_amplitude * 181) / 256; I -= (max_amplitude * 181) / 256;
I /= max_amplitude; I /= max_amplitude;
@ -464,7 +463,6 @@ static void rf_rx(void)
*blockptr++ = (uint8_t)I + 128; *blockptr++ = (uint8_t)I + 128;
Q *= gain;
Q -= (max_amplitude * 181) / 256; Q -= (max_amplitude * 181) / 256;
Q /= max_amplitude; Q /= max_amplitude;