|
|
|
@ -20,6 +20,8 @@ |
|
|
|
|
* Inputs are either real or I-Q per bool twoChannel. Rev Apr 2021 |
|
|
|
|
* |
|
|
|
|
* MIT License, Use at your own risk. |
|
|
|
|
* |
|
|
|
|
* Rev 28 Mar 2022 Correctedslight interpolation error. RSL |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include "RadioIQMixer_F32.h" |
|
|
|
@ -78,7 +80,7 @@ void RadioIQMixer_F32::update(void) { |
|
|
|
|
a = sinTable512_f32[index]; |
|
|
|
|
b = sinTable512_f32[index+1]; |
|
|
|
|
// Linear interpolation and multiplying (DBMixer) with input
|
|
|
|
|
blockOut_i->data[i] = blockIn0->data[i] * (a + 0.001953125*(b-a)*deltaPhase); |
|
|
|
|
blockOut_i->data[i] = blockIn0->data[i] * (a + (b-a)*deltaPhase); |
|
|
|
|
|
|
|
|
|
/* Repeat for cosine by adding 90 degrees phase */ |
|
|
|
|
index = (index + 128) & 0x01ff; |
|
|
|
@ -87,9 +89,9 @@ void RadioIQMixer_F32::update(void) { |
|
|
|
|
b = sinTable512_f32[index+1]; |
|
|
|
|
/* deltaPhase will be the same as used for sin */ |
|
|
|
|
if(twoChannel) |
|
|
|
|
blockOut_q->data[i] = blockIn1->data[i]*(a + 0.001953125*(b-a)*deltaPhase); |
|
|
|
|
blockOut_q->data[i] = blockIn1->data[i]*(a + (b-a)*deltaPhase); |
|
|
|
|
else |
|
|
|
|
blockOut_q->data[i] = blockIn0->data[i]*(a + 0.001953125*(b-a)*deltaPhase); |
|
|
|
|
blockOut_q->data[i] = blockIn0->data[i]*(a + (b-a)*deltaPhase); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { // Do a more flexible update, i.e., not doSimple
|
|
|
|
@ -103,7 +105,7 @@ void RadioIQMixer_F32::update(void) { |
|
|
|
|
b = sinTable512_f32[index+1]; |
|
|
|
|
// We now have a sine value, so multiply with the input data and save
|
|
|
|
|
// Linear interpolate sine and multiply with the input and amplitude (about 1.0)
|
|
|
|
|
blockOut_i->data[i] = amplitude_pk * blockIn0->data[i] * (a + 0.001953125*(b-a)*deltaPhase); |
|
|
|
|
blockOut_i->data[i] = amplitude_pk * blockIn0->data[i] * (a + (b-a)*deltaPhase); |
|
|
|
|
|
|
|
|
|
/* Shift forward phaseS_C and get cos. First, the calculation of index of the table */ |
|
|
|
|
phaseC = phaseS + phaseS_C; |
|
|
|
@ -115,9 +117,9 @@ void RadioIQMixer_F32::update(void) { |
|
|
|
|
b = sinTable512_f32[index+1]; |
|
|
|
|
// Same as sin, but leave amplitude of LO at +/- 1.0
|
|
|
|
|
if(twoChannel) |
|
|
|
|
blockOut_q->data[i] = blockIn1->data[i]*(a + 0.001953125*(b-a)*deltaPhase); |
|
|
|
|
blockOut_q->data[i] = blockIn1->data[i]*(a + (b-a)*deltaPhase); |
|
|
|
|
else |
|
|
|
|
blockOut_q->data[i] = blockIn0->data[i]*(a + 0.001953125*(b-a)*deltaPhase); |
|
|
|
|
blockOut_q->data[i] = blockIn0->data[i]*(a + (b-a)*deltaPhase); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
AudioStream_F32::release(blockIn0); // Done with this
|
|
|
|
|