1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

Tx ph.2: UpChannelizer: allow any sample rate

This commit is contained in:
f4exb 2016-10-30 22:01:20 +01:00
parent 34bf0c4c61
commit f5bbbb7cab
4 changed files with 40 additions and 15 deletions

View File

@ -327,8 +327,8 @@ void FileSinkGui::tick()
} }
} }
unsigned int FileSinkSampleRates::m_rates[] = {32, 48, 64, 72, 128}; unsigned int FileSinkSampleRates::m_rates[] = {32, 48, 64, 72, 128, 192, 256, 300, 512, 1000};
unsigned int FileSinkSampleRates::m_nb_rates = 5; unsigned int FileSinkSampleRates::m_nb_rates = 10;
unsigned int FileSinkSampleRates::getRate(unsigned int rate_index) unsigned int FileSinkSampleRates::getRate(unsigned int rate_index)
{ {

View File

@ -93,7 +93,7 @@ public:
static unsigned int getRateIndex(unsigned int rate); static unsigned int getRateIndex(unsigned int rate);
static unsigned int getNbRates(); static unsigned int getNbRates();
private: private:
static unsigned int m_rates[5]; static unsigned int m_rates[10];
static unsigned int m_nb_rates; static unsigned int m_nb_rates;
}; };

View File

@ -64,20 +64,39 @@ void UpChannelizer::pull(Sample& sample)
m_mutex.lock(); m_mutex.lock();
FilterStages::iterator stage = m_filterStages.begin(); FilterStages::iterator stage = m_filterStages.begin();
std::vector<Sample>::iterator stageSample = m_stageSamples.begin();
// m_sampleIn for (; stage != m_filterStages.end(); ++stage, ++stageSample)
{
if(stage == m_filterStages.end() - 1)
{
if ((*stage)->work(&m_sampleIn, &(*stageSample)))
{
m_sampleSource->pull(m_sampleIn); // get new input sample
}
}
else
{
if (!(*stage)->work(&(*(stageSample+1)), &(*stageSample)))
{
break;
}
}
}
for (; stage != m_filterStages.end(); ++stage) sample = *m_stageSamples.begin();
{
// let's make it work for one stage only (96 kS/s < SR < 192 kS/s) // for (; stage != m_filterStages.end(); ++stage)
if(stage == m_filterStages.end() - 1) // {
{ // // let's make it work for one stage only (96 kS/s < SR < 192 kS/s)
if ((*stage)->work(&m_sampleIn, &sample)) // if(stage == m_filterStages.end() - 1)
{ // {
m_sampleSource->pull(m_sampleIn); // get new input sample // if ((*stage)->work(&m_sampleIn, &sample))
} // {
} // m_sampleSource->pull(m_sampleIn); // get new input sample
} // }
// }
// }
m_mutex.unlock(); m_mutex.unlock();
} }
@ -221,6 +240,7 @@ Real UpChannelizer::createFilterChain(Real sigStart, Real sigEnd, Real chanStart
Real sigBw = sigEnd - sigStart; Real sigBw = sigEnd - sigStart;
Real safetyMargin = sigBw / 20; Real safetyMargin = sigBw / 20;
Real rot = sigBw / 4; Real rot = sigBw / 4;
Sample s;
safetyMargin = 0; safetyMargin = 0;
@ -238,6 +258,7 @@ Real UpChannelizer::createFilterChain(Real sigStart, Real sigEnd, Real chanStart
<< " [" << m_filterStages.size() << "]" << " [" << m_filterStages.size() << "]"
<< " sig: [" << sigStart << ":" << sigStart + sigBw / 2.0 << "]"; << " sig: [" << sigStart << ":" << sigStart + sigBw / 2.0 << "]";
m_filterStages.push_back(new FilterStage(FilterStage::ModeLowerHalf)); m_filterStages.push_back(new FilterStage(FilterStage::ModeLowerHalf));
m_stageSamples.push_back(s);
return createFilterChain(sigStart, sigStart + sigBw / 2.0, chanStart, chanEnd); return createFilterChain(sigStart, sigStart + sigBw / 2.0, chanStart, chanEnd);
} }
@ -248,6 +269,7 @@ Real UpChannelizer::createFilterChain(Real sigStart, Real sigEnd, Real chanStart
<< " [" << m_filterStages.size() << "]" << " [" << m_filterStages.size() << "]"
<< " sig: [" << sigEnd - sigBw / 2.0f << ":" << sigEnd << "]"; << " sig: [" << sigEnd - sigBw / 2.0f << ":" << sigEnd << "]";
m_filterStages.push_back(new FilterStage(FilterStage::ModeUpperHalf)); m_filterStages.push_back(new FilterStage(FilterStage::ModeUpperHalf));
m_stageSamples.push_back(s);
return createFilterChain(sigEnd - sigBw / 2.0f, sigEnd, chanStart, chanEnd); return createFilterChain(sigEnd - sigBw / 2.0f, sigEnd, chanStart, chanEnd);
} }
@ -259,6 +281,7 @@ Real UpChannelizer::createFilterChain(Real sigStart, Real sigEnd, Real chanStart
<< " [" << m_filterStages.size() << "]" << " [" << m_filterStages.size() << "]"
<< " sig: [" << sigStart + rot << ":" << sigEnd - rot << "]"; << " sig: [" << sigStart + rot << ":" << sigEnd - rot << "]";
m_filterStages.push_back(new FilterStage(FilterStage::ModeCenter)); m_filterStages.push_back(new FilterStage(FilterStage::ModeCenter));
m_stageSamples.push_back(s);
// Was: return createFilterChain(sigStart + rot, sigStart + sigBw / 2.0f + rot, chanStart, chanEnd); // Was: return createFilterChain(sigStart + rot, sigStart + sigBw / 2.0f + rot, chanStart, chanEnd);
return createFilterChain(sigStart + rot, sigEnd - rot, chanStart, chanEnd); return createFilterChain(sigStart + rot, sigEnd - rot, chanStart, chanEnd);
} }
@ -278,6 +301,7 @@ void UpChannelizer::freeFilterChain()
for(FilterStages::iterator it = m_filterStages.begin(); it != m_filterStages.end(); ++it) for(FilterStages::iterator it = m_filterStages.begin(); it != m_filterStages.end(); ++it)
delete *it; delete *it;
m_filterStages.clear(); m_filterStages.clear();
m_stageSamples.clear();
} }

View File

@ -83,6 +83,7 @@ protected:
}; };
typedef std::vector<FilterStage*> FilterStages; typedef std::vector<FilterStage*> FilterStages;
FilterStages m_filterStages; FilterStages m_filterStages;
std::vector<Sample> m_stageSamples;
BasebandSampleSource* m_sampleSource; //!< Modulator BasebandSampleSource* m_sampleSource; //!< Modulator
int m_outputSampleRate; int m_outputSampleRate;
int m_requestedInputSampleRate; int m_requestedInputSampleRate;