mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 14:44:39 +02:00
hook audio loudness back to QAudioInput
This commit is contained in:
parent
983fd32676
commit
21076af739
2 changed files with 11 additions and 17 deletions
|
@ -10,15 +10,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Syssocket.h"
|
||||
#include "Systime.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
#include <glm/gtx/component_wise.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/vector_angle.hpp>
|
||||
|
@ -2426,10 +2417,8 @@ void Application::updateAudio(float deltaTime) {
|
|||
PerformanceWarning warn(showWarnings, "Application::updateAudio()");
|
||||
|
||||
// Update audio stats for procedural sounds
|
||||
#ifndef _WIN32
|
||||
_audio.setLastAcceleration(_myAvatar.getThrust());
|
||||
_audio.setLastVelocity(_myAvatar.getVelocity());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::updateCursor(float deltaTime) {
|
||||
|
@ -2569,10 +2558,8 @@ void Application::updateAvatar(float deltaTime) {
|
|||
}
|
||||
|
||||
// Get audio loudness data from audio input device
|
||||
#ifndef _WIN32
|
||||
_myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness());
|
||||
#endif
|
||||
|
||||
_myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness());
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
// send head/hand data to the avatar mixer and voxel server
|
||||
|
@ -3203,14 +3190,12 @@ void Application::displayOverlay() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
|
||||
_audio.render(_glWidget->width(), _glWidget->height());
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
|
||||
_audioScope.render(45, _glWidget->height() - 200);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//noiseTest(_glWidget->width(), _glWidget->height());
|
||||
|
||||
|
|
|
@ -194,6 +194,15 @@ void Audio::handleAudioInput() {
|
|||
// copy samples from the inputByteArray to the stereoInputBuffer
|
||||
memcpy((char*) (stereoInputBuffer + bufferSizeSamples), inputByteArray.data(), inputByteArray.size());
|
||||
|
||||
// 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 * SAMPLE_RATE_RATIO; i += 2) {
|
||||
loudness += abs(stereoInputBuffer[i]);
|
||||
}
|
||||
|
||||
loudness /= BUFFER_LENGTH_SAMPLES_PER_CHANNEL * SAMPLE_RATE_RATIO;
|
||||
_lastInputLoudness = loudness;
|
||||
|
||||
} else {
|
||||
// take samples we have in this callback and store them in the first half of the static buffer
|
||||
// to send off in the next callback
|
||||
|
|
Loading…
Reference in a new issue