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-05 09:57:55 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void error (QString message) const;
|
|
|
|
void status (QString message) const;
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
// sink must exist from the start call to any following stop () call
|
2013-08-10 11:29:55 -04:00
|
|
|
bool start(QAudioDeviceInfo const&, unsigned channels, int framesPerBuffer, QIODevice * sink);
|
2013-07-29 20:51:42 -04:00
|
|
|
void stop();
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
private:
|
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;
|
2013-07-31 20:49:58 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleStateChanged (QAudio::State) const;
|
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
|