Browse Source

Cleaned up directory structure, re-enabled Linux audio output

QGC4.4
pixhawk 15 years ago
parent
commit
1d5a31d3a4
  1. 2
      .gitignore
  2. 11
      qgroundcontrol.pri
  3. 0
      qgroundcontrol.pro
  4. 73
      src/GAudioOutput.cc
  5. 6
      src/GAudioOutput.h

2
.gitignore vendored

@ -16,4 +16,4 @@ tmp
debug debug
release release
qgroundcontrol.xcodeproj/** qgroundcontrol.xcodeproj/**
qgroundcontrol qgroundcontrol T*.wav

11
mavground.pri → qgroundcontrol.pri

@ -40,11 +40,6 @@ OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated UI_HEADERS_DIR = src/ui/generated
# Add external libraries
INCLUDEPATH += $$BASEDIR/lib/flite/include \
$$BASEDIR/lib/flite/lang
#$$BASEDIR/lib/qextserialport/include #$$BASEDIR/lib/qextserialport/include
# $$BASEDIR/lib/openjaus/libjaus/include \ # $$BASEDIR/lib/openjaus/libjaus/include \
# $$BASEDIR/lib/openjaus/libopenJaus/include # $$BASEDIR/lib/openjaus/libopenJaus/include
@ -99,7 +94,10 @@ linux-g++ {
release { release {
DESTDIR = $$BASEDIR DESTDIR = $$BASEDIR
} }
INCLUDEPATH += /usr/include INCLUDEPATH += /usr/include \
$$BASEDIR/lib/flite/include \
$$BASEDIR/lib/flite/lang
HARDWARE_PLATFORM = $$system(uname -a) HARDWARE_PLATFORM = $$system(uname -a)
contains( HARDWARE_PLATFORM, x86_64 ) { contains( HARDWARE_PLATFORM, x86_64 ) {
@ -114,7 +112,6 @@ linux-g++ {
message(Building for GNU/Linux 32bit/i386) message(Building for GNU/Linux 32bit/i386)
} }
LIBS += -lm \ LIBS += -lm \
-lflite_cmu_us_awb \
-lflite_cmu_us_rms \ -lflite_cmu_us_rms \
-lflite_cmu_us_slt \ -lflite_cmu_us_slt \
-lflite_usenglish \ -lflite_usenglish \

0
mavground.pro → qgroundcontrol.pro

73
src/GAudioOutput.cc

@ -48,13 +48,13 @@ using System.Speech.Synthesis;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
extern "C" { extern "C" {
#include <flite.h> #include <flite.h>
#include <cmu_us_awb/voxdefs.h> #include <cmu_us_awb/voxdefs.h>
//#include <cmu_us_slt/voxdefs.h> //#include <cmu_us_slt/voxdefs.h>
//cst_voice *REGISTER_VOX(const char *voxdir); //cst_voice *REGISTER_VOX(const char *voxdir);
//void UNREGISTER_VOX(cst_voice *vox); //void UNREGISTER_VOX(cst_voice *vox);
cst_voice *register_cmu_us_awb(const char *voxdir); //cst_voice *register_cmu_us_awb(const char *voxdir);
void unregister_cmu_us_awb(cst_voice *vox); //void unregister_cmu_us_awb(cst_voice *vox);
cst_voice *register_cmu_us_slt(const char *voxdir); cst_voice *register_cmu_us_slt(const char *voxdir);
void unregister_cmu_us_slt(cst_voice *vox); void unregister_cmu_us_slt(cst_voice *vox);
cst_voice *register_cmu_us_rms(const char *voxdir); cst_voice *register_cmu_us_rms(const char *voxdir);
@ -91,9 +91,12 @@ emergency(false)
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
flite_init(); flite_init();
#endif #endif
// Initialize audio output
m_media = new Phonon::MediaObject(this); m_media = new Phonon::MediaObject(this);
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
createPath(m_media, audioOutput); createPath(m_media, audioOutput);
// Prepare regular emergency signal, will be fired off on calling startEmergency()
emergencyTimer = new QTimer(); emergencyTimer = new QTimer();
connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep())); connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep()));
@ -102,11 +105,8 @@ emergency(false)
case 0: case 0:
selectFemaleVoice(); selectFemaleVoice();
break; break;
case 1:
selectMaleVoice();
break;
default: default:
selectNeutralVoice(); selectMaleVoice();
break; break;
} }
} }
@ -132,7 +132,6 @@ bool GAudioOutput::say(QString text, int severity)
// file.fileName() returns the unique file name // file.fileName() returns the unique file name
cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff"); cst_wave_save(wav, file.fileName().toStdString().c_str(), "riff");
m_media->setCurrentSource(Phonon::MediaSource(file.fileName().toStdString().c_str())); m_media->setCurrentSource(Phonon::MediaSource(file.fileName().toStdString().c_str()));
qDebug() << "TYPE:" << m_media->currentSource().type();
m_media->play(); m_media->play();
qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str(); qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str();
res = true; res = true;
@ -149,10 +148,6 @@ bool GAudioOutput::say(QString text, int severity)
SpeakString(str2); SpeakString(str2);
qDebug() << "Synthesized: " << text.toAscii(); qDebug() << "Synthesized: " << text.toAscii();
#endif #endif
#ifdef Q_OS_WIN32
qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!";
#endif
} }
return res; return res;
} }
@ -227,52 +222,46 @@ void GAudioOutput::beep()
void GAudioOutput::selectFemaleVoice() void GAudioOutput::selectFemaleVoice()
{ {
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
//this->voice = register_cmu_us_slt(NULL); this->voice = register_cmu_us_slt(NULL);
#endif #endif
} }
void GAudioOutput::selectMaleVoice() void GAudioOutput::selectMaleVoice()
{ {
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
//this->voice = register_cmu_us_rms(NULL); this->voice = register_cmu_us_rms(NULL);
#endif #endif
} }
/*
void GAudioOutput::selectNeutralVoice() void GAudioOutput::selectNeutralVoice()
{ {
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
//this->voice = register_cmu_us_awb(NULL); this->voice = register_cmu_us_awb(NULL);
#endif #endif
} }*/
#ifdef __cplusplus QStringList GAudioOutput::listVoices(void)
extern "C" { {
#endif /* __cplusplus */ QStringList l;
QStringList GAudioOutput::listVoices(void)
{
QStringList l;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
cst_voice *voice; cst_voice *voice;
const cst_val *v; 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 */

6
src/GAudioOutput.h

@ -65,6 +65,10 @@ public:
static GAudioOutput* instance(); static GAudioOutput* instance();
/** @brief List available voices */ /** @brief List available voices */
QStringList listVoices(void); QStringList listVoices(void);
enum {
VOICE_MALE = 0,
VOICE_FEMALE
} QGVoice;
public slots: public slots:
/** @brief Say this text if current output priority matches */ /** @brief Say this text if current output priority matches */
@ -79,8 +83,6 @@ public slots:
void selectFemaleVoice(); void selectFemaleVoice();
/** @brief Select male voice */ /** @brief Select male voice */
void selectMaleVoice(); void selectMaleVoice();
/** @brief Select neutral voice */
void selectNeutralVoice();
/** @brief Play emergency sound */ /** @brief Play emergency sound */
void beep(); void beep();

Loading…
Cancel
Save