summaryrefslogtreecommitdiff
path: root/soundout.h
diff options
context:
space:
mode:
Diffstat (limited to 'soundout.h')
-rw-r--r--soundout.h83
1 files changed, 42 insertions, 41 deletions
diff --git a/soundout.h b/soundout.h
index a289afc9..1e4b3a94 100644
--- a/soundout.h
+++ b/soundout.h
@@ -1,53 +1,54 @@
-#ifndef SOUNDOUT_H
-#define SOUNDOUT_H
-#include <QtCore>
-#include <QDebug>
+// -*- Mode: C++ -*-
+#ifndef SOUNDOUT_H__
+#define SOUNDOUT_H__
-// An instance of this thread sends audio data to a specified soundcard.
-// Output can be muted while underway, preserving waveform timing when
-// transmission is resumed.
+#include <QObject>
+#include <QString>
+#include <QAudioOutput>
+#include <QAudioDeviceInfo>
-class SoundOutThread : public QThread
-{
- Q_OBJECT
+class QAudioDeviceInfo;
-protected:
- virtual void run();
+// An instance of this sends audio data to a specified soundcard.
+class SoundOutput
+ : public QObject
+{
+ Q_OBJECT;
+
public:
-// Constructs (but does not start) a SoundOutThread
- SoundOutThread()
- : quitExecution(false) // Initialize some private members
- , m_txOK(false)
- , m_txMute(false)
+ SoundOutput ()
+ : m_msBuffered {0u}
+ , m_volume {1.0}
{
}
-public:
- void setOutputDevice(qint32 n);
- void setPeriod(int ntrperiod, int nsps);
- void setTxFreq(int n);
- void setXIT(int n);
- void setTxSNR(double snr);
- void setTune(bool b);
- double samFacOut();
- bool quitExecution; //If true, thread exits gracefully
- QString m_modeTx;
-
-// Private members
+ qreal attenuation () const;
+
+public Q_SLOTS:
+ void setFormat (QAudioDeviceInfo const& device, unsigned channels, unsigned msBuffered = 0u);
+ void restart (QIODevice *);
+ void suspend ();
+ void resume ();
+ void reset ();
+ void stop ();
+ void setAttenuation (qreal); /* unsigned */
+ void resetAttenuation (); /* to zero */
+
+Q_SIGNALS:
+ void error (QString message) const;
+ void status (QString message) const;
+
+private:
+ bool audioError () const;
+
+private Q_SLOTS:
+ void handleStateChanged (QAudio::State);
+
private:
- double m_txsnrdb; //if < 0, add noise to Tx audio
- double m_SamFacOut; //(Output sample rate)/48000.0
-
- qint32 m_nDevOut; //Output device number
- qint32 m_TRperiod; //T/R period (s)
- qint32 m_nsps; //Samples per symbol (at 12000 Hz)
- qint32 m_txFreq;
- qint32 m_xit;
-
- bool m_txOK; //Enable Tx audio
- bool m_txMute; //Mute temporarily
- bool m_tune;
+ QScopedPointer<QAudioOutput> m_stream;
+ unsigned m_msBuffered;
+ qreal m_volume;
};
#endif