WSJT-X/soundin.h
Joe Taylor 4e8a3f54c9 1. Refactoring of code so as to move audio input from a separate thread to
the main GUI thread (thanks to G4WJS).

2.. Also, for the record, some example code for using QAudioInput instead 
of PortAudio.  This code is not presently active, and will need to be 
changed to accommodate the changes in #1, above.  But the basic ideas 
are here...


git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3509 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2013-07-30 00:51:42 +00:00

69 lines
1.5 KiB
C++

#ifndef SOUNDIN_H
#define SOUNDIN_H
#include <portaudio.h>
#include <QtCore>
#include <QScopedPointer>
#include <QDebug>
extern "C" int a2dCallback( const void *, void *, unsigned long, PaStreamCallbackTimeInfo const *, PaStreamCallbackFlags, void *);
// Gets audio data from soundcard and signals when a buffer of
// specified size is available.
class SoundInput : public QObject
{
Q_OBJECT
public:
SoundInput();
~SoundInput();
void setMonitoring(bool b);
void setPeriod(int ntrperiod, int nsps) /* this can be called while processing samples */
{
m_TRperiod=ntrperiod;
m_nsps=nsps;
}
int mstep() const {return m_step;}
double samFacIn() const {return m_SamFacIn;}
signals:
void readyForFFT(int k);
void error(const QString& message);
void status(const QString& message);
public slots:
void start(qint32 device);
void intervalNotify();
void stop();
private:
PaStream * m_inStream;
bool m_dataSinkBusy;
double m_SamFacIn; //(Input sample rate)/12000.0
qint32 m_step;
qint32 m_TRperiod;
qint32 m_TRperiod0;
qint32 m_nsps;
bool m_monitoring;
qint64 m_ms0;
int m_ntr0;
int m_nBusy;
int m_nstep0;
int m_nsps0;
QTimer m_intervalTimer;
struct CallbackData
{
int kin; //Parameters sent to/from the portaudio callback function
int ncall;
bool bzero;
bool monitoring;
} m_callbackData;
friend int a2dCallback(void const *, void *, unsigned long, PaStreamCallbackTimeInfo const *, PaStreamCallbackFlags, void *);
};
#endif // SOUNDIN_H