2016-10-19 12:42:57 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 03:58:55 -05:00
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// Copyright (C) 2014 John Greb <hexameron@spam.no> //
|
|
|
|
// Copyright (C) 2015-2020 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
2016-10-19 12:42:57 -04:00
|
|
|
// //
|
|
|
|
// 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 //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2016-10-19 12:42:57 -04:00
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-08-03 18:29:15 -04:00
|
|
|
#ifndef INCLUDE_FILEOUTPUTWORKER_H
|
|
|
|
#define INCLUDE_FILEOUTPUTWORKER_H
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2020-07-12 04:22:24 -04:00
|
|
|
#include <QObject>
|
2016-10-19 12:42:57 -04:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <cstdlib>
|
2017-01-01 21:14:46 -05:00
|
|
|
#include <stdint.h>
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2017-01-01 21:14:46 -05:00
|
|
|
#include "dsp/interpolators.h"
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2020-08-03 18:29:15 -04:00
|
|
|
#define FILEOUTPUT_THROTTLE_MS 50
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
class SampleSourceFifo;
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2020-08-03 18:29:15 -04:00
|
|
|
class FileOutputWorker : public QObject {
|
2016-10-19 12:42:57 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-08-03 18:29:15 -04:00
|
|
|
FileOutputWorker(std::ofstream *samplesStream, SampleSourceFifo* sampleFifo, QObject* parent = 0);
|
|
|
|
~FileOutputWorker();
|
2016-10-19 12:42:57 -04:00
|
|
|
|
|
|
|
void startWork();
|
|
|
|
void stopWork();
|
|
|
|
void setSamplerate(int samplerate);
|
2017-01-01 21:14:46 -05:00
|
|
|
void setLog2Interpolation(int log2Interpolation);
|
2016-10-19 12:42:57 -04:00
|
|
|
void setBuffer(std::size_t chunksize);
|
|
|
|
bool isRunning() const { return m_running; }
|
2016-10-19 16:32:14 -04:00
|
|
|
std::size_t getSamplesCount() const { return m_samplesCount; }
|
|
|
|
void setSamplesCount(int samplesCount) { m_samplesCount = samplesCount; }
|
2016-10-19 12:42:57 -04:00
|
|
|
|
|
|
|
void connectTimer(const QTimer& timer);
|
|
|
|
|
|
|
|
private:
|
2018-02-21 12:54:59 -05:00
|
|
|
volatile bool m_running;
|
2016-10-19 12:42:57 -04:00
|
|
|
|
|
|
|
std::ofstream* m_ofstream;
|
|
|
|
std::size_t m_bufsize;
|
2016-10-24 20:34:29 -04:00
|
|
|
unsigned int m_samplesChunkSize;
|
2019-11-14 19:04:24 -05:00
|
|
|
SampleSourceFifo* m_sampleFifo;
|
2016-10-19 16:32:14 -04:00
|
|
|
std::size_t m_samplesCount;
|
2016-10-19 12:42:57 -04:00
|
|
|
|
|
|
|
int m_samplerate;
|
2017-01-01 21:14:46 -05:00
|
|
|
int m_log2Interpolation;
|
2016-10-19 12:42:57 -04:00
|
|
|
int m_throttlems;
|
2016-12-19 18:26:43 -05:00
|
|
|
int m_maxThrottlems;
|
2016-10-19 12:42:57 -04:00
|
|
|
QElapsedTimer m_elapsedTimer;
|
|
|
|
bool m_throttleToggle;
|
|
|
|
|
2018-01-22 02:46:05 -05:00
|
|
|
Interpolators<qint16, SDR_TX_SAMP_SZ, 16> m_interpolators;
|
2017-01-01 21:14:46 -05:00
|
|
|
int16_t *m_buf;
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void callbackPart(SampleVector& data, unsigned int iBegin, unsigned int iEnd);
|
2016-10-19 12:42:57 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void tick();
|
|
|
|
};
|
|
|
|
|
2020-08-03 18:29:15 -04:00
|
|
|
#endif // INCLUDE_FILEOUTPUTWORKER_H
|