QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AudioOutput.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4
5class QTextToSpeech;
6class Fact;
7class AudioOutputTest;
8
11class AudioOutput : public QObject
12{
13 Q_OBJECT
14
15 friend AudioOutputTest;
16
17public:
19 enum class TextMod {
20 None = 0,
21 Translate = 1 << 0,
22 };
23 Q_FLAG(TextMod)
24 Q_DECLARE_FLAGS(TextMods, TextMod)
25
26
28 explicit AudioOutput(QObject *parent = nullptr);
29
32
35 static AudioOutput *instance();
36
38 void init(Fact *volumeFact, Fact *mutedFact);
39
43 void say(const QString &text, TextMods textMods = TextMod::None);
44
46 void testAudioOutput();
47
48private:
49 QTextToSpeech *_engine = nullptr;
50 QAtomicInteger<qsizetype> _textQueueSize = 0;
51 bool _initialized = false;
52 Fact *_volumeFact = nullptr;
53 Fact *_mutedFact = nullptr;
54 double _lastVolume = -1.0;
55
57 double _volumeSetting() const;
58
60 bool _mutedSetting() const;
61
63 void _setVolume();
64
65 static const QHash<QString, QString> _textHash;
66
67 static constexpr qsizetype kMaxTextQueueSize = 20;
68
72 static QString _fixTextMessageForAudio(const QString &string);
73
77 static QString _replaceAbbreviations(const QString &input);
78
80 static QString _replaceNegativeSigns(const QString &input);
81
83 static QString _replaceDecimalPoints(const QString &input);
84
86 static QString _replaceMeters(const QString &input);
87
89 static QString _convertMilliseconds(const QString &input);
90
96 static bool _getMillisecondString(const QString &string, QString &match, int &number);
97
98};
99Q_DECLARE_OPERATORS_FOR_FLAGS(AudioOutput::TextMods)
The AudioOutput class provides functionality for audio output using text-to-speech.
Definition AudioOutput.h:12
void say(const QString &text, TextMods textMods=TextMod::None)
void testAudioOutput()
Tests the audio output. Will stop current output before test.
TextMod
Enumeration for text modification options.
Definition AudioOutput.h:19
static AudioOutput * instance()
~AudioOutput()
Destructor for the AudioOutput class.
void init(Fact *volumeFact, Fact *mutedFact)
Initialize the Singleton.
A Fact is used to hold a single value within the system.
Definition Fact.h:17