From 1d5a31d3a4d2763313beaf7fe671354cf770c28b Mon Sep 17 00:00:00 2001 From: pixhawk Date: Mon, 12 Apr 2010 08:01:38 +0200 Subject: [PATCH] Cleaned up directory structure, re-enabled Linux audio output --- .gitignore | 2 +- mavground.pri => qgroundcontrol.pri | 11 ++--- mavground.pro => qgroundcontrol.pro | 0 src/GAudioOutput.cc | 73 ++++++++++++----------------- src/GAudioOutput.h | 6 ++- 5 files changed, 40 insertions(+), 52 deletions(-) rename mavground.pri => qgroundcontrol.pri (96%) rename mavground.pro => qgroundcontrol.pro (100%) diff --git a/.gitignore b/.gitignore index 7c993aa7c..537e1a591 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ tmp debug release qgroundcontrol.xcodeproj/** -qgroundcontrol +qgroundcontrol T*.wav diff --git a/mavground.pri b/qgroundcontrol.pri similarity index 96% rename from mavground.pri rename to qgroundcontrol.pri index 0360d428c..616eccd77 100644 --- a/mavground.pri +++ b/qgroundcontrol.pri @@ -40,11 +40,6 @@ OBJECTS_DIR = $$BUILDDIR/obj MOC_DIR = $$BUILDDIR/moc UI_HEADERS_DIR = src/ui/generated - -# Add external libraries -INCLUDEPATH += $$BASEDIR/lib/flite/include \ - $$BASEDIR/lib/flite/lang - #$$BASEDIR/lib/qextserialport/include # $$BASEDIR/lib/openjaus/libjaus/include \ # $$BASEDIR/lib/openjaus/libopenJaus/include @@ -99,7 +94,10 @@ linux-g++ { release { DESTDIR = $$BASEDIR } - INCLUDEPATH += /usr/include + INCLUDEPATH += /usr/include \ + $$BASEDIR/lib/flite/include \ + $$BASEDIR/lib/flite/lang + HARDWARE_PLATFORM = $$system(uname -a) contains( HARDWARE_PLATFORM, x86_64 ) { @@ -114,7 +112,6 @@ linux-g++ { message(Building for GNU/Linux 32bit/i386) } LIBS += -lm \ - -lflite_cmu_us_awb \ -lflite_cmu_us_rms \ -lflite_cmu_us_slt \ -lflite_usenglish \ diff --git a/mavground.pro b/qgroundcontrol.pro similarity index 100% rename from mavground.pro rename to qgroundcontrol.pro diff --git a/src/GAudioOutput.cc b/src/GAudioOutput.cc index cac132a52..3e5cf8011 100644 --- a/src/GAudioOutput.cc +++ b/src/GAudioOutput.cc @@ -48,13 +48,13 @@ using System.Speech.Synthesis; #ifdef Q_OS_LINUX extern "C" { - #include - #include +#include +#include //#include //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_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); @@ -91,9 +91,12 @@ emergency(false) #ifdef Q_OS_LINUX flite_init(); #endif + // Initialize audio output m_media = new Phonon::MediaObject(this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); createPath(m_media, audioOutput); + + // Prepare regular emergency signal, will be fired off on calling startEmergency() emergencyTimer = new QTimer(); connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep())); @@ -102,11 +105,8 @@ emergency(false) case 0: selectFemaleVoice(); break; - case 1: - selectMaleVoice(); - break; default: - selectNeutralVoice(); + selectMaleVoice(); break; } } @@ -132,7 +132,6 @@ bool GAudioOutput::say(QString text, int severity) // 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; @@ -149,10 +148,6 @@ bool GAudioOutput::say(QString text, int severity) SpeakString(str2); qDebug() << "Synthesized: " << text.toAscii(); #endif - -#ifdef Q_OS_WIN32 - qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!"; -#endif } return res; } @@ -227,52 +222,46 @@ void GAudioOutput::beep() void GAudioOutput::selectFemaleVoice() { #ifdef Q_OS_LINUX - //this->voice = register_cmu_us_slt(NULL); + this->voice = register_cmu_us_slt(NULL); #endif } void GAudioOutput::selectMaleVoice() { #ifdef Q_OS_LINUX - //this->voice = register_cmu_us_rms(NULL); + this->voice = register_cmu_us_rms(NULL); #endif } - +/* void GAudioOutput::selectNeutralVoice() { #ifdef Q_OS_LINUX - //this->voice = register_cmu_us_awb(NULL); + this->voice = register_cmu_us_awb(NULL); #endif -} +}*/ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - QStringList GAudioOutput::listVoices(void) - { - QStringList l; +QStringList GAudioOutput::listVoices(void) +{ + QStringList l; #ifdef Q_OS_LINUX - cst_voice *voice; - const cst_val *v; + cst_voice *voice; + const cst_val *v; - /* - 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; + 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); } -#ifdef __cplusplus + printf("\n"); + +#endif + return l; + } -#endif /* __cplusplus */ diff --git a/src/GAudioOutput.h b/src/GAudioOutput.h index c375ba210..9f1c93db3 100644 --- a/src/GAudioOutput.h +++ b/src/GAudioOutput.h @@ -65,6 +65,10 @@ public: static GAudioOutput* instance(); /** @brief List available voices */ QStringList listVoices(void); + enum { + VOICE_MALE = 0, + VOICE_FEMALE + } QGVoice; public slots: /** @brief Say this text if current output priority matches */ @@ -79,8 +83,6 @@ public slots: void selectFemaleVoice(); /** @brief Select male voice */ void selectMaleVoice(); - /** @brief Select neutral voice */ - void selectNeutralVoice(); /** @brief Play emergency sound */ void beep(); -- 2.22.0