diff options
| author | Christoph Berg <myon@debian.org> | 2020-05-11 22:18:20 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-05-11 22:18:20 +0200 |
| commit | a8edac06b534058e52126c4d55e23b217df2df91 (patch) | |
| tree | f2c3567fae58aad676d544ee8f07ac78dd2eb1ec /Detector/Detector.hpp | |
| parent | 4f6c0156a70e8f2ff70fe5a1a39f5e9b22ffd026 (diff) | |
| parent | 32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (diff) | |
Update upstream source from tag 'upstream/2.2.0_rc1+repack'
Update to upstream version '2.2.0~rc1+repack'
with Debian dir fe177bc6cd2d4c1256a3775504f6010be54e7463
Diffstat (limited to 'Detector/Detector.hpp')
| -rw-r--r-- | Detector/Detector.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Detector/Detector.hpp b/Detector/Detector.hpp new file mode 100644 index 00000000..53723d43 --- /dev/null +++ b/Detector/Detector.hpp @@ -0,0 +1,58 @@ +#ifndef DETECTOR_HPP__ +#define DETECTOR_HPP__ +#include "Audio/AudioDevice.hpp" +#include <QScopedArrayPointer> + +// +// output device that distributes data in predefined chunks via a signal +// +// the underlying device for this abstraction is just the buffer that +// stores samples throughout a receiving period +// +class Detector : public AudioDevice +{ + Q_OBJECT; + +public: + // + // if the data buffer were not global storage and fixed size then we + // might want maximum size passed as constructor arguments + // + // we down sample by a factor of 4 + // + // the samplesPerFFT argument is the number after down sampling + // + Detector (unsigned frameRate, double periodLengthInSeconds, unsigned downSampleFactor = 4u, + QObject * parent = 0); + + void setTRPeriod(double p) {m_period=p;} + bool reset () override; + + Q_SIGNAL void framesWritten (qint64) const; + Q_SLOT void setBlockSize (unsigned); + +protected: + qint64 readData (char * /* data */, qint64 /* maxSize */) override + { + return -1; // we don't produce data + } + + qint64 writeData (char const * data, qint64 maxSize) override; + +private: + void clear (); // discard buffer contents + + unsigned m_frameRate; + double m_period; + unsigned m_downSampleFactor; + qint32 m_samplesPerFFT; // after any down sampling + static size_t const max_buffer_size {7 * 512}; + QScopedArrayPointer<short> m_buffer; // de-interleaved sample buffer + // big enough for all the + // samples for one increment of + // data (a signals worth) at + // the input sample rate + unsigned m_bufferPos; +}; + +#endif |
