diff --git a/src/GAudioOutput.cc b/src/GAudioOutput.cc index a6788f97bdf7850310f608c1a1738f516046ba75..dc847cee7c0a5464fe5a75f346d78953fcfab182 100644 --- a/src/GAudioOutput.cc +++ b/src/GAudioOutput.cc @@ -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; } diff --git a/src/GAudioOutput.h b/src/GAudioOutput.h index 4330a8e816c72afb22e2022ac74482866effb5aa..b9440e5856e2af1a5f6c0e2fafb39396ed8e9806 100644 --- a/src/GAudioOutput.h +++ b/src/GAudioOutput.h @@ -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 */ diff --git a/src/audio/QGCAudioWorker.cpp b/src/audio/QGCAudioWorker.cpp index e56133206b93cb5a5cf65da3573ecd454684dc46..0e74a85e95b6e116ca21acd7d1450a1b5dde48d1 100644 --- a/src/audio/QGCAudioWorker.cpp +++ b/src/audio/QGCAudioWorker.cpp @@ -6,6 +6,7 @@ #include "QGC.h" #include "QGCAudioWorker.h" +#include "GAudioOutput.h" #if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED #include @@ -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() { // 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()); } } diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 1e7f16d0e99e04f6dbc15d6fc05ee42706bbfb17..a474a487ba08b182ef7ebae506d00cd34f3f45c3 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -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() 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) 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)