GAudioOutput.h 1.88 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
pixhawk's avatar
pixhawk committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23


/**
 * @file
 *   @brief Definition of audio output
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 *
 */

#ifndef GAUDIOOUTPUT_H
#define GAUDIOOUTPUT_H

#include <QObject>
#include <QTimer>
24
#include <QThread>
pixhawk's avatar
pixhawk committed
25
#include <QStringList>
26

27
#include "QGCAudioWorker.h"
28 29 30
#include "QGCToolbox.h"

class QGCApplication;
Lorenz Meier's avatar
Lorenz Meier committed
31

pixhawk's avatar
pixhawk committed
32 33 34 35 36
/**
 * @brief Audio Output (speech synthesizer and "beep" output)
 * This class follows the singleton design pattern
 * @see http://en.wikipedia.org/wiki/Singleton_pattern
 */
37
class GAudioOutput : public QGCTool
pixhawk's avatar
pixhawk committed
38 39
{
    Q_OBJECT
dogmaphobic's avatar
dogmaphobic committed
40

pixhawk's avatar
pixhawk committed
41
public:
42 43 44
    GAudioOutput(QGCApplication* app);
    ~GAudioOutput();

pixhawk's avatar
pixhawk committed
45 46
    /** @brief List available voices */
    QStringList listVoices(void);
Lorenz Meier's avatar
Lorenz Meier committed
47 48
    enum
    {
49 50 51
        VOICE_MALE = 0,
        VOICE_FEMALE
    } QGVoice;
pixhawk's avatar
pixhawk committed
52

53 54 55 56 57 58 59 60 61 62 63 64
    enum AUDIO_SEVERITY
    {
        AUDIO_SEVERITY_EMERGENCY = 0,
        AUDIO_SEVERITY_ALERT = 1,
        AUDIO_SEVERITY_CRITICAL = 2,
        AUDIO_SEVERITY_ERROR = 3,
        AUDIO_SEVERITY_WARNING = 4,
        AUDIO_SEVERITY_NOTICE = 5,
        AUDIO_SEVERITY_INFO = 6,
        AUDIO_SEVERITY_DEBUG = 7
    };

65 66 67
    /** @brief Get the mute state */
    bool isMuted();

pixhawk's avatar
pixhawk committed
68
public slots:
Don Gagne's avatar
Don Gagne committed
69 70
    /** @brief Say this text */
    bool say(const QString& text);
71 72
    /** @brief Mute/unmute sound */
    void mute(bool mute);
73 74 75

signals:
    void mutedChanged(bool);
Don Gagne's avatar
Don Gagne committed
76
    bool textToSpeak(QString text);
77
    void beepOnce();
pixhawk's avatar
pixhawk committed
78 79

protected:
80
    bool muted;
dogmaphobic's avatar
dogmaphobic committed
81 82

#if !defined __android__
83 84
    QThread* thread;
    QGCAudioWorker* worker;
dogmaphobic's avatar
dogmaphobic committed
85 86
#endif

pixhawk's avatar
pixhawk committed
87
private:
88
    static const char* _mutedKey;
pixhawk's avatar
pixhawk committed
89 90 91
};

#endif // AUDIOOUTPUT_H
Lorenz Meier's avatar
Lorenz Meier committed
92