diff --git a/interface/resources/images/mic-tool.svg b/interface/resources/images/mic-tool.svg
new file mode 100644
index 0000000000..956b12dff3
--- /dev/null
+++ b/interface/resources/images/mic-tool.svg
@@ -0,0 +1,20 @@
+
+
\ No newline at end of file
diff --git a/interface/resources/images/mic.svg b/interface/resources/images/mic.svg
new file mode 100644
index 0000000000..a6dee50740
--- /dev/null
+++ b/interface/resources/images/mic.svg
@@ -0,0 +1,20 @@
+
+
\ No newline at end of file
diff --git a/interface/resources/images/mute.svg b/interface/resources/images/mute.svg
new file mode 100644
index 0000000000..1f1b238463
--- /dev/null
+++ b/interface/resources/images/mute.svg
@@ -0,0 +1,20 @@
+
+
\ No newline at end of file
diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp
index 615fcfaa01..5597d708bc 100644
--- a/interface/src/Application.cpp
+++ b/interface/src/Application.cpp
@@ -971,7 +971,12 @@ void Application::mousePressEvent(QMouseEvent* event) {
_mousePressed = true;
maybeEditVoxelUnderCursor();
-
+
+ if (_audio.mousePressEvent(_mouseX, _mouseY)) {
+ // stop propagation
+ return;
+ }
+
if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
_pieMenu.mousePressEvent(_mouseX, _mouseY);
}
@@ -1607,6 +1612,8 @@ void Application::init() {
_followMode = new QAction(this);
connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode()));
_pieMenu.addAction(_followMode);
+
+ _audio.init(_glWidget);
}
@@ -2655,7 +2662,7 @@ void Application::displayOverlay() {
#ifndef _WIN32
_audio.render(_glWidget->width(), _glWidget->height());
if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
- _audioScope.render(20, _glWidget->height() - 200);
+ _audioScope.render(45, _glWidget->height() - 200);
}
#endif
diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp
index d98577eaaf..bea12af25e 100644
--- a/interface/src/Audio.cpp
+++ b/interface/src/Audio.cpp
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include "Application.h"
#include "Audio.h"
@@ -69,6 +70,10 @@ static const int PING_FRAMES_TO_RECORD = AEC_BUFFERED_FRAMES;
static const int PING_SAMPLES_TO_ANALYZE = AEC_BUFFERED_SAMPLES_PER_CHANNEL; // Samples to analyze (reusing AEC buffer)
static const int PING_BUFFER_OFFSET = BUFFER_LENGTH_SAMPLES_PER_CHANNEL - PING_PERIOD * 2.0f; // Signal start
+// Mute icon configration
+static const int ICON_SIZE = 24;
+static const int ICON_LEFT = 20;
+static const int BOTTOM_PADDING = 110;
inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* outputRight) {
@@ -84,17 +89,19 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
if (nodeList && inputLeft) {
- // Measure the loudness of the signal from the microphone and store in audio object
- float loudness = 0;
- for (int i = 0; i < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) {
- loudness += abs(inputLeft[i]);
+ if (!_muted) {
+ // Measure the loudness of the signal from the microphone and store in audio object
+ float loudness = 0;
+ for (int i = 0; i < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) {
+ loudness += abs(inputLeft[i]);
+ }
+
+ loudness /= BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
+ _lastInputLoudness = loudness;
+
+ // add input (@microphone) data to the scope
+ _scope->addSamples(0, inputLeft, BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
}
-
- loudness /= BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
- _lastInputLoudness = loudness;
-
- // add input (@microphone) data to the scope
- _scope->addSamples(0, inputLeft, BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
Node* audioMixer = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
@@ -323,6 +330,11 @@ int Audio::audioCallback (const void* inputBuffer,
return paContinue;
}
+void Audio::init(QGLWidget *parent) {
+ switchToResourcesParentIfRequired();
+ _micTextureId = parent->bindTexture(QImage("./resources/images/mic.svg"));
+ _muteTextureId = parent->bindTexture(QImage("./resources/images/mute.svg"));
+}
static void outputPortAudioError(PaError error) {
if (error != paNoError) {
@@ -384,6 +396,7 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
_collisionSoundDuration(0.0f),
_proceduralEffectSample(0),
_heartbeatMagnitude(0.0f),
+ _muted(false),
_listenMode(AudioRingBuffer::NORMAL),
_listenRadius(0.0f)
{
@@ -515,6 +528,14 @@ void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBy
_lastReceiveTime = currentReceiveTime;
}
+bool Audio::mousePressEvent(int x, int y) {
+ if (_iconBounds.contains(x, y)) {
+ _muted = !_muted;
+ return true;
+ }
+ return false;
+}
+
void Audio::render(int screenWidth, int screenHeight) {
if (_stream) {
glLineWidth(2.0);
@@ -609,6 +630,7 @@ void Audio::render(int screenWidth, int screenHeight) {
glEnd();
}
+ renderToolIcon(screenHeight);
}
//
@@ -856,4 +878,49 @@ bool Audio::eventuallyAnalyzePing() {
return true;
}
+void Audio::renderToolIcon(int screenHeigh) {
+
+ _iconBounds = QRect(ICON_LEFT, screenHeigh - BOTTOM_PADDING, ICON_SIZE, ICON_SIZE);
+ glEnable(GL_TEXTURE_2D);
+
+ glBindTexture(GL_TEXTURE_2D, _micTextureId);
+ glColor3f(1, 1, 1);
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(1, 1);
+ glVertex2f(_iconBounds.left(), _iconBounds.top());
+
+ glTexCoord2f(0, 1);
+ glVertex2f(_iconBounds.right(), _iconBounds.top());
+
+ glTexCoord2f(0, 0);
+ glVertex2f(_iconBounds.right(), _iconBounds.bottom());
+
+ glTexCoord2f(1, 0);
+ glVertex2f(_iconBounds.left(), _iconBounds.bottom());
+
+ glEnd();
+
+ if (_muted) {
+ glBindTexture(GL_TEXTURE_2D, _muteTextureId);
+ glBegin(GL_QUADS);
+
+ glTexCoord2f(1, 1);
+ glVertex2f(_iconBounds.left(), _iconBounds.top());
+
+ glTexCoord2f(0, 1);
+ glVertex2f(_iconBounds.right(), _iconBounds.top());
+
+ glTexCoord2f(0, 0);
+ glVertex2f(_iconBounds.right(), _iconBounds.bottom());
+
+ glTexCoord2f(1, 0);
+ glVertex2f(_iconBounds.left(), _iconBounds.bottom());
+
+ glEnd();
+ }
+
+ glDisable(GL_TEXTURE_2D);
+}
+
#endif
diff --git a/interface/src/Audio.h b/interface/src/Audio.h
index 8409f5ca84..7c66c7e375 100644
--- a/interface/src/Audio.h
+++ b/interface/src/Audio.h
@@ -12,6 +12,8 @@
#include
#include
+#include "InterfaceConfig.h"
+
#include
#include
@@ -21,6 +23,8 @@
#include "Oscilloscope.h"
+#include
+
static const int NUM_AUDIO_CHANNELS = 2;
static const int PACKET_LENGTH_BYTES = 1024;
@@ -56,6 +60,9 @@ public:
float getCollisionSoundMagnitude() { return _collisionSoundMagnitude; }
void ping();
+
+ void init(QGLWidget *parent = 0);
+ bool mousePressEvent(int x, int y);
// Call periodically to eventually perform round trip time analysis,
// in which case 'true' is returned - otherwise the return value is 'false'.
@@ -69,6 +76,7 @@ public:
void clearListenSources();
private:
+
PaStream* _stream;
AudioRingBuffer _ringBuffer;
Oscilloscope* _scope;
@@ -103,6 +111,11 @@ private:
float _collisionSoundDuration;
int _proceduralEffectSample;
float _heartbeatMagnitude;
+
+ bool _muted;
+ GLuint _micTextureId;
+ GLuint _muteTextureId;
+ QRect _iconBounds;
AudioRingBuffer::ListenMode _listenMode;
float _listenRadius;
@@ -130,6 +143,7 @@ private:
PaStreamCallbackFlags statusFlags,
void *userData);
+ void renderToolIcon(int screenHeight);
};