History

first pass, clipping audio meter

Philip Rosedale committed 12 years ago

Commit d90244c1 parent ec225403 files · +49 −1Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+37−1
@@ -2494,7 +2494,7 @@ void Application::displayOverlay() { · 2493 unmodified lines
24942494 renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
24952495 }
24962496 }
2497−
2497+
24982498 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
24992499 _audio.renderMuteIcon(1, _glWidget->height() - 50);
25002500 if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
@@ -2502,6 +2502,42 @@ void Application::displayOverlay() { · 1 unmodified line
25022502 _audioScope.render(25, oscilloscopeTop);
25032503 }
25042504 }
2505+
2506+ const int AUDIO_METER_WIDTH = 300;
2507+ const int AUDIO_METER_INSET = 2;
2508+ const int AUDIO_METER_SCALE_WIDTH = AUDIO_METER_WIDTH - 2 * AUDIO_METER_INSET;
2509+ const int AUDIO_METER_HEIGHT = 8;
2510+ const int AUDIO_METER_Y = _glWidget->height() - 40;
2511+ const int AUDIO_METER_X = 25;
2512+ const float CLIPPING_INDICATOR_TIME = 1.0f;
2513+ float audioLevel = log10(_audio.getLastInputLoudness() + 1.0) / log10(32767.0) * (float)AUDIO_METER_SCALE_WIDTH;
2514+ bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
2515+
2516+ if (isClipping) {
2517+ glColor3f(1, 0, 0);
2518+ } else {
2519+ glColor3f(0, 0, 0);
2520+ }
2521+ glBegin(GL_QUADS);
2522+ // Draw background Quad
2523+ glVertex2i(AUDIO_METER_X, AUDIO_METER_Y);
2524+ glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, AUDIO_METER_Y);
2525+ glVertex2i(AUDIO_METER_X + AUDIO_METER_WIDTH, AUDIO_METER_Y + AUDIO_METER_HEIGHT);
2526+ glVertex2i(AUDIO_METER_X, AUDIO_METER_Y + AUDIO_METER_HEIGHT);
2527+
2528+ // Draw Meter Quad
2529+ if (isClipping) {
2530+ glColor3f(1, 1, 1);
2531+ } else {
2532+ glColor3f(0, 1, 1);
2533+ }
2534+ // Draw Meter quad
2535+ glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET, AUDIO_METER_Y + AUDIO_METER_INSET);
2536+ glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, AUDIO_METER_Y + AUDIO_METER_INSET);
2537+ glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET + audioLevel, AUDIO_METER_Y + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
2538+ glVertex2i(AUDIO_METER_X + AUDIO_METER_INSET, AUDIO_METER_Y + AUDIO_METER_HEIGHT - AUDIO_METER_INSET);
2539+
2540+ glEnd();
25052541
25062542 if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
25072543 _myAvatar->renderHeadMouse();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t