Browse Source

Improve audio output logic and consistency

QGC4.4
Lorenz Meier 11 years ago
parent
commit
d53d5f88a8
  1. 2
      src/GAudioOutput.cc
  2. 14
      src/GAudioOutput.h
  3. 9
      src/audio/QGCAudioWorker.cpp
  4. 6
      src/uas/UAS.cc

2
src/GAudioOutput.cc

@ -107,7 +107,7 @@ bool GAudioOutput::say(QString text, int severity) @@ -107,7 +107,7 @@ bool GAudioOutput::say(QString text, int severity)
*/
bool GAudioOutput::alert(QString text)
{
emit textToSpeak(text, 2);
emit textToSpeak(text, 1);
return true;
}

14
src/GAudioOutput.h

@ -58,12 +58,24 @@ public: @@ -58,12 +58,24 @@ public:
VOICE_FEMALE
} QGVoice;
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
};
/** @brief Get the mute state */
bool isMuted();
public slots:
/** @brief Say this text if current output priority matches */
bool say(QString text, int severity = 1);
bool say(QString text, int severity = 6);
/** @brief Play alert sound and say notification message */
bool alert(QString text);
/** @brief Start emergency sound */

9
src/audio/QGCAudioWorker.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "QGC.h"
#include "QGCAudioWorker.h"
#include "GAudioOutput.h"
#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED
#include <ApplicationServices/ApplicationServices.h>
@ -89,11 +90,12 @@ QGCAudioWorker::~QGCAudioWorker() @@ -89,11 +90,12 @@ QGCAudioWorker::~QGCAudioWorker()
void QGCAudioWorker::say(QString text, int severity)
{
qDebug() << "TEXT" << text;
if (!muted)
{
// TODO Add severity filter
Q_UNUSED(severity);
// Prepend high priority text with alert beep
if (severity < GAudioOutput::AUDIO_SEVERITY_CRITICAL) {
beep();
}
// Wait for the last sound to finish
while (!sound->isFinished()) {
@ -149,7 +151,6 @@ void QGCAudioWorker::beep() @@ -149,7 +151,6 @@ void QGCAudioWorker::beep()
{
// Use QFile to transform path for all OS
QFile f(QCoreApplication::applicationDirPath() + QString("/files/audio/alert.wav"));
qDebug() << "SOUND FILE:" << f.fileName();
sound->play(f.fileName());
}
}

6
src/uas/UAS.cc

@ -333,7 +333,7 @@ void UAS::updateState() @@ -333,7 +333,7 @@ void UAS::updateState()
connectionLost = true;
receivedMode = false;
QString audiostring = QString("Link lost to system %1").arg(this->getUASID());
GAudioOutput::instance()->say(audiostring.toLower());
GAudioOutput::instance()->say(audiostring.toLower(), GAudioOutput::AUDIO_SEVERITY_ALERT);
}
// Update connection loss time on each iteration
@ -347,7 +347,7 @@ void UAS::updateState() @@ -347,7 +347,7 @@ void UAS::updateState()
if (connectionLost && (heartbeatInterval < timeoutIntervalHeartbeat))
{
QString audiostring = QString("Link regained to system %1").arg(this->getUASID());
GAudioOutput::instance()->say(audiostring.toLower());
GAudioOutput::instance()->say(audiostring.toLower(), GAudioOutput::AUDIO_SEVERITY_NOTICE);
connectionLost = false;
connectionLossTime = 0;
emit heartbeatTimeout(false, 0);
@ -574,7 +574,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) @@ -574,7 +574,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
if (statechanged && ((int)state.system_status == (int)MAV_STATE_CRITICAL || state.system_status == (int)MAV_STATE_EMERGENCY))
{
GAudioOutput::instance()->say(QString("emergency for system %1").arg(this->getUASID()));
GAudioOutput::instance()->say(QString("emergency for system %1").arg(this->getUASID()), GAudioOutput::AUDIO_SEVERITY_EMERGENCY);
QTimer::singleShot(3000, GAudioOutput::instance(), SLOT(startEmergency()));
}
else if (modechanged || statechanged)

Loading…
Cancel
Save