From 5d74a865e85d2b619dd1cc1bdd5843a3340d0819 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 29 May 2013 11:35:32 -0700 Subject: [PATCH 1/3] make audio echo a menu option instead of forcing with mirror --- interface/src/Application.cpp | 8 +++----- interface/src/Application.h | 4 +++- interface/src/Audio.cpp | 4 ++-- interface/src/Audio.h | 3 --- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a8e62a68e7..f307efa470 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -965,11 +965,7 @@ void Application::pair() { PairingHandler::sendPairRequest(); } -void Application::setHead(bool head) { - #ifndef _WIN32 - _audio.setMixerLoopbackFlag(head); - #endif - +void Application::setHead(bool head) { if (head) { _myCamera.setMode(CAMERA_MODE_MIRROR); _myCamera.setModeShiftRate(100.0f); @@ -1133,6 +1129,8 @@ void Application::initMenu() { QMenu* optionsMenu = menuBar->addMenu("Options"); (_lookingInMirror = optionsMenu->addAction("Mirror", this, SLOT(setHead(bool)), Qt::Key_H))->setCheckable(true); + (_echoAudioMode = optionsMenu->addAction("Echo Audio"))->setCheckable(true); + optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N)->setCheckable(true); (_gyroLook = optionsMenu->addAction("Gyro Look"))->setCheckable(true); _gyroLook->setChecked(true); diff --git a/interface/src/Application.h b/interface/src/Application.h index 35d49d275a..ac089b4dd4 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -64,6 +64,7 @@ public: Avatar* getAvatar() { return &_myAvatar; } VoxelSystem* getVoxels() { return &_voxels; } Environment* getEnvironment() { return &_environment; } + QAction* getEchoAudioMode() { return _echoAudioMode; } private slots: @@ -137,7 +138,8 @@ private: QMainWindow* _window; QGLWidget* _glWidget; - QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror? + QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror? + QAction* _echoAudioMode; // Are we asking the mixer to echo back our audio? QAction* _gyroLook; // Whether to allow the gyro data from head to move your view QAction* _mouseLook; // Whether the have the mouse near edge of screen move your view QAction* _showHeadMouse; // Whether the have the mouse near edge of screen move your view diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 8acb70ebcc..8b484e1fb8 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "Application.h" #include "Audio.h" @@ -158,7 +159,7 @@ int audioCallback (const void* inputBuffer, correctedYaw += 360; } - if (parentAudio->_mixerLoopbackFlag) { + if (Application::getInstance()->getEchoAudioMode()->isChecked()) { correctedYaw = correctedYaw > 0 ? correctedYaw + AGENT_LOOPBACK_MODIFIER : correctedYaw - AGENT_LOOPBACK_MODIFIER; @@ -310,7 +311,6 @@ Audio::Audio(Oscilloscope* scope) : NUM_AUDIO_CHANNELS * (SAMPLE_RATE / 1000.0)), _wasStarved(0), _lastInputLoudness(0), - _mixerLoopbackFlag(false), _lastVelocity(0), _lastAcceleration(0), _totalPacketsReceived(0), diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 34a342a1d4..197daf0194 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -24,8 +24,6 @@ public: void render(int screenWidth, int screenHeight); - void setMixerLoopbackFlag(bool mixerLoopbackFlag) { _mixerLoopbackFlag = mixerLoopbackFlag; } - float getLastInputLoudness() const { return _lastInputLoudness; }; void setLastAcceleration(glm::vec3 lastAcceleration) { _lastAcceleration = lastAcceleration; }; @@ -52,7 +50,6 @@ private: short _jitterBufferSamples; int _wasStarved; float _lastInputLoudness; - bool _mixerLoopbackFlag; glm::vec3 _lastVelocity; glm::vec3 _lastAcceleration; int _totalPacketsReceived; From a5a30efec94062109fe7d5375e6137762262d990 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 29 May 2013 11:42:10 -0700 Subject: [PATCH 2/3] CR fixes --- interface/src/Application.cpp | 4 ++++ interface/src/Application.h | 3 ++- interface/src/Audio.cpp | 7 +++---- interface/src/Head.cpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f307efa470..e8419fd79b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -217,6 +217,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // initialization continues in initializeGL when OpenGL context is ready } +bool Application::shouldEchoAudio() { + return _echoAudioMode->isChecked(); +} + void Application::initializeGL() { printLog( "Created Display Window.\n" ); diff --git a/interface/src/Application.h b/interface/src/Application.h index ac089b4dd4..050f29895a 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -61,10 +61,11 @@ public: void wheelEvent(QWheelEvent* event); + bool shouldEchoAudio(); + Avatar* getAvatar() { return &_myAvatar; } VoxelSystem* getVoxels() { return &_voxels; } Environment* getEnvironment() { return &_environment; } - QAction* getEchoAudioMode() { return _echoAudioMode; } private slots: diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 8b484e1fb8..97929a99ca 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "Application.h" #include "Audio.h" @@ -159,10 +158,10 @@ int audioCallback (const void* inputBuffer, correctedYaw += 360; } - if (Application::getInstance()->getEchoAudioMode()->isChecked()) { + if (Application::getInstance()->shouldEchoAudio()) { correctedYaw = correctedYaw > 0 - ? correctedYaw + AGENT_LOOPBACK_MODIFIER - : correctedYaw - AGENT_LOOPBACK_MODIFIER; + ? correctedYaw + AGENT_LOOPBACK_MODIFIER + : correctedYaw - AGENT_LOOPBACK_MODIFIER; } memcpy(currentPacketPtr, &correctedYaw, sizeof(float)); diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 762b9f16ac..6f7f330010 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -40,8 +40,8 @@ vector irisTexture; Head::Head(Avatar* owningAvatar) : HeadData((AvatarData*)owningAvatar), - _renderAlpha(0.0), yawRate(0.0f), + _renderAlpha(0.0), _returnHeadToCenter(false), _skinColor(0.0f, 0.0f, 0.0f), _position(0.0f, 0.0f, 0.0f), From b6a0662c98e333f56d7d52841f401585838c39cb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 29 May 2013 11:47:02 -0700 Subject: [PATCH 3/3] inline the shouldEchoAudio --- interface/src/Application.cpp | 4 ---- interface/src/Application.h | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e8419fd79b..f307efa470 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -217,10 +217,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // initialization continues in initializeGL when OpenGL context is ready } -bool Application::shouldEchoAudio() { - return _echoAudioMode->isChecked(); -} - void Application::initializeGL() { printLog( "Created Display Window.\n" ); diff --git a/interface/src/Application.h b/interface/src/Application.h index 050f29895a..f611a803b9 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -13,6 +13,7 @@ #include #include +#include #include @@ -61,11 +62,10 @@ public: void wheelEvent(QWheelEvent* event); - bool shouldEchoAudio(); - Avatar* getAvatar() { return &_myAvatar; } VoxelSystem* getVoxels() { return &_voxels; } Environment* getEnvironment() { return &_environment; } + bool shouldEchoAudio() { return _echoAudioMode->isChecked(); } private slots: