1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Tx ph.2: UpChannelizer: interpolator (1) draft

This commit is contained in:
f4exb 2016-10-28 18:39:45 +02:00
parent 1f58b6ece7
commit e9f0bb0d45
3 changed files with 91 additions and 14 deletions

View File

@ -327,7 +327,7 @@ void FileSinkGui::tick()
}
}
unsigned int FileSinkSampleRates::m_rates[] = {32, 36, 48, 64, 72};
unsigned int FileSinkSampleRates::m_rates[] = {32, 48, 64, 72, 128};
unsigned int FileSinkSampleRates::m_nb_rates = 5;
unsigned int FileSinkSampleRates::getRate(unsigned int rate_index)

View File

@ -376,7 +376,7 @@ public:
}
}
// upsample by 2, from upper half of original spectrum
// upsample by 2, move original spectrum to upper half
bool workInterpolateUpperHalf(Sample* sampleIn, Sample *sampleOut)
{
switch(m_state)
@ -400,8 +400,8 @@ public:
case 1:
// insert sample into ring-buffer
m_samples[m_ptr][0] = -sampleIn->real();
m_samples[m_ptr][1] = -sampleIn->imag();
m_samples[m_ptr][0] = sampleIn->imag();
m_samples[m_ptr][1] = -sampleIn->real();
// save result
doFIR(sampleOut);
@ -432,10 +432,78 @@ public:
// tell caller we didn't consume the sample
return false;
case 3:
// insert sample into ring-buffer
m_samples[m_ptr][0] = -sampleIn->real();
m_samples[m_ptr][1] = -sampleIn->imag();
// save result
doFIR(sampleOut);
// advance write-pointer
m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 4;
// tell caller we consumed the sample
return true;
case 4:
// insert sample into ring-buffer
m_samples[m_ptr][0] = 0;
m_samples[m_ptr][1] = 0;
// save result
doFIR(sampleOut);
// advance write-pointer
m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 5;
// tell caller we didn't consume the sample
return false;
case 5:
// insert sample into ring-buffer
m_samples[m_ptr][0] = -sampleIn->imag();
m_samples[m_ptr][1] = sampleIn->real();
// save result
doFIR(sampleOut);
// advance write-pointer
m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 6;
// tell caller we consumed the sample
return true;
case 6:
// insert sample into ring-buffer
m_samples[m_ptr][0] = 0;
m_samples[m_ptr][1] = 0;
// save result
doFIR(sampleOut);
// advance write-pointer
m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
// next state
m_state = 7;
// tell caller we didn't consume the sample
return false;
default:
// insert sample into ring-buffer
m_samples[m_ptr][0] = sampleIn->real();
m_samples[m_ptr][1] = sampleIn->imag();
m_samples[m_ptr][0] = sampleIn->real();
m_samples[m_ptr][1] = sampleIn->imag();
// save result
doFIR(sampleOut);

View File

@ -63,14 +63,23 @@ void UpChannelizer::pull(Sample& sample)
{
m_mutex.lock();
// TODO: handle multiple stages
FilterStages::iterator stage = m_filterStages.begin();
FilterStages::iterator last = m_filterStages.end();
last--;
if ((*stage)->work(&m_sampleIn, &sample))
{
m_sampleSource->pull(m_sampleIn);
}
// m_sampleIn
for (; stage != m_filterStages.end(); ++stage)
{
// let's make it work for one stage only (96 kS/s < SR < 192 kS/s)
if(stage == last)
{
if ((*stage)->work(&m_sampleIn, &sample))
{
m_sampleSource->pull(m_sampleIn); // get new input sample
}
}
}
m_mutex.unlock();
}
@ -162,9 +171,9 @@ void UpChannelizer::applyConfiguration()
m_currentInputSampleRate = m_outputSampleRate / (1 << m_filterStages.size());
qDebug() << "UpChannelizer::applyConfiguration in=" << m_outputSampleRate
qDebug() << "UpChannelizer::applyConfiguration out=" << m_outputSampleRate
<< ", req=" << m_requestedInputSampleRate
<< ", out=" << m_currentInputSampleRate
<< ", in=" << m_currentInputSampleRate
<< ", fc=" << m_currentCenterFrequency;
if (m_sampleSource != 0)