2013-08-05 09:57:55 -04:00
|
|
|
#ifndef SOUNDIN_H__
|
|
|
|
#define SOUNDIN_H__
|
2013-07-29 20:51:42 -04:00
|
|
|
|
2013-07-31 20:49:58 -04:00
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2013-08-05 09:57:55 -04:00
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QAudioInput>
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
class QAudioDeviceInfo;
|
|
|
|
class QAudioInput;
|
|
|
|
class QIODevice;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
// Gets audio data from sound sample source and passes it to a sink device
|
2013-07-29 20:51:42 -04:00
|
|
|
class SoundInput : public QObject
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2013-08-05 09:57:55 -04:00
|
|
|
Q_OBJECT;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY (SoundInput);
|
2013-07-31 20:49:58 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
public:
|
|
|
|
SoundInput (QObject * parent = 0)
|
|
|
|
: QObject (parent)
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
~SoundInput ();
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-17 15:21:14 -04:00
|
|
|
private:
|
|
|
|
Q_SIGNAL void error (QString message) const;
|
|
|
|
Q_SIGNAL void status (QString message) const;
|
2013-08-05 09:57:55 -04:00
|
|
|
|
|
|
|
// sink must exist from the start call to any following stop () call
|
2013-10-04 15:00:29 -04:00
|
|
|
Q_SLOT void start(QAudioDeviceInfo const&, unsigned channels, int framesPerBuffer, QIODevice * sink, unsigned downSampleFactor);
|
2013-08-17 15:21:14 -04:00
|
|
|
Q_SLOT void stop();
|
|
|
|
|
|
|
|
// used internally
|
|
|
|
Q_SLOT void handleStateChanged (QAudio::State) const;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
bool audioError () const;
|
2013-07-29 20:51:42 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
QScopedPointer<QAudioInput> m_stream;
|
2012-05-22 13:09:48 -04:00
|
|
|
};
|
2013-07-31 20:49:58 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
#endif
|