Commit c522b4ed authored by pixhawk's avatar pixhawk

Included Hugos x64 MAC fixes, changed voice interface to Apple native for Mac computers

parents 85f38487 fc050481
*Makefile* *Makefile*
./build build
Info.plist Info.plist
obj obj
*.log *.log
...@@ -16,3 +16,5 @@ qrc_*.cpp ...@@ -16,3 +16,5 @@ qrc_*.cpp
tmp tmp
debug debug
release release
opengroundcontrol.xcodeproj/**
[submodule "MAVLink"]
path = MAVLink
url = git://github.com/pixhawk/mavlink.git
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += network opengl svg xml QT += network opengl svg xml phonon
TEMPLATE = app TEMPLATE = app
TARGET = opengroundcontrol TARGET = opengroundcontrol
...@@ -62,23 +62,23 @@ macx { ...@@ -62,23 +62,23 @@ macx {
message(Building for Mac OS X) message(Building for Mac OS X)
QT += phonon CONFIG += x86
contains ( DEFINES, QT_MAC_USE_COCOA ) {
CONFIG += x86_64 cocoa
CONFIG -= static
}
DESTDIR = $$BASEDIR/bin/mac DESTDIR = $$BASEDIR/bin/mac
INCLUDEPATH += -framework SDL
LIBS += -framework IOKit \ LIBS += -framework IOKit \
-L/opt/local/lib \ -framework SDL \
-L$$BASEDIR/lib/flite/mac32 \ -framework CoreFoundation \
-lm \ -framework ApplicationServices \
-lflite_cmu_us_awb \ -lm
-lflite_cmu_us_rms \
-lflite_cmu_us_slt \
-lflite_usenglish \
-lflite_cmulex \
-lflite \
-L/lib/mac32/SDL \
-lSDL \
-lSDLmain
DEFINES += _TTY_POSIX_ DEFINES += _TTY_POSIX_
#ICON = $$BASEDIR/img/icons/empty.png #ICON = $$BASEDIR/img/icons/empty.png
...@@ -88,8 +88,6 @@ macx { ...@@ -88,8 +88,6 @@ macx {
linux-g++ { linux-g++ {
message(Building for GNU/Linux) message(Building for GNU/Linux)
QT += phonon
debug { debug {
DESTDIR = $$BASEDIR DESTDIR = $$BASEDIR
...@@ -99,10 +97,6 @@ linux-g++ { ...@@ -99,10 +97,6 @@ linux-g++ {
DESTDIR = $$BASEDIR DESTDIR = $$BASEDIR
} }
INCLUDEPATH += /usr/include/SDL INCLUDEPATH += /usr/include/SDL
# /usr/include/qwt-qt4
#-L$$BASEDIR/lib/qwt/linux \
DEFINES += _TTY_POSIX_ DEFINES += _TTY_POSIX_
...@@ -137,26 +131,18 @@ linux-g++ { ...@@ -137,26 +131,18 @@ linux-g++ {
} }
# Windows (32bit) # Windows (32bit/64bit)
win32 { win32 {
message(Building for Windows Platform (32/64bit)) message(Building for Windows Platform (32/64bit))
# Special settings for debug # Special settings for debug
#CONFIG += CONSOLE #CONFIG += CONSOLE
LIBS += -L$$BASEDIR\lib\sdl\win32 \ LIBS += -L$$BASEDIR\lib\sdl\win32 \
-lmingw32 -lSDLmain -lSDL -mwindows -lmingw32 -lSDLmain -lSDL -mwindows
INCLUDEPATH += $$BASEDIR/lib/sdl/include/SDL INCLUDEPATH += $$BASEDIR/lib/sdl/include/SDL
#LIBS += -L$$BASEDIR\lib\qextserialport\win32 \
# -lqextserialport \
# -lsetupapi
# -L$$BASEDIR/lib/openjaus/libjaus/lib/win32 \
# -ljaus \
# -L$$BASEDIR/lib/openjaus/libopenJaus/lib/win32 \
# -lopenjaus
DEFINES += _TTY_WIN_ DEFINES += _TTY_WIN_
debug { debug {
......
...@@ -8,7 +8,8 @@ include(src/lib/qextserialport/qextserialport.pri) ...@@ -8,7 +8,8 @@ include(src/lib/qextserialport/qextserialport.pri)
include(src/lib/qwt/qwt.pri) include(src/lib/qwt/qwt.pri)
# Include FLITE audio synthesizer library # Include FLITE audio synthesizer library
# include(src/lib/flite/flite.pri) #include(src/lib/flite/flite.pri)
# Include QMapControl map library # Include QMapControl map library
include(lib/QMapControl/QMapControl.pri) include(lib/QMapControl/QMapControl.pri)
DEPENDPATH += . \ DEPENDPATH += . \
...@@ -17,8 +18,8 @@ DEPENDPATH += . \ ...@@ -17,8 +18,8 @@ DEPENDPATH += . \
INCLUDEPATH += . \ INCLUDEPATH += . \
lib/QMapControl \ lib/QMapControl \
../mavlink/src \ ../mavlink/src \
mavlink/src \ MAVLink/src \
src/mavlink mavlink/src
# Input # Input
FORMS += src/ui/MainWindow.ui \ FORMS += src/ui/MainWindow.ui \
......
#include "AudioOutput.h"
#ifndef Q_OS_MAC
#include <flite.h>
#include <phonon/mediaobject.h>
#include <QTemporaryFile>
#else
#include <ApplicationServices/ApplicationServices.h>
#endif
#include <QDebug>
#ifndef Q_OS_MAC
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);
};
#endif
AudioOutput::AudioOutput(QString voice, QObject* parent) : QObject(parent),
voice(NULL),
voiceIndex(0)
{
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
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
#if defined(Q_OS_WIN32)
qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!";
#elif defined(Q_OS_MAC)
SpeakString((const unsigned char*)text.toAscii().data());
qDebug() << "Synthesized: " << text;
#else
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();
}
#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()
{
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
this->voice = register_cmu_us_slt(NULL);
#endif
}
void AudioOutput::selectMaleVoice()
{
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
this->voice = register_cmu_us_rms(NULL);
#endif
}
void AudioOutput::selectNeutralVoice()
{
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
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;
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
/*
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 */
...@@ -70,7 +70,6 @@ protected: ...@@ -70,7 +70,6 @@ protected:
private: private:
MainWindow* mainWindow; MainWindow* mainWindow;
//ViconTarsusProtocol* tarsus; //ViconTarsusProtocol* tarsus;
}; };
#endif /* _CORE_H_ */ #endif /* _CORE_H_ */
...@@ -32,13 +32,19 @@ This file is part of the PIXHAWK project ...@@ -32,13 +32,19 @@ This file is part of the PIXHAWK project
#include <QApplication> #include <QApplication>
#include "GAudioOutput.h" #include "GAudioOutput.h"
#include "MG.h" #include "MG.h"
#include <flite.h>
#ifdef Q_OS_MAC
#include <ApplicationServices/ApplicationServices.h>
#endif
#ifdef Q_OS_LINUX
#include <flite.h>
#endif
#include <Phonon> #include <Phonon>
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QDebug> #include <QDebug>
#ifndef Q_OS_MAC
extern "C" { extern "C" {
#include <cmu_us_awb/voxdefs.h> #include <cmu_us_awb/voxdefs.h>
//#include <cmu_us_slt/voxdefs.h> //#include <cmu_us_slt/voxdefs.h>
...@@ -51,6 +57,7 @@ extern "C" { ...@@ -51,6 +57,7 @@ extern "C" {
cst_voice *register_cmu_us_rms(const char *voxdir); cst_voice *register_cmu_us_rms(const char *voxdir);
void unregister_cmu_us_rms(cst_voice *vox); void unregister_cmu_us_rms(cst_voice *vox);
}; };
#endif
/** /**
* This class follows the singleton design pattern * This class follows the singleton design pattern
...@@ -76,14 +83,14 @@ voice(NULL), ...@@ -76,14 +83,14 @@ voice(NULL),
voiceIndex(0), voiceIndex(0),
emergency(false) emergency(false)
{ {
#ifndef _WIN32 #if Q_OS_LINUX
flite_init(); flite_init();
#endif
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);
emergencyTimer = new QTimer(); emergencyTimer = new QTimer();
connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep())); connect(emergencyTimer, SIGNAL(timeout()), this, SLOT(beep()));
#endif
switch (voiceIndex) switch (voiceIndex)
{ {
...@@ -97,27 +104,6 @@ emergency(false) ...@@ -97,27 +104,6 @@ emergency(false)
selectNeutralVoice(); selectNeutralVoice();
break; 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 GAudioOutput::say(QString text, int severity)
...@@ -126,7 +112,7 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -126,7 +112,7 @@ bool GAudioOutput::say(QString text, int severity)
if (!emergency) if (!emergency)
{ {
// Only give speech output on Linux and MacOS // Only give speech output on Linux and MacOS
#ifndef _WIN32 #ifdef Q_OS_LINUX
QTemporaryFile file; QTemporaryFile file;
file.setFileTemplate("XXXXXX.wav"); file.setFileTemplate("XXXXXX.wav");
if (file.open()) if (file.open())
...@@ -140,7 +126,20 @@ bool GAudioOutput::say(QString text, int severity) ...@@ -140,7 +126,20 @@ bool GAudioOutput::say(QString text, int severity)
qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str(); qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str();
res = true; res = true;
} }
#else #endif
#ifdef Q_OS_MAC
// Slashes necessary to have the right start to the sentence
// copying data prevents SpeakString from reading additional chars
text = "\\" + text;
QStdWString str = text.toStdWString();
unsigned char str2[1024] = {};
memcpy(str2, text.toAscii().data(), str.length());
SpeakString(str2);
qDebug() << "Synthesized: " << text.toAscii();
#endif
#ifdef Q_OS_WIN32
qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!"; qDebug() << "Synthesized: " << text << ", NO OUTPUT SUPPORT ON WINDOWS!";
#endif #endif
} }
...@@ -212,14 +211,14 @@ void GAudioOutput::beep() ...@@ -212,14 +211,14 @@ void GAudioOutput::beep()
void GAudioOutput::selectFemaleVoice() void GAudioOutput::selectFemaleVoice()
{ {
#ifndef _WIN32 #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()
{ {
#ifndef _WIN32 #ifdef Q_OS_LINUX
this->voice = register_cmu_us_rms(NULL); this->voice = register_cmu_us_rms(NULL);
#endif #endif
} }
...@@ -227,7 +226,7 @@ void GAudioOutput::selectMaleVoice() ...@@ -227,7 +226,7 @@ void GAudioOutput::selectMaleVoice()
void GAudioOutput::selectNeutralVoice() void GAudioOutput::selectNeutralVoice()
{ {
#ifndef _WIN32 #ifdef Q_OS_LINUX
this->voice = register_cmu_us_awb(NULL); this->voice = register_cmu_us_awb(NULL);
#endif #endif
} }
......
...@@ -38,6 +38,12 @@ This file is part of the PIXHAWK project ...@@ -38,6 +38,12 @@ This file is part of the PIXHAWK project
#include <flite.h> #include <flite.h>
#include <Phonon> #include <Phonon>
/* For Snow leopard and later
#ifdef Q_OS_MAC
#include <NSSpeechSynthesizer.h>
#endif
*/
/** /**
* @brief Audio Output (speech synthesizer and "beep" output) * @brief Audio Output (speech synthesizer and "beep" output)
* This class follows the singleton design pattern * This class follows the singleton design pattern
...@@ -71,6 +77,9 @@ public slots: ...@@ -71,6 +77,9 @@ public slots:
void beep(); void beep();
protected: protected:
#ifdef Q_OS_MAC
//NSSpeechSynthesizer
#endif
cst_voice* voice; ///< The flite voice object cst_voice* voice; ///< The flite voice object
int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms) int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms)
Phonon::MediaObject* m_media; ///< The output object for audio Phonon::MediaObject* m_media; ///< The output object for audio
......
...@@ -35,7 +35,7 @@ This file is part of the PIXHAWK project ...@@ -35,7 +35,7 @@ This file is part of the PIXHAWK project
#include <QThread> #include <QThread>
#include <QList> #include <QList>
#include <SDL.h> #include <SDL/SDL.h>
#include "UASInterface.h" #include "UASInterface.h"
......
...@@ -33,6 +33,11 @@ This file is part of the PIXHAWK project ...@@ -33,6 +33,11 @@ This file is part of the PIXHAWK project
#include "MainWindow.h" #include "MainWindow.h"
#include "configuration.h" #include "configuration.h"
/* SDL does ugly things to main() */
#ifdef main
# undef main
#endif
/** /**
* @brief Starts the application * @brief Starts the application
* *
......
...@@ -130,7 +130,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -130,7 +130,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
this->status = state.status; this->status = state.status;
getStatusForCode((int)state.status, uasState, stateDescription); getStatusForCode((int)state.status, uasState, stateDescription);
emit statusChanged(this, uasState, stateDescription); emit statusChanged(this, uasState, stateDescription);
stateAudio = "changed status to " + uasState; stateAudio = " changed status to " + uasState;
} }
if (static_cast<int>(this->mode) != static_cast<int>(state.mode)) if (static_cast<int>(this->mode) != static_cast<int>(state.mode))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment