From f6bf1d414188415e8e65841cfc6947543e57958a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 3 Apr 2015 17:41:19 -0700 Subject: [PATCH 01/23] Disable DDE code if not Windows or OSX --- interface/src/Application.cpp | 4 +++- interface/src/Menu.cpp | 4 ++-- interface/src/devices/DdeFaceTracker.h | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f0324b7361..b49b8188c5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1730,8 +1730,10 @@ FaceTracker* Application::getActiveFaceTracker() { void Application::setActiveFaceTracker() { #ifdef HAVE_FACESHIFT DependencyManager::get()->setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift)); -#endif +#endif +#ifdef HAVE_DDE DependencyManager::get()->setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::DDEFaceRegression)); +#endif #ifdef HAVE_VISAGE DependencyManager::get()->updateEnabled(); #endif diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f95ffddbfb..2313cb569e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -370,12 +370,12 @@ Menu::Menu() { qApp, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(faceshiftFaceTracker); #endif - +#ifdef HAVE_DDE QAction* ddeFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::DDEFaceRegression, 0, false, qApp, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(ddeFaceTracker); - +#endif #ifdef HAVE_VISAGE QAction* visageFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::Visage, 0, false, diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index 3c95666a6c..1a998d4b7f 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -12,6 +12,10 @@ #ifndef hifi_DdeFaceTracker_h #define hifi_DdeFaceTracker_h +#if defined(Q_OS_WIN) || defined(Q_OS_OSX) + #define HAVE_DDE +#endif + #include #include From 0d42c7a1c1addd1978a26044c360193366b99809 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 3 Apr 2015 19:16:07 -0700 Subject: [PATCH 02/23] Start and stop DDE as separate process --- interface/src/devices/DdeFaceTracker.cpp | 23 +++++++++++++++++++++++ interface/src/devices/DdeFaceTracker.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 9d753d228d..9449084c5d 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -19,6 +20,13 @@ #include "DdeFaceTracker.h" #include "FaceshiftConstants.h" +#if defined(Q_OS_WIN) +static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde.exe"; +static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:5555 --headless"; +#elif defined(Q_OS_MAC) +static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde"; +static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:5555 --headless"; +#endif static const QHostAddress DDE_FEATURE_POINT_SERVER_ADDR("127.0.0.1"); static const quint16 DDE_FEATURE_POINT_SERVER_PORT = 5555; @@ -125,6 +133,7 @@ DdeFaceTracker::DdeFaceTracker() : } DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 port) : + _ddeProcess(NULL), _host(host), _port(port), _lastReceiveTimestamp(0), @@ -161,11 +170,25 @@ DdeFaceTracker::~DdeFaceTracker() { } void DdeFaceTracker::setEnabled(bool enabled) { +#ifdef HAVE_DDE + if (enabled && !_ddeProcess) { + qDebug() << "[Info] DDE Face Tracker Starting"; + _ddeProcess = new QProcess(qApp); + _ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS.split(" ")); + } + // isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket. _udpSocket.close(); if (enabled) { _udpSocket.bind(_host, _port); } + + if (!enabled && _ddeProcess) { + _ddeProcess->kill(); + _ddeProcess = NULL; + qDebug() << "[Info] DDE Face Tracker Stopped"; + } +#endif } bool DdeFaceTracker::isActive() const { diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index 1a998d4b7f..d7008a57b9 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -16,6 +16,7 @@ #define HAVE_DDE #endif +#include #include #include @@ -62,6 +63,8 @@ private: DdeFaceTracker(const QHostAddress& host, quint16 port); ~DdeFaceTracker(); + QProcess* _ddeProcess; + QHostAddress _host; quint16 _port; From 00f5469fa82e50995d12db7a6504f25605a755aa Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 4 Apr 2015 17:31:32 -0700 Subject: [PATCH 03/23] Add menu item that resets DDE tracking --- interface/src/Application.h | 4 ++-- interface/src/Menu.cpp | 23 +++++++++++++++++++---- interface/src/Menu.h | 2 ++ interface/src/devices/DdeFaceTracker.cpp | 24 ++++++++++++++++-------- interface/src/devices/DdeFaceTracker.h | 6 ++++-- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index e9b8deff55..b6d2a5cc10 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -210,6 +210,8 @@ public: bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; } FaceTracker* getActiveFaceTracker(); + void setActiveFaceTracker(); + QSystemTrayIcon* getTrayIcon() { return _trayIcon; } ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; } Overlays& getOverlays() { return _overlays; } @@ -388,8 +390,6 @@ public slots: void notifyPacketVersionMismatch(); - void setActiveFaceTracker(); - void domainConnectionDenied(const QString& reason); private slots: diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 2313cb569e..ac27030ee3 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -361,28 +361,36 @@ Menu::Menu() { QAction* noFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::NoFaceTracking, 0, true, - qApp, SLOT(setActiveFaceTracker())); + this, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(noFaceTracker); #ifdef HAVE_FACESHIFT QAction* faceshiftFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::Faceshift, 0, false, - qApp, SLOT(setActiveFaceTracker())); + this, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(faceshiftFaceTracker); #endif #ifdef HAVE_DDE QAction* ddeFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::DDEFaceRegression, 0, false, - qApp, SLOT(setActiveFaceTracker())); + this, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(ddeFaceTracker); #endif #ifdef HAVE_VISAGE QAction* visageFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::Visage, 0, false, - qApp, SLOT(setActiveFaceTracker())); + this, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(visageFaceTracker); #endif } +#ifdef HAVE_DDE + faceTrackingMenu->addSeparator(); + QAction* ddeFaceTrackerReset = addActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::ResetDDETracking, + Qt::CTRL | Qt::Key_Apostrophe, + DependencyManager::get().data(), SLOT(resetTracking())); + ddeFaceTrackerReset->setVisible(false); + faceTrackingMenu->addAction(ddeFaceTrackerReset); +#endif addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSkeletonCollisionShapes); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderHeadCollisionShapes); @@ -1002,3 +1010,10 @@ void Menu::visibilityChanged(Discoverability::Mode discoverabilityMode) { qDebug() << "ERROR Menu::visibilityChanged() called with unrecognized value."; } } + +void Menu::setActiveFaceTracker() { + bool isUsingDDE = Menu::getInstance()->isOptionChecked(MenuOption::DDEFaceRegression); + Menu::getInstance()->getActionForOption(MenuOption::ResetDDETracking)->setVisible(isUsingDDE); + + qApp->setActiveFaceTracker(); +} diff --git a/interface/src/Menu.h b/interface/src/Menu.h index db126a3c9b..00f876a539 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -68,6 +68,7 @@ public slots: private slots: void setVisibility(); + void setActiveFaceTracker(); private: static Menu* _instance; @@ -230,6 +231,7 @@ namespace MenuOption { const QString RenderAmbientLight8 = "CAMPUS_SUNSET"; const QString RenderAmbientLight9 = "FUNSTON_BEACH_SUNSET"; const QString ResetAvatarSize = "Reset Avatar Size"; + const QString ResetDDETracking = "Reset DDE Tracking"; const QString ResetSensors = "Reset Sensors"; const QString RunningScripts = "Running Scripts"; const QString RunTimingTests = "Run Timing Tests"; diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 9449084c5d..000ddf6069 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -22,13 +22,14 @@ #if defined(Q_OS_WIN) static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde.exe"; -static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:5555 --headless"; +static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:64204 --receiver=64205 --headless"; #elif defined(Q_OS_MAC) static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde"; -static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:5555 --headless"; +static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:64204 --receiver=64205 --headless"; #endif -static const QHostAddress DDE_FEATURE_POINT_SERVER_ADDR("127.0.0.1"); -static const quint16 DDE_FEATURE_POINT_SERVER_PORT = 5555; +static const QHostAddress DDE_SERVER_ADDR("127.0.0.1"); +static const quint16 DDE_SERVER_PORT = 64204; +static const quint16 DDE_CONTROL_PORT = 64205; static const int NUM_EXPRESSIONS = 46; static const int MIN_PACKET_SIZE = (8 + NUM_EXPRESSIONS) * sizeof(float) + sizeof(int); @@ -127,15 +128,16 @@ struct Packet { }; DdeFaceTracker::DdeFaceTracker() : - DdeFaceTracker(QHostAddress::Any, DDE_FEATURE_POINT_SERVER_PORT) + DdeFaceTracker(QHostAddress::Any, DDE_SERVER_PORT, DDE_CONTROL_PORT) { } -DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 port) : +DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, quint16 controlPort) : _ddeProcess(NULL), _host(host), - _port(port), + _serverPort(serverPort), + _controlPort(controlPort), _lastReceiveTimestamp(0), _reset(false), _leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes @@ -180,7 +182,7 @@ void DdeFaceTracker::setEnabled(bool enabled) { // isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket. _udpSocket.close(); if (enabled) { - _udpSocket.bind(_host, _port); + _udpSocket.bind(_host, _serverPort); } if (!enabled && _ddeProcess) { @@ -191,6 +193,12 @@ void DdeFaceTracker::setEnabled(bool enabled) { #endif } +void DdeFaceTracker::resetTracking() { + qDebug() << "[Info] Reset DDE Tracking"; + const char* DDE_RESET_COMMAND = "reset"; + _udpSocket.writeDatagram(DDE_RESET_COMMAND, DDE_SERVER_ADDR, _controlPort); +} + bool DdeFaceTracker::isActive() const { static const quint64 ACTIVE_TIMEOUT_USECS = 3000000; //3 secs return (usecTimestampNow() - _lastReceiveTimestamp < ACTIVE_TIMEOUT_USECS); diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index d7008a57b9..a53fbdb379 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -50,6 +50,7 @@ public: public slots: void setEnabled(bool enabled); + void resetTracking(); private slots: @@ -60,13 +61,14 @@ private slots: private: DdeFaceTracker(); - DdeFaceTracker(const QHostAddress& host, quint16 port); + DdeFaceTracker(const QHostAddress& host, quint16 serverPort, quint16 controlPort); ~DdeFaceTracker(); QProcess* _ddeProcess; QHostAddress _host; - quint16 _port; + quint16 _serverPort; + quint16 _controlPort; float getBlendshapeCoefficient(int index) const; void decodePacket(const QByteArray& buffer); From 1eb5716ab77079736a326803e3d83919388991b1 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 4 Apr 2015 19:04:47 -0700 Subject: [PATCH 04/23] Shut down DDE when Interface shuts down --- interface/src/Application.cpp | 2 ++ interface/src/devices/DdeFaceTracker.cpp | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b49b8188c5..a26364cb06 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -610,6 +610,8 @@ void Application::cleanupBeforeQuit() { // destroy the AudioClient so it and its thread have a chance to go down safely DependencyManager::destroy(); + + DependencyManager::destroy(); } Application::~Application() { diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 000ddf6069..cadf48d98b 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -166,9 +166,7 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui } DdeFaceTracker::~DdeFaceTracker() { - if (_udpSocket.isOpen()) { - _udpSocket.close(); - } + setEnabled(false); } void DdeFaceTracker::setEnabled(bool enabled) { From 65c1fea689bf21e2438fb3156ec43b990f29fe8d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 4 Apr 2015 19:08:23 -0700 Subject: [PATCH 05/23] Increase DDE head translation to make avatar better reflect RL --- interface/src/devices/DdeFaceTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index cadf48d98b..d654a493ed 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -266,7 +266,7 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) { } // Compute relative translation - float LEAN_DAMPING_FACTOR = 200.0f; + float LEAN_DAMPING_FACTOR = 75.0f; translation -= _referenceTranslation; translation /= LEAN_DAMPING_FACTOR; translation.x *= -1; From 765d66eee55597c4af1fc9cc8811fc5fe9bc661c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 4 Apr 2015 19:20:44 -0700 Subject: [PATCH 06/23] Fix running without DDE available --- interface/src/Application.cpp | 2 ++ interface/src/Menu.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a26364cb06..b1f7d65441 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -611,7 +611,9 @@ void Application::cleanupBeforeQuit() { // destroy the AudioClient so it and its thread have a chance to go down safely DependencyManager::destroy(); +#ifdef HAVE_DDE DependencyManager::destroy(); +#endif } Application::~Application() { diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index ac27030ee3..6e8763426d 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1012,8 +1012,9 @@ void Menu::visibilityChanged(Discoverability::Mode discoverabilityMode) { } void Menu::setActiveFaceTracker() { +#ifdef HAVE_DDE bool isUsingDDE = Menu::getInstance()->isOptionChecked(MenuOption::DDEFaceRegression); Menu::getInstance()->getActionForOption(MenuOption::ResetDDETracking)->setVisible(isUsingDDE); - +#endif qApp->setActiveFaceTracker(); } From f496175fb94b3307d31948d964bedcfd4c437a61 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 9 Apr 2015 09:17:23 -0700 Subject: [PATCH 07/23] Attempt to stop the crashing on exit caused by the Oculus SDK --- interface/src/devices/OculusManager.cpp | 13 +++++++++++-- interface/src/devices/OculusManager.h | 1 + interface/src/main.cpp | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 3f527c6137..437229a483 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -114,8 +114,11 @@ void OculusManager::initSdk() { } void OculusManager::shutdownSdk() { - ovrHmd_Destroy(_ovrHmd); - ovr_Shutdown(); + if (_ovrHmd) { + ovrHmd_Destroy(_ovrHmd); + _ovrHmd = nullptr; + ovr_Shutdown(); + } } void OculusManager::init() { @@ -124,6 +127,12 @@ void OculusManager::init() { #endif } +void OculusManager::deinit() { +#ifdef OVR_DIRECT_MODE + shutdownSdk(); +#endif +} + void OculusManager::connect() { #ifndef OVR_DIRECT_MODE initSdk(); diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index fe2da31231..4b1bc98fb2 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -51,6 +51,7 @@ class Text3DOverlay; class OculusManager { public: static void init(); + static void deinit(); static void connect(); static void disconnect(); static bool isConnected(); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index b4486ceb2b..7d80b077b8 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -112,6 +112,7 @@ int main(int argc, const char* argv[]) { exitCode = app.exec(); } + OculusManager::deinit(); #ifdef Q_OS_WIN ReleaseMutex(mutex); #endif From 86f89a1d6f52427966966ec8d64b96d53543b562 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 13 Apr 2015 13:23:15 -0700 Subject: [PATCH 08/23] fix bug where fly speed is limited to walk speed --- libraries/physics/src/DynamicCharacterController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/physics/src/DynamicCharacterController.cpp b/libraries/physics/src/DynamicCharacterController.cpp index db84bea540..aaabe21e9b 100644 --- a/libraries/physics/src/DynamicCharacterController.cpp +++ b/libraries/physics/src/DynamicCharacterController.cpp @@ -245,7 +245,6 @@ void DynamicCharacterController::setEnabled(bool enabled) { // Don't bother clearing REMOVE bit since it might be paired with an UPDATE_SHAPE bit. // Setting the ADD bit here works for all cases so we don't even bother checking other bits. _pendingFlags |= PENDING_FLAG_ADD_TO_SIMULATION; - setHovering(true); } else { if (_dynamicsWorld) { _pendingFlags |= PENDING_FLAG_REMOVE_FROM_SIMULATION; @@ -253,6 +252,7 @@ void DynamicCharacterController::setEnabled(bool enabled) { _pendingFlags &= ~ PENDING_FLAG_ADD_TO_SIMULATION; _isOnGround = false; } + setHovering(true); _enabled = enabled; } } From 2c4f049851efed0c15b390b2c5d0379deb66d5c4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 13 Apr 2015 17:11:27 -0700 Subject: [PATCH 09/23] Change OSX DDE program path per build system requirements --- interface/src/devices/DdeFaceTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index d654a493ed..7228358532 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -24,7 +24,7 @@ static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde.exe"; static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:64204 --receiver=64205 --headless"; #elif defined(Q_OS_MAC) -static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde"; +static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde.app/Contents/MacOS/dde"; static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:64204 --receiver=64205 --headless"; #endif static const QHostAddress DDE_SERVER_ADDR("127.0.0.1"); From 13c038879dbcbec386e697191eaf577db2703275 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 13 Apr 2015 17:13:03 -0700 Subject: [PATCH 10/23] Don't repeat constant values --- interface/src/devices/DdeFaceTracker.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 7228358532..78c665b7a0 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -20,16 +20,18 @@ #include "DdeFaceTracker.h" #include "FaceshiftConstants.h" -#if defined(Q_OS_WIN) -static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde.exe"; -static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:64204 --receiver=64205 --headless"; -#elif defined(Q_OS_MAC) -static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde.app/Contents/MacOS/dde"; -static const QString DDE_ARGUMENTS = "--udp=127.0.0.1:64204 --receiver=64205 --headless"; -#endif static const QHostAddress DDE_SERVER_ADDR("127.0.0.1"); static const quint16 DDE_SERVER_PORT = 64204; static const quint16 DDE_CONTROL_PORT = 64205; +#if defined(Q_OS_WIN) +static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde/dde.exe"; +#elif defined(Q_OS_MAC) +static const QString DDE_PROGRAM_PATH = QCoreApplication::applicationDirPath() + "/dde.app/Contents/MacOS/dde"; +#endif +static const QStringList DDE_ARGUMENTS = QStringList() + << "--udp=" + DDE_SERVER_ADDR.toString() + ":" + QString::number(DDE_SERVER_PORT) + << "--receiver=" + QString::number(DDE_CONTROL_PORT) + << "--headless"; static const int NUM_EXPRESSIONS = 46; static const int MIN_PACKET_SIZE = (8 + NUM_EXPRESSIONS) * sizeof(float) + sizeof(int); @@ -174,7 +176,7 @@ void DdeFaceTracker::setEnabled(bool enabled) { if (enabled && !_ddeProcess) { qDebug() << "[Info] DDE Face Tracker Starting"; _ddeProcess = new QProcess(qApp); - _ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS.split(" ")); + _ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS); } // isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket. From b7f7cebb808cbbe5e051bee86dcc39ba1fe6f157 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 13 Apr 2015 22:41:17 -0700 Subject: [PATCH 11/23] Handle DDE stopping unexpectedly --- interface/src/devices/DdeFaceTracker.cpp | 12 ++++++++++++ interface/src/devices/DdeFaceTracker.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 55a9b7979b..4ab2d70509 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -20,6 +20,7 @@ #include "DdeFaceTracker.h" #include "FaceshiftConstants.h" #include "InterfaceLogging.h" +#include "Menu.h" static const QHostAddress DDE_SERVER_ADDR("127.0.0.1"); @@ -178,6 +179,7 @@ void DdeFaceTracker::setEnabled(bool enabled) { if (enabled && !_ddeProcess) { qDebug() << "[Info] DDE Face Tracker Starting"; _ddeProcess = new QProcess(qApp); + connect(_ddeProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus))); _ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS); } @@ -195,6 +197,16 @@ void DdeFaceTracker::setEnabled(bool enabled) { #endif } +void DdeFaceTracker::processFinished(int exitCode, QProcess::ExitStatus exitStatus) { + if (_ddeProcess) { + // DDE crashed or was manually terminated + qDebug() << "[Info] DDE Face Tracker Stopped Unexpectedly"; + _udpSocket.close(); + _ddeProcess = NULL; + Menu::getInstance()->setIsOptionChecked(MenuOption::NoFaceTracking, true); + } +} + void DdeFaceTracker::resetTracking() { qDebug() << "[Info] Reset DDE Tracking"; const char* DDE_RESET_COMMAND = "reset"; diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index a53fbdb379..490020e511 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -53,7 +53,8 @@ public slots: void resetTracking(); private slots: - + void processFinished(int exitCode, QProcess::ExitStatus exitStatus); + //sockets void socketErrorOccurred(QAbstractSocket::SocketError socketError); void readPendingDatagrams(); From f509d08378c62523b50e1132b3996b9463f3dd8b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 13 Apr 2015 23:12:13 -0700 Subject: [PATCH 12/23] Handle DDE already running --- interface/src/devices/DdeFaceTracker.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 4ab2d70509..a701160198 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -176,21 +176,25 @@ DdeFaceTracker::~DdeFaceTracker() { void DdeFaceTracker::setEnabled(bool enabled) { #ifdef HAVE_DDE - if (enabled && !_ddeProcess) { - qDebug() << "[Info] DDE Face Tracker Starting"; - _ddeProcess = new QProcess(qApp); - connect(_ddeProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus))); - _ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS); - } - // isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket. _udpSocket.close(); if (enabled) { _udpSocket.bind(_host, _serverPort); } + if (enabled && !_ddeProcess) { + // Terminate any existing DDE process, perhaps left running after an Interface crash + const char* DDE_EXIT_COMMAND = "exit"; + _udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort); + + qDebug() << "[Info] DDE Face Tracker Starting"; + _ddeProcess = new QProcess(qApp); + connect(_ddeProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus))); + _ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS); + } + if (!enabled && _ddeProcess) { - _ddeProcess->kill(); + _ddeProcess->kill(); // More robust than trying to send an "exit" command to DDE _ddeProcess = NULL; qDebug() << "[Info] DDE Face Tracker Stopped"; } From b6942e2300ef061aadde288c9b36a6450ccd504c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 14 Apr 2015 10:11:52 -0700 Subject: [PATCH 13/23] Fix stuck-spinners in entity properties --- examples/html/entityProperties.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 4ac1b70e33..dd5bced393 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -508,18 +508,22 @@ // To make this work we block the first mouseup event after the elements // received focus. If we block all mouseup events the user will not // be able to click within the selected text. + // We also check to see if the value has changed to make sure we aren't + // blocking a mouse-up event when clicking on an input spinner. var els = document.querySelectorAll("input, textarea"); for (var i = 0; i < els.length; i++) { var clicked = false; + var originalText; els[i].onfocus = function() { + originalText = this.value; this.select(); clicked = false; }; els[i].onmouseup = function(e) { - if (!clicked) { + if (!clicked && originalText == this.value) { e.preventDefault(); - clicked = true; } + clicked = true; }; } } From 4d34ba7bdf646dff089b2d8ebe50949828dd8b67 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 14 Apr 2015 10:57:47 -0700 Subject: [PATCH 14/23] Update main window to quit app when closed --- interface/src/MainWindow.cpp | 4 ++++ interface/src/MainWindow.h | 1 + 2 files changed, 5 insertions(+) diff --git a/interface/src/MainWindow.cpp b/interface/src/MainWindow.cpp index 41b1249af1..f60716dc48 100644 --- a/interface/src/MainWindow.cpp +++ b/interface/src/MainWindow.cpp @@ -55,6 +55,10 @@ void MainWindow::saveGeometry() { } } +void MainWindow::closeEvent(QCloseEvent* event) { + qApp->quit(); +} + void MainWindow::moveEvent(QMoveEvent* event) { emit windowGeometryChanged(QRect(event->pos(), size())); QMainWindow::moveEvent(event); diff --git a/interface/src/MainWindow.h b/interface/src/MainWindow.h index 4437fa6a1f..c6faf8e01a 100644 --- a/interface/src/MainWindow.h +++ b/interface/src/MainWindow.h @@ -30,6 +30,7 @@ signals: void windowShown(bool shown); protected: + virtual void closeEvent(QCloseEvent* event); virtual void moveEvent(QMoveEvent* event); virtual void resizeEvent(QResizeEvent* event); virtual void showEvent(QShowEvent* event); From bd3b25383ae3c1996589be8c59e7a78a38d7b9a7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 14:20:50 +0200 Subject: [PATCH 15/23] Some code cleanup --- libraries/audio-client/src/AudioClient.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index a02dc912f7..f37172ea4e 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -726,9 +726,9 @@ void AudioClient::handleAudioInput() { int inputSamplesRequired = (int)((float)AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * inputToNetworkInputRatio); QByteArray inputByteArray = _inputDevice->readAll(); - + + // Add audio source injection if enabled if (!_muted && _audioSourceInjectEnabled) { - int16_t* inputFrameData = (int16_t*)inputByteArray.data(); const uint32_t inputFrameCount = inputByteArray.size() / sizeof(int16_t); @@ -737,17 +737,12 @@ void AudioClient::handleAudioInput() { #if ENABLE_INPUT_GAIN _inputGain.render(_inputFrameBuffer); // input/mic gain+mute #endif - // Add audio source injection if enabled - if (_audioSourceInjectEnabled) { - - if (_toneSourceEnabled) { // sine generator - _toneSource.render(_inputFrameBuffer); - } - else if(_noiseSourceEnabled) { // pink noise generator - _noiseSource.render(_inputFrameBuffer); - } - _sourceGain.render(_inputFrameBuffer); // post gain + if (_toneSourceEnabled) { // sine generator + _toneSource.render(_inputFrameBuffer); + } else if(_noiseSourceEnabled) { // pink noise generator + _noiseSource.render(_inputFrameBuffer); } + _sourceGain.render(_inputFrameBuffer); // post gain _inputFrameBuffer.copyFrames(1, inputFrameCount, inputFrameData, true /*copy out*/); } From 8f8e4d8dc66bd8e0a392d6344bdd847c71c251be Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 15:49:11 +0200 Subject: [PATCH 16/23] Add generated audio methods to audio interface --- libraries/audio-client/src/AudioClient.cpp | 4 ++-- libraries/audio-client/src/AudioClient.h | 8 ++++---- libraries/audio/src/AbstractAudioInterface.h | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index f37172ea4e..032c70985e 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -967,8 +967,8 @@ void AudioClient::setIsStereoInput(bool isStereoInput) { } } -void AudioClient::toggleAudioSourceInject() { - _audioSourceInjectEnabled = !_audioSourceInjectEnabled; +void AudioClient::enableAudioSourceInject(bool enable) { + _audioSourceInjectEnabled = enable; } void AudioClient::selectAudioSourcePinkNoise() { diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index 7ac445a7fc..bb145a209f 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -1,6 +1,6 @@ // // AudioClient.h -// interface/src +// libraries/audio-client/src // // Created by Stephen Birarda on 1/22/13. // Copyright 2013 High Fidelity, Inc. @@ -143,9 +143,9 @@ public slots: void audioMixerKilled(); void toggleMute(); - void toggleAudioSourceInject(); - void selectAudioSourcePinkNoise(); - void selectAudioSourceSine440(); + virtual void enableAudioSourceInject(bool enable); + virtual void selectAudioSourcePinkNoise(); + virtual void selectAudioSourceSine440(); void toggleAudioNoiseReduction() { _isNoiseGateEnabled = !_isNoiseGateEnabled; } diff --git a/libraries/audio/src/AbstractAudioInterface.h b/libraries/audio/src/AbstractAudioInterface.h index 656d3c1f58..9649d11ad2 100644 --- a/libraries/audio/src/AbstractAudioInterface.h +++ b/libraries/audio/src/AbstractAudioInterface.h @@ -27,6 +27,10 @@ public: public slots: virtual bool outputLocalInjector(bool isStereo, qreal volume, AudioInjector* injector) = 0; + + virtual void enableAudioSourceInject(bool enable) = 0; + virtual void selectAudioSourcePinkNoise() = 0; + virtual void selectAudioSourceSine440() = 0; }; Q_DECLARE_METATYPE(AbstractAudioInterface*) From b1cfd3343877fa92869ac196edf9683f12d1b18e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 15:49:47 +0200 Subject: [PATCH 17/23] Add generated audio controls to scripting interface --- .../src/AudioScriptingInterface.cpp | 23 ++++++++++++++++++- .../src/AudioScriptingInterface.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/src/AudioScriptingInterface.cpp b/libraries/script-engine/src/AudioScriptingInterface.cpp index deb1e1e9e9..8bcc4a20cf 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.cpp +++ b/libraries/script-engine/src/AudioScriptingInterface.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioScriptingInterface.h" + #include "ScriptAudioInjector.h" #include "ScriptEngineLogging.h" -#include "AudioScriptingInterface.h" void registerAudioMetaTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, injectorOptionsToScriptValue, injectorOptionsFromScriptValue); @@ -69,3 +70,23 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(Sound* sound, const Audi return NULL; } } + +void AudioScriptingInterface::injectGeneratedNoise(bool inject) { + if (_localAudioInterface) { + _localAudioInterface->enableAudioSourceInject(inject); + } +} + +void AudioScriptingInterface::selectPinkNoise() { + if (_localAudioInterface) { + _localAudioInterface->selectAudioSourcePinkNoise(); + } +} + +void AudioScriptingInterface::selectSine440() { + if (_localAudioInterface) { + _localAudioInterface->selectAudioSourceSine440(); + } +} + + diff --git a/libraries/script-engine/src/AudioScriptingInterface.h b/libraries/script-engine/src/AudioScriptingInterface.h index b74c520670..9d02b8c9a1 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.h +++ b/libraries/script-engine/src/AudioScriptingInterface.h @@ -29,6 +29,10 @@ protected: // this method is protected to stop C++ callers from calling, but invokable from script Q_INVOKABLE ScriptAudioInjector* playSound(Sound* sound, const AudioInjectorOptions& injectorOptions = AudioInjectorOptions()); + Q_INVOKABLE void injectGeneratedNoise(bool inject); + Q_INVOKABLE void selectPinkNoise(); + Q_INVOKABLE void selectSine440(); + signals: void mutedByMixer(); void environmentMuted(); From c2c1ccc2b75d62c665889274f021db94c74228c9 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 15:50:22 +0200 Subject: [PATCH 18/23] Remove generated audio options from menu --- interface/src/Menu.cpp | 24 ------------------------ interface/src/Menu.h | 3 --- 2 files changed, 27 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 1cce0b1f56..796c8e6dd6 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -483,30 +483,6 @@ Menu::Menu() { 0, audioIO.data(), SLOT(sendMuteEnvironmentPacket())); - - addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioSourceInject, - 0, - false, - audioIO.data(), - SLOT(toggleAudioSourceInject())); - QMenu* audioSourceMenu = audioDebugMenu->addMenu("Generated Audio Source"); - { - QAction *pinkNoise = addCheckableActionToQMenuAndActionHash(audioSourceMenu, MenuOption::AudioSourcePinkNoise, - 0, - false, - audioIO.data(), - SLOT(selectAudioSourcePinkNoise())); - - QAction *sine440 = addCheckableActionToQMenuAndActionHash(audioSourceMenu, MenuOption::AudioSourceSine440, - 0, - true, - audioIO.data(), - SLOT(selectAudioSourceSine440())); - - QActionGroup* audioSourceGroup = new QActionGroup(audioSourceMenu); - audioSourceGroup->addAction(pinkNoise); - audioSourceGroup->addAction(sine440); - } auto scope = DependencyManager::get(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index db126a3c9b..4589c94b08 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -123,9 +123,6 @@ namespace MenuOption { const QString AudioScopeTwentyFrames = "Twenty"; const QString AudioStats = "Audio Stats"; const QString AudioStatsShowInjectedStreams = "Audio Stats Show Injected Streams"; - const QString AudioSourceInject = "Generated Audio"; - const QString AudioSourcePinkNoise = "Pink Noise"; - const QString AudioSourceSine440 = "Sine 440hz"; const QString BandwidthDetails = "Bandwidth Details"; const QString BlueSpeechSphere = "Blue Sphere While Speaking"; const QString BookmarkLocation = "Bookmark Location"; From 9ea72f2a03052c0f37102a3d99d5a917fcf280bb Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 16:16:13 +0200 Subject: [PATCH 19/23] Added generated audio to developer menu script --- .../utilities/tools/developerMenuItems.js | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/examples/utilities/tools/developerMenuItems.js b/examples/utilities/tools/developerMenuItems.js index a691031131..4243838601 100644 --- a/examples/utilities/tools/developerMenuItems.js +++ b/examples/utilities/tools/developerMenuItems.js @@ -13,16 +13,25 @@ var createdRenderMenu = false; -var ENTITIES_MENU = "Developer > Entities"; +var DEVELOPER_MENU = "Developer"; + +var ENTITIES_MENU = DEVELOPER_MENU + " > Entities"; var COLLISION_UPDATES_TO_SERVER = "Don't send collision updates to server"; -var RENDER_MENU = "Developer > Render"; +var RENDER_MENU = DEVELOPER_MENU + " > Render"; var ENTITIES_ITEM = "Entities"; var AVATARS_ITEM = "Avatars"; +var AUDIO_MENU = DEVELOPER_MENU + " > Audio"; +var AUDIO_SOURCE_INJECT = "Generated Audio"; +var AUDIO_SOURCE_MENU = AUDIO_MENU + " > Generated Audio Source"; +var AUDIO_SOURCE_PINK_NOISE = "Pink Noise"; +var AUDIO_SOURCE_SINE_440 = "Sine 440hz"; + + function setupMenus() { - if (!Menu.menuExists("Developer")) { - Menu.addMenu("Developer"); + if (!Menu.menuExists(DEVELOPER_MENU)) { + Menu.addMenu(DEVELOPER_MENU); } if (!Menu.menuExists(ENTITIES_MENU)) { Menu.addMenu(ENTITIES_MENU); @@ -54,6 +63,17 @@ function setupMenus() { if (!Menu.menuItemExists(RENDER_MENU, AVATARS_ITEM)) { Menu.addMenuItem({ menuName: RENDER_MENU, menuItemName: AVATARS_ITEM, isCheckable: true, isChecked: Scene.shouldRenderAvatars }) } + + + if (!Menu.menuExists(AUDIO_MENU)) { + Menu.addMenu(AUDIO_MENU); + } + Menu.addMenuItem({ menuName: AUDIO_MENU, menuItemName: AUDIO_SOURCE_INJECT, isCheckable: true, isChecked: false }); + Menu.addMenu(AUDIO_SOURCE_MENU); + Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_PINK_NOISE, isCheckable: true, isChecked: false }); + Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_SINE_440, isCheckable: true, isChecked: false }); + Menu.setIsOptionChecked(AUDIO_SOURCE_PINK_NOISE, true); + } Menu.menuItemEvent.connect(function (menuItem) { @@ -67,7 +87,15 @@ Menu.menuItemEvent.connect(function (menuItem) { Scene.shouldRenderEntities = Menu.isOptionChecked(ENTITIES_ITEM); } else if (menuItem == AVATARS_ITEM) { Scene.shouldRenderAvatars = Menu.isOptionChecked(AVATARS_ITEM); - } + } else if (menuItem == AUDIO_SOURCE_INJECT) { + Audio.injectGeneratedNoise(Menu.isOptionChecked(AUDIO_SOURCE_INJECT)); + } else if (menuItem == AUDIO_SOURCE_PINK_NOISE) { + Audio.selectPinkNoise(); + Menu.setIsOptionChecked(AUDIO_SOURCE_SINE_440, false); + } else if (menuItem == AUDIO_SOURCE_SINE_440) { + Audio.selectSine440(); + Menu.setIsOptionChecked(AUDIO_SOURCE_PINK_NOISE, false); + } }); Scene.shouldRenderAvatarsChanged.connect(function(shouldRenderAvatars) { @@ -87,6 +115,10 @@ function scriptEnding() { Menu.removeMenuItem(RENDER_MENU, ENTITIES_ITEM); Menu.removeMenuItem(RENDER_MENU, AVATARS_ITEM); } + + Audio.injectGeneratedNoise(false); + Menu.removeMenuItem(AUDIO_MENU, AUDIO_SOURCE_INJECT); + Menu.removeMenu(AUDIO_SOURCE_MENU); } setupMenus(); From 5f9d7a00fa01c426598a809b9349c1f7970b0087 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 16:22:18 +0200 Subject: [PATCH 20/23] Correct default to pink noise --- examples/utilities/tools/developerMenuItems.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/utilities/tools/developerMenuItems.js b/examples/utilities/tools/developerMenuItems.js index 4243838601..84e1853d64 100644 --- a/examples/utilities/tools/developerMenuItems.js +++ b/examples/utilities/tools/developerMenuItems.js @@ -73,6 +73,7 @@ function setupMenus() { Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_PINK_NOISE, isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_SINE_440, isCheckable: true, isChecked: false }); Menu.setIsOptionChecked(AUDIO_SOURCE_PINK_NOISE, true); + Audio.selectPinkNoise(); } From 62d3b39c2569a818a183a51fad92dfaa173970c7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 16:22:52 +0200 Subject: [PATCH 21/23] less loud generated noise Prevents the audio mixer from muting you because of too much noise --- libraries/audio-client/src/AudioClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 032c70985e..331e62ec70 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -493,7 +493,7 @@ void AudioClient::start() { _sourceGain.initialize(); _noiseSource.initialize(); _toneSource.initialize(); - _sourceGain.setParameters(0.25f, 0.0f); + _sourceGain.setParameters(0.05f, 0.0f); _inputGain.setParameters(1.0f, 0.0f); } From d2775fe9b337b1be396a1f90c03709fc21c6c1cd Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 16:52:41 +0200 Subject: [PATCH 22/23] Fix for people running older version of interface --- .../utilities/tools/developerMenuItems.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/examples/utilities/tools/developerMenuItems.js b/examples/utilities/tools/developerMenuItems.js index 84e1853d64..58b5149307 100644 --- a/examples/utilities/tools/developerMenuItems.js +++ b/examples/utilities/tools/developerMenuItems.js @@ -12,6 +12,7 @@ // var createdRenderMenu = false; +var createdGeneratedAudioMenu = false; var DEVELOPER_MENU = "Developer"; @@ -68,13 +69,15 @@ function setupMenus() { if (!Menu.menuExists(AUDIO_MENU)) { Menu.addMenu(AUDIO_MENU); } - Menu.addMenuItem({ menuName: AUDIO_MENU, menuItemName: AUDIO_SOURCE_INJECT, isCheckable: true, isChecked: false }); - Menu.addMenu(AUDIO_SOURCE_MENU); - Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_PINK_NOISE, isCheckable: true, isChecked: false }); - Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_SINE_440, isCheckable: true, isChecked: false }); - Menu.setIsOptionChecked(AUDIO_SOURCE_PINK_NOISE, true); - Audio.selectPinkNoise(); - + if (!Menu.menuItemExists(AUDIO_MENU, AUDIO_SOURCE_INJECT)) { + Menu.addMenuItem({ menuName: AUDIO_MENU, menuItemName: AUDIO_SOURCE_INJECT, isCheckable: true, isChecked: false }); + Menu.addMenu(AUDIO_SOURCE_MENU); + Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_PINK_NOISE, isCheckable: true, isChecked: false }); + Menu.addMenuItem({ menuName: AUDIO_SOURCE_MENU, menuItemName: AUDIO_SOURCE_SINE_440, isCheckable: true, isChecked: false }); + Menu.setIsOptionChecked(AUDIO_SOURCE_PINK_NOISE, true); + Audio.selectPinkNoise(); + createdGeneratedAudioMenu = true; + } } Menu.menuItemEvent.connect(function (menuItem) { @@ -88,12 +91,12 @@ Menu.menuItemEvent.connect(function (menuItem) { Scene.shouldRenderEntities = Menu.isOptionChecked(ENTITIES_ITEM); } else if (menuItem == AVATARS_ITEM) { Scene.shouldRenderAvatars = Menu.isOptionChecked(AVATARS_ITEM); - } else if (menuItem == AUDIO_SOURCE_INJECT) { + } else if (menuItem == AUDIO_SOURCE_INJECT && !createdGeneratedAudioMenu) { Audio.injectGeneratedNoise(Menu.isOptionChecked(AUDIO_SOURCE_INJECT)); - } else if (menuItem == AUDIO_SOURCE_PINK_NOISE) { + } else if (menuItem == AUDIO_SOURCE_PINK_NOISE && !createdGeneratedAudioMenu) { Audio.selectPinkNoise(); Menu.setIsOptionChecked(AUDIO_SOURCE_SINE_440, false); - } else if (menuItem == AUDIO_SOURCE_SINE_440) { + } else if (menuItem == AUDIO_SOURCE_SINE_440 && !createdGeneratedAudioMenu) { Audio.selectSine440(); Menu.setIsOptionChecked(AUDIO_SOURCE_PINK_NOISE, false); } @@ -117,9 +120,11 @@ function scriptEnding() { Menu.removeMenuItem(RENDER_MENU, AVATARS_ITEM); } - Audio.injectGeneratedNoise(false); - Menu.removeMenuItem(AUDIO_MENU, AUDIO_SOURCE_INJECT); - Menu.removeMenu(AUDIO_SOURCE_MENU); + if (createdGeneratedAudioMenu) { + Audio.injectGeneratedNoise(false); + Menu.removeMenuItem(AUDIO_MENU, AUDIO_SOURCE_INJECT); + Menu.removeMenu(AUDIO_SOURCE_MENU); + } } setupMenus(); From 604a13f8adef63337db66fecb49bda3c7314078e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 15 Apr 2015 17:04:59 +0200 Subject: [PATCH 23/23] Only editor can mute environment --- assignment-client/src/audio/AudioMixer.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index dd566bc40b..06e6f77f69 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -549,14 +549,18 @@ void AudioMixer::readPendingDatagram(const QByteArray& receivedPacket, const Hif nodeList->findNodeAndUpdateWithDataFromPacket(receivedPacket); } else if (mixerPacketType == PacketTypeMuteEnvironment) { - QByteArray packet = receivedPacket; - populatePacketHeader(packet, PacketTypeMuteEnvironment); - - nodeList->eachNode([&](const SharedNodePointer& node){ - if (node->getType() == NodeType::Agent && node->getActiveSocket() && node->getLinkedData() && node != nodeList->sendingNodeForPacket(receivedPacket)) { - nodeList->writeDatagram(packet, packet.size(), node); - } - }); + SharedNodePointer sendingNode = nodeList->sendingNodeForPacket(receivedPacket); + if (sendingNode->getCanAdjustLocks()) { + QByteArray packet = receivedPacket; + populatePacketHeader(packet, PacketTypeMuteEnvironment); + + nodeList->eachNode([&](const SharedNodePointer& node){ + if (node->getType() == NodeType::Agent && node->getActiveSocket() && + node->getLinkedData() && node != sendingNode) { + nodeList->writeDatagram(packet, packet.size(), node); + } + }); + } } else { // let processNodeData handle it. nodeList->processNodeData(senderSockAddr, receivedPacket);