27 changed files with 891 additions and 636 deletions
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@ -1,155 +1,149 @@
@@ -1,155 +1,149 @@
|
||||
# Include general settings for MAVGround |
||||
include(mavground.pri) |
||||
|
||||
# Include serial port library |
||||
include(src/lib/qextserialport/qextserialport.pri) |
||||
|
||||
# Include QWT plotting library |
||||
include(src/lib/qwt/qwt.pri) |
||||
|
||||
# Include FLITE audio synthesizer library |
||||
#include(src/lib/flite/flite.pri) |
||||
|
||||
# Include QMapControl map library |
||||
include(lib/QMapControl/QMapControl.pri) |
||||
DEPENDPATH += . \ |
||||
lib/QMapControl \ |
||||
lib/QMapControl/src |
||||
INCLUDEPATH += . \ |
||||
lib/QMapControl \ |
||||
../mavlink/src |
||||
|
||||
# Input |
||||
FORMS += src/ui/MainWindow.ui \ |
||||
src/ui/CommSettings.ui \ |
||||
src/ui/SerialSettings.ui \ |
||||
src/ui/UASControl.ui \ |
||||
src/ui/UASList.ui \ |
||||
src/ui/UASInfo.ui \ |
||||
src/ui/LineChart.ui \ |
||||
src/ui/UASView.ui \ |
||||
src/ui/ParameterInterface.ui \ |
||||
src/ui/WaypointList.ui \ |
||||
src/ui/WaypointView.ui \ |
||||
src/ui/ObjectDetectionView.ui \ |
||||
src/ui/JoystickWidget.ui \ |
||||
src/ui/DebugConsole.ui \ |
||||
src/ui/MapWidget.ui \ |
||||
src/ui/XMLCommProtocolWidget.ui \ |
||||
src/ui/HDDisplay.ui \ |
||||
src/ui/MAVLinkSettingsWidget.ui \ |
||||
src/ui/AudioOutputWidget.ui |
||||
INCLUDEPATH += src \ |
||||
src/ui \ |
||||
src/ui/linechart \ |
||||
src/ui/uas \ |
||||
src/ui/map \ |
||||
src/uas \ |
||||
src/comm \ |
||||
include/ui \ |
||||
src/input \ |
||||
src/lib/qmapcontrol \ |
||||
src/ui/mavlink |
||||
HEADERS += src/MG.h \ |
||||
src/Core.h \ |
||||
src/uas/UASInterface.h \ |
||||
src/uas/UAS.h \ |
||||
src/uas/UASManager.h \ |
||||
src/comm/LinkManager.h \ |
||||
src/comm/LinkInterface.h \ |
||||
src/comm/SerialLinkInterface.h \ |
||||
src/comm/SerialLink.h \ |
||||
src/comm/SerialSimulationLink.h \ |
||||
src/comm/ProtocolInterface.h \ |
||||
src/comm/MAVLinkProtocol.h \ |
||||
src/comm/AS4Protocol.h \ |
||||
src/ui/CommConfigurationWindow.h \ |
||||
src/ui/SerialConfigurationWindow.h \ |
||||
src/ui/MainWindow.h \ |
||||
src/ui/uas/UASControlWidget.h \ |
||||
src/ui/uas/UASListWidget.h \ |
||||
src/ui/uas/UASInfoWidget.h \ |
||||
src/ui/HUD.h \ |
||||
src/ui/linechart/LinechartWidget.h \ |
||||
src/ui/linechart/LinechartContainer.h \ |
||||
src/ui/linechart/LinechartPlot.h \ |
||||
src/ui/linechart/Scrollbar.h \ |
||||
src/ui/linechart/ScrollZoomer.h \ |
||||
src/configuration.h \ |
||||
src/ui/uas/UASView.h \ |
||||
src/ui/CameraView.h \ |
||||
src/comm/MAVLinkSimulationLink.h \ |
||||
src/comm/UDPLink.h \ |
||||
src/ui/ParameterInterface.h \ |
||||
src/ui/WaypointList.h \ |
||||
src/Waypoint.h \ |
||||
src/ui/WaypointView.h \ |
||||
src/ui/ObjectDetectionView.h \ |
||||
src/input/JoystickInput.h \ |
||||
src/ui/JoystickWidget.h \ |
||||
src/ui/PFD.h \ |
||||
src/ui/GaugePanel.h \ |
||||
src/ui/DebugConsole.h \ |
||||
src/ui/MapWidget.h \ |
||||
src/ui/XMLCommProtocolWidget.h \ |
||||
src/ui/mavlink/DomItem.h \ |
||||
src/ui/mavlink/DomModel.h \ |
||||
src/comm/MAVLinkXMLParser.h \ |
||||
src/ui/HDDisplay.h \ |
||||
src/ui/MAVLinkSettingsWidget.h \ |
||||
src/ui/AudioOutputWidget.h \ |
||||
src/AudioOutput.h \ |
||||
src/LogCompressor.h \ |
||||
src/comm/ViconTarsusProtocol.h \ |
||||
src/comm/TarsusField.h \ |
||||
src/comm/TarsusFieldDescriptor.h \ |
||||
src/comm/TarsusFieldTriplet.h \ |
||||
src/comm/TarsusRigidBody.h \ |
||||
src/comm/TarsusStream.h |
||||
SOURCES += src/main.cc \ |
||||
src/Core.cc \ |
||||
src/uas/UASManager.cc \ |
||||
src/uas/UAS.cc \ |
||||
src/comm/LinkManager.cc \ |
||||
src/comm/SerialLink.cc \ |
||||
src/comm/SerialSimulationLink.cc \ |
||||
src/comm/MAVLinkProtocol.cc \ |
||||
src/comm/AS4Protocol.cc \ |
||||
src/ui/CommConfigurationWindow.cc \ |
||||
src/ui/SerialConfigurationWindow.cc \ |
||||
src/ui/MainWindow.cc \ |
||||
src/ui/uas/UASControlWidget.cc \ |
||||
src/ui/uas/UASListWidget.cc \ |
||||
src/ui/uas/UASInfoWidget.cc \ |
||||
src/ui/HUD.cc \ |
||||
src/ui/linechart/LinechartWidget.cc \ |
||||
src/ui/linechart/LinechartContainer.cc \ |
||||
src/ui/linechart/LinechartPlot.cc \ |
||||
src/ui/linechart/Scrollbar.cc \ |
||||
src/ui/linechart/ScrollZoomer.cc \ |
||||
src/ui/uas/UASView.cc \ |
||||
src/ui/CameraView.cc \ |
||||
src/comm/MAVLinkSimulationLink.cc \ |
||||
src/comm/UDPLink.cc \ |
||||
src/ui/ParameterInterface.cc \ |
||||
src/ui/WaypointList.cc \ |
||||
src/Waypoint.cc \ |
||||
src/ui/WaypointView.cc \ |
||||
src/ui/ObjectDetectionView.cc \ |
||||
src/input/JoystickInput.cc \ |
||||
src/ui/JoystickWidget.cc \ |
||||
src/ui/PFD.cc \ |
||||
src/ui/GaugePanel.cc \ |
||||
src/ui/DebugConsole.cc \ |
||||
src/ui/MapWidget.cc \ |
||||
src/ui/XMLCommProtocolWidget.cc \ |
||||
src/ui/mavlink/DomItem.cc \ |
||||
src/ui/mavlink/DomModel.cc \ |
||||
src/comm/MAVLinkXMLParser.cc \ |
||||
src/ui/HDDisplay.cc \ |
||||
src/ui/MAVLinkSettingsWidget.cc \ |
||||
src/ui/AudioOutputWidget.cc \ |
||||
src/AudioOutput.cc \ |
||||
src/LogCompressor.cc \ |
||||
src/comm/ViconTarsusProtocol.cc |
||||
RESOURCES = mavground.qrc |
||||
# Include general settings for MAVGround |
||||
include(mavground.pri) |
||||
|
||||
# Include serial port library |
||||
include(src/lib/qextserialport/qextserialport.pri) |
||||
|
||||
# Include QWT plotting library |
||||
include(src/lib/qwt/qwt.pri) |
||||
|
||||
# Include FLITE audio synthesizer library |
||||
# include(src/lib/flite/flite.pri) |
||||
# Include QMapControl map library |
||||
include(lib/QMapControl/QMapControl.pri) |
||||
DEPENDPATH += . \ |
||||
lib/QMapControl \ |
||||
lib/QMapControl/src |
||||
INCLUDEPATH += . \ |
||||
lib/QMapControl \ |
||||
../mavlink/src \ |
||||
mavlink/src \ |
||||
src/mavlink |
||||
|
||||
# Input |
||||
FORMS += src/ui/MainWindow.ui \ |
||||
src/ui/CommSettings.ui \ |
||||
src/ui/SerialSettings.ui \ |
||||
src/ui/UASControl.ui \ |
||||
src/ui/UASList.ui \ |
||||
src/ui/UASInfo.ui \ |
||||
src/ui/LineChart.ui \ |
||||
src/ui/UASView.ui \ |
||||
src/ui/ParameterInterface.ui \ |
||||
src/ui/WaypointList.ui \ |
||||
src/ui/WaypointView.ui \ |
||||
src/ui/ObjectDetectionView.ui \ |
||||
src/ui/JoystickWidget.ui \ |
||||
src/ui/DebugConsole.ui \ |
||||
src/ui/MapWidget.ui \ |
||||
src/ui/XMLCommProtocolWidget.ui \ |
||||
src/ui/HDDisplay.ui \ |
||||
src/ui/MAVLinkSettingsWidget.ui \ |
||||
src/ui/AudioOutputWidget.ui |
||||
INCLUDEPATH += src \ |
||||
src/ui \ |
||||
src/ui/linechart \ |
||||
src/ui/uas \ |
||||
src/ui/map \ |
||||
src/uas \ |
||||
src/comm \ |
||||
include/ui \ |
||||
src/input \ |
||||
src/lib/qmapcontrol \ |
||||
src/ui/mavlink |
||||
HEADERS += src/MG.h \ |
||||
src/Core.h \ |
||||
src/uas/UASInterface.h \ |
||||
src/uas/UAS.h \ |
||||
src/uas/UASManager.h \ |
||||
src/comm/LinkManager.h \ |
||||
src/comm/LinkInterface.h \ |
||||
src/comm/SerialLinkInterface.h \ |
||||
src/comm/SerialLink.h \ |
||||
src/comm/SerialSimulationLink.h \ |
||||
src/comm/ProtocolInterface.h \ |
||||
src/comm/MAVLinkProtocol.h \ |
||||
src/comm/AS4Protocol.h \ |
||||
src/ui/CommConfigurationWindow.h \ |
||||
src/ui/SerialConfigurationWindow.h \ |
||||
src/ui/MainWindow.h \ |
||||
src/ui/uas/UASControlWidget.h \ |
||||
src/ui/uas/UASListWidget.h \ |
||||
src/ui/uas/UASInfoWidget.h \ |
||||
src/ui/HUD.h \ |
||||
src/ui/linechart/LinechartWidget.h \ |
||||
src/ui/linechart/LinechartContainer.h \ |
||||
src/ui/linechart/LinechartPlot.h \ |
||||
src/ui/linechart/Scrollbar.h \ |
||||
src/ui/linechart/ScrollZoomer.h \ |
||||
src/configuration.h \ |
||||
src/ui/uas/UASView.h \ |
||||
src/ui/CameraView.h \ |
||||
src/comm/MAVLinkSimulationLink.h \ |
||||
src/comm/UDPLink.h \ |
||||
src/ui/ParameterInterface.h \ |
||||
src/ui/WaypointList.h \ |
||||
src/Waypoint.h \ |
||||
src/ui/WaypointView.h \ |
||||
src/ui/ObjectDetectionView.h \ |
||||
src/input/JoystickInput.h \ |
||||
src/ui/JoystickWidget.h \ |
||||
src/ui/PFD.h \ |
||||
src/ui/GaugePanel.h \ |
||||
src/ui/DebugConsole.h \ |
||||
src/ui/MapWidget.h \ |
||||
src/ui/XMLCommProtocolWidget.h \ |
||||
src/ui/mavlink/DomItem.h \ |
||||
src/ui/mavlink/DomModel.h \ |
||||
src/comm/MAVLinkXMLParser.h \ |
||||
src/ui/HDDisplay.h \ |
||||
src/ui/MAVLinkSettingsWidget.h \ |
||||
src/ui/AudioOutputWidget.h \ |
||||
src/GAudioOutput.h \ |
||||
src/LogCompressor.h |
||||
SOURCES += src/main.cc \ |
||||
src/Core.cc \ |
||||
src/uas/UASManager.cc \ |
||||
src/uas/UAS.cc \ |
||||
src/comm/LinkManager.cc \ |
||||
src/comm/SerialLink.cc \ |
||||
src/comm/SerialSimulationLink.cc \ |
||||
src/comm/MAVLinkProtocol.cc \ |
||||
src/comm/AS4Protocol.cc \ |
||||
src/ui/CommConfigurationWindow.cc \ |
||||
src/ui/SerialConfigurationWindow.cc \ |
||||
src/ui/MainWindow.cc \ |
||||
src/ui/uas/UASControlWidget.cc \ |
||||
src/ui/uas/UASListWidget.cc \ |
||||
src/ui/uas/UASInfoWidget.cc \ |
||||
src/ui/HUD.cc \ |
||||
src/ui/linechart/LinechartWidget.cc \ |
||||
src/ui/linechart/LinechartContainer.cc \ |
||||
src/ui/linechart/LinechartPlot.cc \ |
||||
src/ui/linechart/Scrollbar.cc \ |
||||
src/ui/linechart/ScrollZoomer.cc \ |
||||
src/ui/uas/UASView.cc \ |
||||
src/ui/CameraView.cc \ |
||||
src/comm/MAVLinkSimulationLink.cc \ |
||||
src/comm/UDPLink.cc \ |
||||
src/ui/ParameterInterface.cc \ |
||||
src/ui/WaypointList.cc \ |
||||
src/Waypoint.cc \ |
||||
src/ui/WaypointView.cc \ |
||||
src/ui/ObjectDetectionView.cc \ |
||||
src/input/JoystickInput.cc \ |
||||
src/ui/JoystickWidget.cc \ |
||||
src/ui/PFD.cc \ |
||||
src/ui/GaugePanel.cc \ |
||||
src/ui/DebugConsole.cc \ |
||||
src/ui/MapWidget.cc \ |
||||
src/ui/XMLCommProtocolWidget.cc \ |
||||
src/ui/mavlink/DomItem.cc \ |
||||
src/ui/mavlink/DomModel.cc \ |
||||
src/comm/MAVLinkXMLParser.cc \ |
||||
src/ui/HDDisplay.cc \ |
||||
src/ui/MAVLinkSettingsWidget.cc \ |
||||
src/ui/AudioOutputWidget.cc \ |
||||
src/GAudioOutput.cc \ |
||||
src/LogCompressor.cc |
||||
RESOURCES = mavground.qrc |
||||
|
@ -1,156 +0,0 @@
@@ -1,156 +0,0 @@
|
||||
#include "AudioOutput.h" |
||||
#include <flite.h> |
||||
|
||||
#include <phonon/mediaobject.h> |
||||
#include <QTemporaryFile> |
||||
|
||||
#include <QDebug> |
||||
|
||||
extern "C" { |
||||
#include <cmu_us_awb/voxdefs.h> |
||||
//#include <cmu_us_slt/voxdefs.h>
|
||||
//cst_voice *REGISTER_VOX(const char *voxdir);
|
||||
//void UNREGISTER_VOX(cst_voice *vox);
|
||||
cst_voice *register_cmu_us_awb(const char *voxdir); |
||||
void unregister_cmu_us_awb(cst_voice *vox); |
||||
cst_voice *register_cmu_us_slt(const char *voxdir); |
||||
void unregister_cmu_us_slt(cst_voice *vox); |
||||
cst_voice *register_cmu_us_rms(const char *voxdir); |
||||
void unregister_cmu_us_rms(cst_voice *vox); |
||||
}; |
||||
|
||||
AudioOutput::AudioOutput(QString voice, QObject* parent) : QObject(parent), |
||||
voice(NULL), |
||||
voiceIndex(0) |
||||
{ |
||||
#ifndef _WIN32 |
||||
flite_init(); |
||||
#endif |
||||
|
||||
switch (voiceIndex) |
||||
{ |
||||
case 0: |
||||
selectFemaleVoice(); |
||||
break; |
||||
case 1: |
||||
selectMaleVoice(); |
||||
break; |
||||
default: |
||||
selectNeutralVoice(); |
||||
break; |
||||
} |
||||
|
||||
/*
|
||||
// List available voices
|
||||
QStringList voices = listVoices(); |
||||
foreach (QString s, voices) |
||||
{ |
||||
qDebug() << "VOICE: " << s; |
||||
} |
||||
|
||||
if (voice.length() > 0) |
||||
{ |
||||
//this->voice = flite_voice_select(voice.toStdString().c_str());
|
||||
} |
||||
else |
||||
{ |
||||
// Take default voice
|
||||
//this->voice = flite_voice_select("awb");
|
||||
} |
||||
*/ |
||||
} |
||||
|
||||
bool AudioOutput::say(QString text, int severity) |
||||
{ |
||||
// Only give speech output on Linux and MacOS
|
||||
#ifndef _WIN32 |
||||
QTemporaryFile file; |
||||
file.setFileTemplate("XXXXXX.wav"); |
||||
if (file.open()) |
||||
{ |
||||
cst_wave* wav = flite_text_to_wave(text.toStdString().c_str(), this->voice); |
||||
// file.fileName() returns the unique file name
|
||||
cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff"); |
||||
Phonon::MediaObject *music = |
||||
Phonon::createPlayer(Phonon::MusicCategory, |
||||
Phonon::MediaSource(file.fileName().toStdString().c_str())); |
||||
music->play(); |
||||
qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str(); |
||||
} |
||||
#else |
||||
qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!"; |
||||
#endif |
||||
return true; |
||||
} |
||||
|
||||
bool AudioOutput::alert(QString text) |
||||
{ |
||||
// Play alert sound
|
||||
|
||||
// Say alert message
|
||||
return say(text, 2); |
||||
} |
||||
|
||||
bool AudioOutput::startEmergency() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
bool AudioOutput::stopEmergency() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
void AudioOutput::selectFemaleVoice() |
||||
{ |
||||
#ifndef _WIN32 |
||||
this->voice = register_cmu_us_slt(NULL); |
||||
#endif |
||||
} |
||||
|
||||
void AudioOutput::selectMaleVoice() |
||||
{ |
||||
#ifndef _WIN32 |
||||
this->voice = register_cmu_us_rms(NULL); |
||||
#endif |
||||
} |
||||
|
||||
|
||||
void AudioOutput::selectNeutralVoice() |
||||
{ |
||||
#ifndef _WIN32 |
||||
this->voice = register_cmu_us_awb(NULL); |
||||
#endif |
||||
} |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif /* __cplusplus */ |
||||
QStringList AudioOutput::listVoices(void) |
||||
{ |
||||
|
||||
|
||||
cst_voice *voice; |
||||
const cst_val *v; |
||||
QStringList l; |
||||
|
||||
#ifndef _WIN32 |
||||
/*
|
||||
printf("Voices available: "); |
||||
for (v=flite_voice_list; v; v=val_cdr(v)) |
||||
{ |
||||
voice = val_voice(val_car(v)); |
||||
QString s; |
||||
s.sprintf("%s",voice->name); |
||||
printf("%s",voice->name); |
||||
l.append(s); |
||||
} |
||||
printf("\n"); |
||||
*/ |
||||
#endif |
||||
return l; |
||||
|
||||
} |
||||
#ifdef __cplusplus |
||||
} |
||||
#endif /* __cplusplus */ |
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
#ifndef AUDIOOUTPUT_H |
||||
#define AUDIOOUTPUT_H |
||||
|
||||
#include <QObject> |
||||
#include <QStringList> |
||||
#include <flite.h> |
||||
|
||||
class AudioOutput : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
AudioOutput(QString voice="", QObject* parent=NULL); |
||||
/** @brief List available voices */ |
||||
QStringList listVoices(void); |
||||
|
||||
public slots: |
||||
/** @brief Say this text if current output priority matches */ |
||||
bool say(QString text, int severity); |
||||
/** @brief Play alert sound */ |
||||
bool alert(QString text); |
||||
/** @brief Start emergency sound */ |
||||
bool startEmergency(); |
||||
/** @brief Stop emergency sound */ |
||||
bool stopEmergency(); |
||||
/** @brief Select female voice */ |
||||
void selectFemaleVoice(); |
||||
/** @brief Select male voice */ |
||||
void selectMaleVoice(); |
||||
/** @brief Select neutral voice */ |
||||
void selectNeutralVoice(); |
||||
protected: |
||||
cst_voice* voice; |
||||
int voiceIndex; |
||||
|
||||
}; |
||||
|
||||
#endif // AUDIOOUTPUT_H
|
@ -0,0 +1,265 @@
@@ -0,0 +1,265 @@
|
||||
/*=====================================================================
|
||||
|
||||
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit |
||||
|
||||
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
|
||||
|
||||
This file is part of the PIXHAWK project |
||||
|
||||
PIXHAWK is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
PIXHAWK is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Implementation of audio output |
||||
* |
||||
* @author Lorenz Meier <mavteam@student.ethz.ch> |
||||
* |
||||
*/ |
||||
|
||||
#include <QApplication> |
||||
#include "GAudioOutput.h" |
||||
#include "MG.h" |
||||
#include <flite.h> |
||||
|
||||
#include <Phonon> |
||||
#include <QTemporaryFile> |
||||
|
||||
#include <QDebug> |
||||
|
||||
extern "C" { |
||||
#include <cmu_us_awb/voxdefs.h> |
||||
//#include <cmu_us_slt/voxdefs.h>
|
||||
//cst_voice *REGISTER_VOX(const char *voxdir);
|
||||
//void UNREGISTER_VOX(cst_voice *vox);
|
||||
cst_voice *register_cmu_us_awb(const char *voxdir); |
||||
void unregister_cmu_us_awb(cst_voice *vox); |
||||
cst_voice *register_cmu_us_slt(const char *voxdir); |
||||
void unregister_cmu_us_slt(cst_voice *vox); |
||||
cst_voice *register_cmu_us_rms(const char *voxdir); |
||||
void unregister_cmu_us_rms(cst_voice *vox); |
||||
}; |
||||
|
||||
/**
|
||||
* This class follows the singleton design pattern |
||||
* @see http://en.wikipedia.org/wiki/Singleton_pattern
|
||||
* A call to this function thus returns the only instance of this object |
||||
* the call can occur at any place in the code, no reference to the |
||||
* GAudioOutput object has to be passed. |
||||
*/ |
||||
GAudioOutput* GAudioOutput::instance() |
||||
{ |
||||
static GAudioOutput* _instance = 0; |
||||
if(_instance == 0) { |
||||
_instance = new GAudioOutput(); |
||||
// Set the application as parent to ensure that this object
|
||||
// will be destroyed when the main application exits
|
||||
_instance->setParent(qApp); |
||||
} |
||||
return _instance; |
||||
} |
||||
|
||||
GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), |
||||
voice(NULL), |
||||
voiceIndex(0), |
||||
emergency(false) |
||||
{ |
||||
#ifndef _WIN32 |
||||
flite_init(); |
||||
m_media = new Phonon::MediaObject(this); |
||||
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); |
||||
createPath(m_media, audioOutput); |
||||
emergencyTimer = new QTimer(); |
||||
connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep())); |
||||
#endif |
||||
|
||||
switch (voiceIndex) |
||||
{ |
||||
case 0: |
||||
selectFemaleVoice(); |
||||
break; |
||||
case 1: |
||||
selectMaleVoice(); |
||||
break; |
||||
default: |
||||
selectNeutralVoice(); |
||||
break; |
||||
} |
||||
|
||||
/*
|
||||
// List available voices
|
||||
QStringList voices = listVoices(); |
||||
foreach (QString s, voices) |
||||
{ |
||||
qDebug() << "VOICE: " << s; |
||||
} |
||||
|
||||
if (voice.length() > 0) |
||||
{ |
||||
//this->voice = flite_voice_select(voice.toStdString().c_str());
|
||||
} |
||||
else |
||||
{ |
||||
// Take default voice
|
||||
//this->voice = flite_voice_select("awb");
|
||||
} |
||||
*/ |
||||
|
||||
|
||||
} |
||||
|
||||
bool GAudioOutput::say(QString text, int severity) |
||||
{ |
||||
bool res = false; |
||||
if (!emergency) |
||||
{ |
||||
// Only give speech output on Linux and MacOS
|
||||
#ifndef _WIN32 |
||||
QTemporaryFile file; |
||||
file.setFileTemplate("XXXXXX.wav"); |
||||
if (file.open()) |
||||
{ |
||||
cst_wave* wav = flite_text_to_wave(text.toStdString().c_str(), this->voice); |
||||
// file.fileName() returns the unique file name
|
||||
cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff"); |
||||
m_media->setCurrentSource(Phonon::MediaSource(file.fileName().toStdString().c_str())); |
||||
qDebug() << "TYPE:" << m_media->currentSource().type(); |
||||
m_media->play(); |
||||
qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str(); |
||||
res = true; |
||||
} |
||||
#else |
||||
qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!"; |
||||
#endif |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
/**
|
||||
* @param text This message will be played after the alert beep |
||||
*/ |
||||
bool GAudioOutput::alert(QString text) |
||||
{ |
||||
if (!emergency) |
||||
{ |
||||
// Play alert sound
|
||||
m_media->setCurrentSource(Phonon::MediaSource(QString("alert.wav").toStdString().c_str())); |
||||
qDebug() << "FILENAME:" << m_media->currentSource().fileName(); |
||||
qDebug() << "TYPE:" << m_media->currentSource().type(); |
||||
qDebug() << QString("alert.wav").toStdString().c_str(); |
||||
m_media->play(); |
||||
m_media->setCurrentSource(Phonon::MediaSource(QString("alert.wav").toStdString().c_str())); |
||||
m_media->play(); |
||||
// Say alert message
|
||||
return true;//say(text, 2);
|
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* The emergency sound will be played continously during the emergency. |
||||
* call stopEmergency() to disable it again. No speech synthesis or other |
||||
* audio output is available during the emergency. |
||||
* |
||||
* @return true if the emergency could be started, false else |
||||
*/ |
||||
bool GAudioOutput::startEmergency() |
||||
{ |
||||
if (!emergency) |
||||
{ |
||||
emergency = true; |
||||
emergencyTimer->start(1600); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/**
|
||||
* Stops the continous emergency sound. Use startEmergency() to start |
||||
* the emergency sound. |
||||
* |
||||
* @return true if the emergency could be stopped, false else |
||||
*/ |
||||
bool GAudioOutput::stopEmergency() |
||||
{ |
||||
if (emergency) |
||||
{ |
||||
emergency = false; |
||||
emergencyTimer->stop(); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
void GAudioOutput::beep() |
||||
{ |
||||
m_media->setCurrentSource(Phonon::MediaSource(QString("alert.wav").toStdString().c_str())); |
||||
m_media->play(); |
||||
} |
||||
|
||||
void GAudioOutput::selectFemaleVoice() |
||||
{ |
||||
#ifndef _WIN32 |
||||
this->voice = register_cmu_us_slt(NULL); |
||||
#endif |
||||
} |
||||
|
||||
void GAudioOutput::selectMaleVoice() |
||||
{ |
||||
#ifndef _WIN32 |
||||
this->voice = register_cmu_us_rms(NULL); |
||||
#endif |
||||
} |
||||
|
||||
|
||||
void GAudioOutput::selectNeutralVoice() |
||||
{ |
||||
#ifndef _WIN32 |
||||
this->voice = register_cmu_us_awb(NULL); |
||||
#endif |
||||
} |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif /* __cplusplus */ |
||||
QStringList GAudioOutput::listVoices(void) |
||||
{ |
||||
|
||||
|
||||
cst_voice *voice; |
||||
const cst_val *v; |
||||
QStringList l; |
||||
|
||||
#ifndef _WIN32 |
||||
/*
|
||||
printf("Voices available: "); |
||||
for (v=flite_voice_list; v; v=val_cdr(v)) |
||||
{ |
||||
voice = val_voice(val_car(v)); |
||||
QString s; |
||||
s.sprintf("%s",voice->name); |
||||
printf("%s",voice->name); |
||||
l.append(s); |
||||
} |
||||
printf("\n"); |
||||
*/ |
||||
#endif |
||||
return l; |
||||
|
||||
} |
||||
#ifdef __cplusplus |
||||
} |
||||
#endif /* __cplusplus */ |
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
/*=====================================================================
|
||||
|
||||
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit |
||||
|
||||
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
|
||||
|
||||
This file is part of the PIXHAWK project |
||||
|
||||
PIXHAWK is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
PIXHAWK is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Definition of audio output |
||||
* |
||||
* @author Lorenz Meier <mavteam@student.ethz.ch> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GAUDIOOUTPUT_H |
||||
#define GAUDIOOUTPUT_H |
||||
|
||||
#include <QObject> |
||||
#include <QTimer> |
||||
#include <QStringList> |
||||
#include <flite.h> |
||||
#include <Phonon> |
||||
|
||||
/**
|
||||
* @brief Audio Output (speech synthesizer and "beep" output) |
||||
* This class follows the singleton design pattern |
||||
* @see http://en.wikipedia.org/wiki/Singleton_pattern
|
||||
*/ |
||||
class GAudioOutput : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
/** @brief Get the singleton instance */ |
||||
static GAudioOutput* GAudioOutput::instance(); |
||||
/** @brief List available voices */ |
||||
QStringList listVoices(void); |
||||
|
||||
public slots: |
||||
/** @brief Say this text if current output priority matches */ |
||||
bool say(QString text, int severity=1); |
||||
/** @brief Play alert sound */ |
||||
bool alert(QString text); |
||||
/** @brief Start emergency sound */ |
||||
bool startEmergency(); |
||||
/** @brief Stop emergency sound */ |
||||
bool stopEmergency(); |
||||
/** @brief Select female voice */ |
||||
void selectFemaleVoice(); |
||||
/** @brief Select male voice */ |
||||
void selectMaleVoice(); |
||||
/** @brief Select neutral voice */ |
||||
void selectNeutralVoice(); |
||||
/** @brief Play emergency sound */ |
||||
void beep(); |
||||
|
||||
protected: |
||||
cst_voice* voice; ///< The flite voice object
|
||||
int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms)
|
||||
Phonon::MediaObject* m_media; ///< The output object for audio
|
||||
Phonon::AudioOutput* m_audioOutput; |
||||
bool emergency; ///< Emergency status flag
|
||||
QTimer* emergencyTimer; |
||||
private: |
||||
GAudioOutput(QObject* parent=NULL); |
||||
}; |
||||
|
||||
#endif // AUDIOOUTPUT_H
|
Loading…
Reference in new issue