1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 13:21:50 -05:00

Tx ph.1: FileSink: set sample source FIFO size depending on sample rate

This commit is contained in:
f4exb 2016-10-25 02:34:29 +02:00
parent 5021d15162
commit ee55747c0b
8 changed files with 24 additions and 6 deletions

View File

@ -146,7 +146,9 @@ void AMMod::apply()
if ((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) || if ((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) ||
(m_config.m_outputSampleRate != m_running.m_outputSampleRate)) (m_config.m_outputSampleRate != m_running.m_outputSampleRate))
{ {
m_settingsMutex.lock();
m_carrierNco.setFreq(m_config.m_inputFrequencyOffset, m_config.m_outputSampleRate); m_carrierNco.setFreq(m_config.m_inputFrequencyOffset, m_config.m_outputSampleRate);
m_settingsMutex.unlock();
} }
if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) || if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) ||

View File

@ -88,6 +88,11 @@ void FileSinkThread::setSamplerate(int samplerate)
stopWork(); stopWork();
} }
// resize sample FIFO
if (m_sampleFifo) {
m_sampleFifo->resize(samplerate, samplerate/4); // 1s buffer with 250ms write chunk size
}
m_samplerate = samplerate; m_samplerate = samplerate;
m_samplesChunkSize = (m_samplerate * m_throttlems) / 1000; m_samplesChunkSize = (m_samplerate * m_throttlems) / 1000;
} }

View File

@ -57,7 +57,7 @@ private:
std::ofstream* m_ofstream; std::ofstream* m_ofstream;
quint8 *m_buf; quint8 *m_buf;
std::size_t m_bufsize; std::size_t m_bufsize;
std::size_t m_samplesChunkSize; unsigned int m_samplesChunkSize;
SampleSourceFifo* m_sampleFifo; SampleSourceFifo* m_sampleFifo;
std::size_t m_samplesCount; std::size_t m_samplesCount;

View File

@ -332,7 +332,7 @@ void DeviceSourceAPI::loadChannelSettings(const Preset *preset, PluginAPI *plugi
} }
else else
{ {
qDebug("DeviceSourceAPI::loadChannelSettings: Loading preset [%s | %s] not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); qDebug("DeviceSourceAPI::loadChannelSettings: Loading preset [%s | %s] not a source preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
} }
} }

View File

@ -202,7 +202,6 @@ void DSPDeviceSinkEngine::work()
{ {
(*it)->pull(s); (*it)->pull(s);
s /= (m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()); s /= (m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size());
(*writeAt) += s;
if (sourceOccurence == 0) { if (sourceOccurence == 0) {
(*writeAt) = s; (*writeAt) = s;

View File

@ -44,7 +44,7 @@ NCO::NCO()
void NCO::setFreq(Real freq, Real sampleRate) void NCO::setFreq(Real freq, Real sampleRate)
{ {
m_phaseIncrement = (freq * TableSize) / sampleRate; m_phaseIncrement = (freq * TableSize) / sampleRate;
qDebug("NCO phase inc %d", m_phaseIncrement); qDebug("NCO freq: %f phase inc %d", freq, m_phaseIncrement);
} }
float NCO::next() float NCO::next()

View File

@ -31,6 +31,17 @@ SampleSourceFifo::SampleSourceFifo(uint32_t size, uint32_t samplesChunkSize) :
SampleSourceFifo::~SampleSourceFifo() SampleSourceFifo::~SampleSourceFifo()
{} {}
void SampleSourceFifo::resize(uint32_t size, uint32_t samplesChunkSize)
{
qDebug("SampleSourceFifo::resize: %d, %d", size, samplesChunkSize);
assert(samplesChunkSize <= size/4);
m_size = size;
m_samplesChunkSize = samplesChunkSize;
m_data.resize(2*m_size);
init();
}
void SampleSourceFifo::init() void SampleSourceFifo::init()
{ {
memset(&m_data[0], 0, sizeof(2*m_size*sizeof(Sample))); memset(&m_data[0], 0, sizeof(2*m_size*sizeof(Sample)));
@ -84,9 +95,9 @@ void SampleSourceFifo::write(const Sample& sample)
} }
} }
void SampleSourceFifo::getReadIterator(SampleVector::iterator& writeUntil) void SampleSourceFifo::getReadIterator(SampleVector::iterator& readUntil)
{ {
writeUntil = m_data.begin() + m_size + m_ir; readUntil = m_data.begin() + m_size + m_ir;
} }
void SampleSourceFifo::getWriteIterator(SampleVector::iterator& writeAt) void SampleSourceFifo::getWriteIterator(SampleVector::iterator& writeAt)

View File

@ -33,6 +33,7 @@ public:
unsigned int getChunkSize() const { return m_samplesChunkSize; } unsigned int getChunkSize() const { return m_samplesChunkSize; }
void resize(uint32_t size, uint32_t samplesChunkSize);
void init(); void init();
/** begin read at current read point for the given length and activate R/W signals */ /** begin read at current read point for the given length and activate R/W signals */
void readAndSignal(SampleVector::iterator& beginRead, unsigned int nbSamples); void readAndSignal(SampleVector::iterator& beginRead, unsigned int nbSamples);