mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 09:25:31 +02:00
#19426 - Add a mute control to the interface
- OpenGL overlay icon - mute control - icons
This commit is contained in:
parent
e9a21e284a
commit
61b213804a
6 changed files with 160 additions and 12 deletions
20
interface/resources/images/mic-tool.svg
Normal file
20
interface/resources/images/mic-tool.svg
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="45px" height="45px" viewBox="0 0 45 45" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
||||
<title>Slice 1</title>
|
||||
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
||||
<g sketch:type="MSLayerGroup">
|
||||
<rect d="M0,0 L0,45 L45,45 L45,0 L0,0 Z M0,0" id="Rectangle-1" fill="#000000" sketch:type="MSShapeGroup" x="0" y="0" width="45" height="45"></rect>
|
||||
<g id="mic" transform="translate(3.000000, 2.000000)" sketch:type="MSShapeGroup">
|
||||
<path d="M23.1863426,39.2982456 L27.9259259,39.2982456" id="Shape" fill="#CACACA"></path>
|
||||
<path d="M11.0740741,39.2982456 C12.6269271,36.6118421 15.3070486,34.8441118 18.2962963,34.4674781 L18.2962963,30.5769518 C12.8949016,29.9582346 8.66666667,25.3241886 8.66666667,19.6491228 L8.66666667,17.1929824 C8.66666667,16.5141667 9.20502316,15.9649123 9.87037034,15.9649123 C10.5357176,15.9649123 11.0740741,16.5141667 11.0740741,17.1929824 L11.0740741,19.6491228 C11.0740741,24.3887061 14.854456,28.2456141 19.5,28.2456141 C24.145544,28.2456141 27.9259259,24.3887061 27.9259259,19.6491228 L27.9259259,17.1929824 C27.9259259,16.5141667 28.4642824,15.9649123 29.1296297,15.9649123 C29.7949768,15.9649123 30.3333333,16.5141667 30.3333333,17.1929824 L30.3333333,19.6491228 C30.3333333,25.3241886 26.1062268,29.9582346 20.7037037,30.5770285 L20.7037037,34.4675548 C23.6941551,34.8441118 26.3742766,36.6118421 27.9259259,39.2982456 L23.1863426,39.2982456 C22.5586111,37.8207237 21.1386169,36.8589145 19.561088,36.8421053 C17.9858912,36.8252961 16.5447569,37.8351535 15.8888136,39.2982456 L11.0740741,39.2982456 L11.0740741,39.2982456 L11.0740741,39.2982456 L11.0740741,39.2982456 Z M11.0740741,39.2982456" id="Shape" fill="#CACACA"></path>
|
||||
<path d="M19.5,0 C16.1756713,0 13.4814815,2.74880483 13.4814815,6.14035088 L13.4814815,12.2807018 L13.4814815,19.6491228 C13.4814815,23.0407456 16.1757465,25.7894737 19.5,25.7894737 C22.8242535,25.7894737 25.5185185,23.0406689 25.5185185,19.6491228 L25.5185185,12.2807018 L25.5185185,6.14035088 C25.5185185,2.74880483 22.8243287,0 19.5,0 L19.5,0 L19.5,0 L19.5,0 L19.5,0 Z M15.8888889,12.4342105 L15.8888889,6.29385962 C15.8888889,4.26224781 17.5086979,2.60964912 19.5,2.60964912 C21.4913021,2.60964912 23.1111111,4.26224781 23.1111111,6.29385962 L23.1111111,12.4342105 L15.8888889,12.4342105 L15.8888889,12.4342105 L15.8888889,12.4342105 L15.8888889,12.4342105 Z M15.8888889,12.4342105" id="Shape" fill="#CACACA"></path>
|
||||
<g id="muted" transform="translate(0.000000, 1.250000)" stroke="#CB0011" stroke-width="4">
|
||||
<ellipse d="M19.5,36.25 C30.2695532,36.25 39,28.1351616 39,18.125 C39,8.11483841 30.2695532,0 19.5,0 C8.73044685,0 0,8.11483841 0,18.125 C0,28.1351616 8.73044685,36.25 19.5,36.25 Z M19.5,36.25" id="Oval-1" cx="19.5" cy="18.125" rx="19.5" ry="18.125"></ellipse>
|
||||
<path d="M6.65836705,31.3171677 L32.4462334,4.98158885" id="Line"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
20
interface/resources/images/mic.svg
Normal file
20
interface/resources/images/mic.svg
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="45px" height="45px" viewBox="0 0 45 45" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
||||
<title>Mic</title>
|
||||
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
||||
<g id="mic-tool" sketch:type="MSLayerGroup">
|
||||
<g id="Page-1" sketch:type="MSShapeGroup">
|
||||
<g id="Group">
|
||||
<rect d="M0,0 L0,45 L45,45 L45,0 L0,0 Z M0,0" id="Rectangle-1" fill="#000000" x="0" y="0" width="45" height="45"></rect>
|
||||
<g id="mic" transform="translate(3.000000, 2.000000)" fill="#CACACA">
|
||||
<path d="M23.1863426,39.2982456 L27.9259259,39.2982456" id="Shape"></path>
|
||||
<path d="M11.0740741,39.2982456 C12.6269271,36.6118421 15.3070486,34.8441118 18.2962963,34.4674781 L18.2962963,30.5769518 C12.8949016,29.9582346 8.66666667,25.3241886 8.66666667,19.6491228 L8.66666667,17.1929824 C8.66666667,16.5141667 9.20502316,15.9649123 9.87037034,15.9649123 C10.5357176,15.9649123 11.0740741,16.5141667 11.0740741,17.1929824 L11.0740741,19.6491228 C11.0740741,24.3887061 14.854456,28.2456141 19.5,28.2456141 C24.145544,28.2456141 27.9259259,24.3887061 27.9259259,19.6491228 L27.9259259,17.1929824 C27.9259259,16.5141667 28.4642824,15.9649123 29.1296297,15.9649123 C29.7949768,15.9649123 30.3333333,16.5141667 30.3333333,17.1929824 L30.3333333,19.6491228 C30.3333333,25.3241886 26.1062268,29.9582346 20.7037037,30.5770285 L20.7037037,34.4675548 C23.6941551,34.8441118 26.3742766,36.6118421 27.9259259,39.2982456 L23.1863426,39.2982456 C22.5586111,37.8207237 21.1386169,36.8589145 19.561088,36.8421053 C17.9858912,36.8252961 16.5447569,37.8351535 15.8888136,39.2982456 L11.0740741,39.2982456 L11.0740741,39.2982456 L11.0740741,39.2982456 L11.0740741,39.2982456 Z M11.0740741,39.2982456" id="Shape"></path>
|
||||
<path d="M19.5,0 C16.1756713,0 13.4814815,2.74880483 13.4814815,6.14035088 L13.4814815,12.2807018 L13.4814815,19.6491228 C13.4814815,23.0407456 16.1757465,25.7894737 19.5,25.7894737 C22.8242535,25.7894737 25.5185185,23.0406689 25.5185185,19.6491228 L25.5185185,12.2807018 L25.5185185,6.14035088 C25.5185185,2.74880483 22.8243287,0 19.5,0 L19.5,0 L19.5,0 L19.5,0 L19.5,0 Z M15.8888889,12.4342105 L15.8888889,6.29385962 C15.8888889,4.26224781 17.5086979,2.60964912 19.5,2.60964912 C21.4913021,2.60964912 23.1111111,4.26224781 23.1111111,6.29385962 L23.1111111,12.4342105 L15.8888889,12.4342105 L15.8888889,12.4342105 L15.8888889,12.4342105 L15.8888889,12.4342105 Z M15.8888889,12.4342105" id="Shape"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.9 KiB |
20
interface/resources/images/mute.svg
Normal file
20
interface/resources/images/mute.svg
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="45px" height="45px" viewBox="0 0 45 45" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
||||
<title>mute</title>
|
||||
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
||||
<g id="mic-tool" sketch:type="MSLayerGroup" stroke-width="4" stroke="#CB0011">
|
||||
<g id="Page-1" sketch:type="MSShapeGroup">
|
||||
<g id="Group">
|
||||
<g id="mic" transform="translate(3.000000, 2.000000)">
|
||||
<g id="muted" transform="translate(0.000000, 1.250000)">
|
||||
<ellipse d="M19.5,36.25 C30.2695532,36.25 39,28.1351616 39,18.125 C39,8.11483841 30.2695532,0 19.5,0 C8.73044685,0 0,8.11483841 0,18.125 C0,28.1351616 8.73044685,36.25 19.5,36.25 Z M19.5,36.25" id="Oval-1" cx="19.5" cy="18.125" rx="19.5" ry="18.125"></ellipse>
|
||||
<path d="M6.65836705,31.3171677 L32.4462334,4.98158885" id="Line"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -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
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <SharedUtil.h>
|
||||
#include <StdDev.h>
|
||||
#include <UDPSocket.h>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#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
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <portaudio.h>
|
||||
|
@ -21,6 +23,8 @@
|
|||
|
||||
#include "Oscilloscope.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue