Code cleanup for avatar volmue fix

This commit is contained in:
ksuprynowicz 2024-03-01 02:12:28 +01:00
parent 04e85d53e6
commit 6be71a7140
2 changed files with 12 additions and 19 deletions

View file

@ -222,25 +222,23 @@ void AudioMixerClientData::parseInjectorGainSet(ReceivedMessage& message, const
qCDebug(audio) << "Setting MASTER injector gain for" << uuid << "to" << gain;
}
void AudioMixerClientData::setGainForAvatar(QUuid nodeID, float gain) {
auto itActive = std::find_if(_streams.active.cbegin(), _streams.active.cend(), [nodeID](const MixableStream& mixableStream){
bool setGainInStreams(const QUuid &nodeID, float gain, std::vector<AudioMixerClientData::MixableStream> &streamVector) {
auto itActive = std::find_if(streamVector.cbegin(), streamVector.cend(),
[nodeID](const AudioMixerClientData::MixableStream& mixableStream){
return mixableStream.nodeStreamID.nodeID == nodeID && mixableStream.nodeStreamID.streamID.isNull();
});
if (itActive != _streams.active.cend()) {
if (itActive != streamVector.cend()) {
itActive->hrtf->setGainAdjustment(gain);
return;
return true;
} else {
return false;
}
}
// If someone is not speaking at the moment, then stream is not in active streams, and volume adjustment will fail,
// so we need to search in inactive streams too
auto itInactive = std::find_if(_streams.inactive.cbegin(), _streams.inactive.cend(), [nodeID](const MixableStream& mixableStream){
return mixableStream.nodeStreamID.nodeID == nodeID && mixableStream.nodeStreamID.streamID.isNull();
});
if (itInactive != _streams.active.cend()) {
itInactive->hrtf->setGainAdjustment(gain);
return;
void AudioMixerClientData::setGainForAvatar(QUuid nodeID, float gain) {
if (!setGainInStreams(nodeID, gain, _streams.active)) {
setGainInStreams(nodeID, gain, _streams.inactive);
}
}

View file

@ -16,8 +16,6 @@
#include <string.h>
#include <algorithm>
#include <qdebug.h>
#include "AudioHelpers.h"
static const int HRTF_AZIMUTHS = 72; // 360 / 5-degree steps
@ -82,10 +80,7 @@ public:
//
// HRTF local gain adjustment in amplitude (1.0 == unity)
//
void setGainAdjustment(float gain) {
_gainAdjust = HRTF_GAIN * gain;
qDebug() << "AudioHRTF::setGainAdjustment: " << _gainAdjust;
};
void setGainAdjustment(float gain) { _gainAdjust = HRTF_GAIN * gain; };
float getGainAdjustment() { return _gainAdjust; }
// clear internal state, but retain settings