Tweak LO dithering for better performance
This commit is contained in:
parent
2fc01539f0
commit
57e36203aa
1 changed files with 8 additions and 8 deletions
16
src/main.c
16
src/main.c
|
@ -251,12 +251,11 @@ static void lo_generate(uint32_t *buf, double freq, uint32_t phase)
|
||||||
{
|
{
|
||||||
freq_step = STEP_BASE * freq;
|
freq_step = STEP_BASE * freq;
|
||||||
|
|
||||||
unsigned down = 4 + __builtin_clz(freq_step);
|
unsigned down = 2 + __builtin_clz(freq_step);
|
||||||
|
|
||||||
for (size_t i = 0; i < LO_WORDS; i++) {
|
for (size_t i = 0; i < LO_WORDS; i++) {
|
||||||
uint32_t bits = 0;
|
uint32_t bits = 0;
|
||||||
int shift = (rnd_next() >> down) - (rnd_next() >> down) + (rnd_next() >> down) -
|
int shift = (rnd_next() >> down) - (rnd_next() >> down);
|
||||||
(rnd_next() >> down);
|
|
||||||
|
|
||||||
for (int j = 0; j < 32; j++) {
|
for (int j = 0; j < 32; j++) {
|
||||||
bits |= (phase + shift) >> 31;
|
bits |= (phase + shift) >> 31;
|
||||||
|
@ -272,13 +271,12 @@ static void lo_tweak(uint32_t *buf, uint32_t phase)
|
||||||
{
|
{
|
||||||
static size_t i = 0;
|
static size_t i = 0;
|
||||||
uint32_t bits = 0;
|
uint32_t bits = 0;
|
||||||
unsigned down = 4 + __builtin_clz(freq_step);
|
unsigned down = 2 + __builtin_clz(freq_step);
|
||||||
|
|
||||||
phase += freq_step * i * 32;
|
phase += freq_step * i * 32;
|
||||||
|
|
||||||
for (int j = 0; j < 32; j++) {
|
for (int j = 0; j < 32; j++) {
|
||||||
int shift = (rnd_next() >> down) - (rnd_next() >> down) + (rnd_next() >> down) -
|
int shift = (rnd_next() >> down) - (rnd_next() >> down);
|
||||||
(rnd_next() >> down);
|
|
||||||
bits |= (phase + shift) >> 31;
|
bits |= (phase + shift) >> 31;
|
||||||
bits <<= 1;
|
bits <<= 1;
|
||||||
phase += freq_step;
|
phase += freq_step;
|
||||||
|
@ -602,8 +600,10 @@ static void rf_rx(void)
|
||||||
iq_queue_pos = (iq_queue_pos + 1) & (IQ_QUEUE_LEN - 1);
|
iq_queue_pos = (iq_queue_pos + 1) & (IQ_QUEUE_LEN - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lo_tweak(lo_cos, COS_PHASE);
|
for (int i = 0; i < 8; i++) {
|
||||||
lo_tweak(lo_sin, SIN_PHASE);
|
lo_tweak(lo_cos, COS_PHASE);
|
||||||
|
lo_tweak(lo_sin, SIN_PHASE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue