fix the scope and last input loudness

This commit is contained in:
Stephen Birarda 2013-12-16 15:41:58 -08:00
parent f7ed8cef8f
commit 89beff4253
2 changed files with 9 additions and 6 deletions

View file

@ -353,15 +353,18 @@ void Audio::handleAudioInput() {
memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation));
currentPacketPtr += sizeof(headOrientation);
float loudness = 0;
if (!_muted) {
float loudness = 0;
// loudness /= BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
_lastInputLoudness = loudness;
for (int i = 0; i < NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) {
loudness += fabsf(_monoAudioSamples[i]);
}
} else {
_lastInputLoudness = 0;
loudness /= NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
}
_lastInputLoudness = loudness;
nodeList->getNodeSocket().writeDatagram(monoAudioDataPacket,
NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes,
audioMixer->getActiveSocket()->getAddress(),

View file

@ -77,7 +77,7 @@ void Oscilloscope::addSamples(const QByteArray& audioByteArray, bool isStereo, b
int numSamplesPerChannel = audioByteArray.size() / (sizeof(int16_t) * (isStereo ? 2 : 1));
int16_t* samples = (int16_t*) audioByteArray.data();
for (int channel = 0; channel < (isStereo ? 1 : 2); channel++) {
for (int channel = 0; channel < (isStereo ? 2 : 1); channel++) {
// add samples for each of the channels
// determine start/end offset of this channel's region