diff options
Diffstat (limited to 'examples/multimedia/audioinput/audioinput.h')
-rw-r--r-- | examples/multimedia/audioinput/audioinput.h | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/examples/multimedia/audioinput/audioinput.h b/examples/multimedia/audioinput/audioinput.h index abe2be1..f87c682 100644 --- a/examples/multimedia/audioinput/audioinput.h +++ b/examples/multimedia/audioinput/audioinput.h @@ -45,6 +45,7 @@ #include <QMainWindow> #include <QPushButton> #include <QComboBox> +#include <QByteArray> #include <qaudioinput.h> @@ -52,21 +53,21 @@ class AudioInfo : public QIODevice { Q_OBJECT public: - AudioInfo(QObject *parent, QAudioInput *device); + AudioInfo(const QAudioFormat &format, QObject *parent); ~AudioInfo(); void start(); void stop(); - int LinearMax(); + qreal level() const { return m_level; } qint64 readData(char *data, qint64 maxlen); qint64 writeData(const char *data, qint64 len); - QAudioInput *input; - private: - int m_maxValue; + const QAudioFormat m_format; + quint16 m_maxAmplitude; + qreal m_level; // 0.0 <= m_level <= 1.0 signals: void update(); @@ -80,14 +81,14 @@ class RenderArea : public QWidget public: RenderArea(QWidget *parent = 0); - void setLevel(int value); + void setLevel(qreal value); protected: void paintEvent(QPaintEvent *event); private: - int level; - QPixmap pixmap; + qreal m_level; + QPixmap m_pixmap; }; class InputTest : public QMainWindow @@ -97,29 +98,38 @@ public: InputTest(); ~InputTest(); +private: + void initializeWindow(); + void initializeAudio(); + void createAudioInput(); + private slots: void refreshDisplay(); - void status(); + void notified(); void readMore(); void toggleMode(); void toggleSuspend(); - void state(QAudio::State s); - void deviceChanged(int idx); + void stateChanged(QAudio::State state); + void deviceChanged(int index); private: - AudioInfo *audioinfo; - QAudioDeviceInfo device; - QAudioFormat format; - QAudioInput *audioInput; - QIODevice *input; - RenderArea *canvas; - - bool pullMode; - - QPushButton *button; - QPushButton *button2; - QComboBox *deviceBox; - - char *buffer; + // Owned by layout + RenderArea *m_canvas; + QPushButton *m_modeButton; + QPushButton *m_suspendResumeButton; + QComboBox *m_deviceBox; + + AudioInfo *m_audioInfo; + QAudioDeviceInfo m_device; + QAudioFormat m_format; + QAudioInput *m_audioInput; + QIODevice *m_input; + bool m_pullMode; + QByteArray m_buffer; + + static const QString PushModeLabel; + static const QString PullModeLabel; + static const QString SuspendLabel; + static const QString ResumeLabel; }; |