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*
./build
build
Info.plist
obj
*.log
......@@ -16,3 +16,5 @@ qrc_*.cpp
tmp
debug
release
opengroundcontrol.xcodeproj/**
[submodule "MAVLink"]
path = MAVLink
url = git://github.com/pixhawk/mavlink.git
......@@ -25,7 +25,7 @@
#
#-------------------------------------------------
QT += network opengl svg xml
QT += network opengl svg xml phonon
TEMPLATE = app
TARGET = opengroundcontrol
......@@ -62,23 +62,23 @@ macx {
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
INCLUDEPATH += -framework SDL
LIBS += -framework IOKit \
-L/opt/local/lib \
-L$$BASEDIR/lib/flite/mac32 \
-lm \
-lflite_cmu_us_awb \
-lflite_cmu_us_rms \
-lflite_cmu_us_slt \
-lflite_usenglish \
-lflite_cmulex \
-lflite \
-L/lib/mac32/SDL \
-lSDL \
-lSDLmain
-framework SDL \
-framework CoreFoundation \
-framework ApplicationServices \
-lm
DEFINES += _TTY_POSIX_
#ICON = $$BASEDIR/img/icons/empty.png
......@@ -88,8 +88,6 @@ macx {
linux-g++ {
message(Building for GNU/Linux)
QT += phonon
debug {
DESTDIR = $$BASEDIR
......@@ -99,10 +97,6 @@ linux-g++ {
DESTDIR = $$BASEDIR
}
INCLUDEPATH += /usr/include/SDL
# /usr/include/qwt-qt4
#-L$$BASEDIR/lib/qwt/linux \
DEFINES += _TTY_POSIX_
......@@ -137,26 +131,18 @@ linux-g++ {
}
# Windows (32bit)
# Windows (32bit/64bit)
win32 {
message(Building for Windows Platform (32/64bit))
# Special settings for debug
#CONFIG += CONSOLE
#CONFIG += CONSOLE
LIBS += -L$$BASEDIR\lib\sdl\win32 \
-lmingw32 -lSDLmain -lSDL -mwindows
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_
debug {
......
......@@ -8,7 +8,8 @@ include(src/lib/qextserialport/qextserialport.pri)
include(src/lib/qwt/qwt.pri)
# Include FLITE audio synthesizer library
# include(src/lib/flite/flite.pri)
#include(src/lib/flite/flite.pri)
# Include QMapControl map library
include(lib/QMapControl/QMapControl.pri)
DEPENDPATH += . \
......@@ -17,8 +18,8 @@ DEPENDPATH += . \
INCLUDEPATH += . \
lib/QMapControl \
../mavlink/src \
mavlink/src \
src/mavlink
MAVLink/src \
mavlink/src
# Input
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:
private:
MainWindow* mainWindow;
//ViconTarsusProtocol* tarsus;
};
#endif /* _CORE_H_ */
......@@ -32,13 +32,19 @@ This file is part of the PIXHAWK project
#include <QApplication>
#include "GAudioOutput.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 <QTemporaryFile>
#include <QDebug>
#ifndef Q_OS_MAC
extern "C" {
#include <cmu_us_awb/voxdefs.h>
//#include <cmu_us_slt/voxdefs.h>
......@@ -51,6 +57,7 @@ extern "C" {
cst_voice *register_cmu_us_rms(const char *voxdir);
void unregister_cmu_us_rms(cst_voice *vox);
};
#endif
/**
* This class follows the singleton design pattern
......@@ -76,14 +83,14 @@ voice(NULL),
voiceIndex(0),
emergency(false)
{
#ifndef _WIN32
#if Q_OS_LINUX
flite_init();
#endif
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)
{
......@@ -97,27 +104,6 @@ emergency(false)
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)
......@@ -126,7 +112,7 @@ bool GAudioOutput::say(QString text, int severity)
if (!emergency)
{
// Only give speech output on Linux and MacOS
#ifndef _WIN32
#ifdef Q_OS_LINUX
QTemporaryFile file;
file.setFileTemplate("XXXXXX.wav");
if (file.open())
......@@ -140,7 +126,20 @@ bool GAudioOutput::say(QString text, int severity)
qDebug() << "Synthesized: " << text << ", tmp file:" << file.fileName().toStdString().c_str();
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!";
#endif
}
......@@ -212,14 +211,14 @@ void GAudioOutput::beep()
void GAudioOutput::selectFemaleVoice()
{
#ifndef _WIN32
#ifdef Q_OS_LINUX
this->voice = register_cmu_us_slt(NULL);
#endif
}
void GAudioOutput::selectMaleVoice()
{
#ifndef _WIN32
#ifdef Q_OS_LINUX
this->voice = register_cmu_us_rms(NULL);
#endif
}
......@@ -227,7 +226,7 @@ void GAudioOutput::selectMaleVoice()
void GAudioOutput::selectNeutralVoice()
{
#ifndef _WIN32
#ifdef Q_OS_LINUX
this->voice = register_cmu_us_awb(NULL);
#endif
}
......
......@@ -38,6 +38,12 @@ This file is part of the PIXHAWK project
#include <flite.h>
#include <Phonon>
/* For Snow leopard and later
#ifdef Q_OS_MAC
#include <NSSpeechSynthesizer.h>
#endif
*/
/**
* @brief Audio Output (speech synthesizer and "beep" output)
* This class follows the singleton design pattern
......@@ -71,6 +77,9 @@ public slots:
void beep();
protected:
#ifdef Q_OS_MAC
//NSSpeechSynthesizer
#endif
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
......
......@@ -35,7 +35,7 @@ This file is part of the PIXHAWK project
#include <QThread>
#include <QList>
#include <SDL.h>
#include <SDL/SDL.h>
#include "UASInterface.h"
......
......@@ -33,6 +33,11 @@ This file is part of the PIXHAWK project
#include "MainWindow.h"
#include "configuration.h"
/* SDL does ugly things to main() */
#ifdef main
# undef main
#endif
/**
* @brief Starts the application
*
......
......@@ -130,7 +130,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
this->status = state.status;
getStatusForCode((int)state.status, 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))
......
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