8 changed files with 2 additions and 1660 deletions
File diff suppressed because it is too large
Load Diff
@ -1,68 +0,0 @@
@@ -1,68 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "samplesinkfifodoublebuffered.h" |
||||
|
||||
SampleSinkFifoDoubleBuffered::SampleSinkFifoDoubleBuffered(uint32_t size, uint32_t signalThreshold) : |
||||
m_size(size), |
||||
m_signalThreshold(signalThreshold), |
||||
m_i(0), |
||||
m_count(0), |
||||
m_readIndex(0), |
||||
m_readCount(0) |
||||
{ |
||||
assert(m_signalThreshold < m_size/2); |
||||
m_data.resize(2*m_size); |
||||
} |
||||
|
||||
SampleSinkFifoDoubleBuffered::~SampleSinkFifoDoubleBuffered() |
||||
{ |
||||
} |
||||
|
||||
void SampleSinkFifoDoubleBuffered::getWriteIterator(SampleVector::iterator& it1) |
||||
{ |
||||
it1 = m_data.begin() + m_i; |
||||
} |
||||
|
||||
void SampleSinkFifoDoubleBuffered::bumpIndex(SampleVector::iterator& it1) |
||||
{ |
||||
m_data[m_i+m_size] = m_data[m_i]; |
||||
m_i = (m_i+1) % m_size; |
||||
it1 = m_data.begin() + m_i; |
||||
|
||||
if (m_count < m_signalThreshold) |
||||
{ |
||||
m_count++; |
||||
} |
||||
else |
||||
{ |
||||
QMutexLocker mutexLocker(&m_mutex); |
||||
m_readIndex = m_i + m_size - m_count; |
||||
m_readCount = m_count; |
||||
m_count = 0; |
||||
emit dataReady(); |
||||
} |
||||
} |
||||
|
||||
void SampleSinkFifoDoubleBuffered::read(SampleVector::iterator& begin, SampleVector::iterator& end) |
||||
{ |
||||
QMutexLocker mutexLocker(&m_mutex); |
||||
|
||||
begin = m_data.begin() + m_readIndex; |
||||
end = begin + m_readCount; |
||||
} |
||||
|
||||
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_DSP_SAMPLESINKFIFODOUBLEBUFFERED_H_ |
||||
#define SDRBASE_DSP_SAMPLESINKFIFODOUBLEBUFFERED_H_ |
||||
|
||||
#include <QObject> |
||||
#include <QMutex> |
||||
#include <stdint.h> |
||||
#include <assert.h> |
||||
#include "export.h" |
||||
#include "dsp/dsptypes.h" |
||||
|
||||
class SDRBASE_API SampleSinkFifoDoubleBuffered : public QObject { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
SampleSinkFifoDoubleBuffered(uint32_t size, uint32_t signalThreshold); |
||||
~SampleSinkFifoDoubleBuffered(); |
||||
|
||||
void getWriteIterator(SampleVector::iterator& it1); |
||||
void bumpIndex(SampleVector::iterator& it1); |
||||
void read(SampleVector::iterator& begin, SampleVector::iterator& end); |
||||
|
||||
private: |
||||
uint32_t m_size; |
||||
uint32_t m_signalThreshold; |
||||
SampleVector m_data; |
||||
uint32_t m_i; |
||||
uint32_t m_count; |
||||
uint32_t m_readIndex; |
||||
uint32_t m_readCount; |
||||
QMutex m_mutex; |
||||
|
||||
signals: |
||||
void dataReady(); |
||||
}; |
||||
|
||||
#endif /* SDRBASE_DSP_SAMPLESINKFIFODOUBLEBUFFERED_H_ */ |
||||
@ -1,67 +0,0 @@
@@ -1,67 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "samplesinkvector.h" |
||||
|
||||
SampleSinkVector::SampleSinkVector(QObject* parent) : |
||||
QObject(parent), |
||||
m_dataSize(0) |
||||
{} |
||||
|
||||
SampleSinkVector::SampleSinkVector(const SampleSinkVector& other) : |
||||
m_sampleVector(other.m_sampleVector), |
||||
m_dataSize(other.m_dataSize) |
||||
{} |
||||
|
||||
SampleSinkVector::~SampleSinkVector() |
||||
{} |
||||
|
||||
void SampleSinkVector::write(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal) |
||||
{ |
||||
if (end - begin > m_sampleVector.size()) { |
||||
m_sampleVector.resize(end - begin); |
||||
} |
||||
|
||||
std::copy(begin, end, m_sampleVector.begin()); |
||||
m_dataSize = end - begin; |
||||
// m_begin = begin;
|
||||
// m_end = end;
|
||||
if (signal) { |
||||
emit dataReady(); |
||||
} |
||||
} |
||||
|
||||
void SampleSinkVector::append(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal) |
||||
{ |
||||
if ((end - begin) + m_dataSize > m_sampleVector.size()) { |
||||
m_sampleVector.resize((end - begin) + m_dataSize); |
||||
} |
||||
|
||||
std::copy(begin, end, m_sampleVector.begin() + m_dataSize); |
||||
m_dataSize += (end - begin); |
||||
if (signal) { |
||||
emit dataReady(); |
||||
} |
||||
} |
||||
|
||||
void SampleSinkVector::read(SampleVector::iterator& begin, SampleVector::iterator& end) |
||||
{ |
||||
begin = m_sampleVector.begin(); |
||||
end = m_sampleVector.begin() + m_dataSize; |
||||
// begin = m_begin;
|
||||
// end = m_end;
|
||||
} |
||||
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_DSP_SAMPLESINKVECTOR_H_ |
||||
#define SDRBASE_DSP_SAMPLESINKVECTOR_H_ |
||||
|
||||
#include <QObject> |
||||
|
||||
#include "dsp/dsptypes.h" |
||||
#include "export.h" |
||||
|
||||
class SDRBASE_API SampleSinkVector : public QObject { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
SampleSinkVector(QObject* parent = nullptr); |
||||
SampleSinkVector(const SampleSinkVector& other); |
||||
~SampleSinkVector(); |
||||
|
||||
void write(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal = true); |
||||
void append(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal = false); |
||||
void read(SampleVector::iterator& begin, SampleVector::iterator& end); |
||||
|
||||
signals: |
||||
void dataReady(); |
||||
|
||||
private: |
||||
SampleVector m_sampleVector; |
||||
int m_dataSize; |
||||
// SampleVector::const_iterator m_begin;
|
||||
// SampleVector::const_iterator m_end;
|
||||
}; |
||||
|
||||
|
||||
#endif // SDRBASE_DSP_SAMPLESINKVECTOR_H_
|
||||
Loading…
Reference in new issue