mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 14:54:29 +02:00
Code review
This commit is contained in:
parent
f60e863b66
commit
2fe24b39db
2 changed files with 11 additions and 13 deletions
|
@ -442,13 +442,12 @@ void Agent::executeScript() {
|
||||||
|
|
||||||
QByteArray audio(frame->data);
|
QByteArray audio(frame->data);
|
||||||
|
|
||||||
auto volume = player->getVolume();
|
|
||||||
if (volume != 1.0f || _isNoiseGateEnabled) {
|
|
||||||
int16_t* samples = reinterpret_cast<int16_t*>(audio.data());
|
int16_t* samples = reinterpret_cast<int16_t*>(audio.data());
|
||||||
int numSamples = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL;
|
int numSamples = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL;
|
||||||
|
|
||||||
if (volume != 1.0f) {
|
auto volume = player->getVolume();
|
||||||
int32_t fract = (int32_t)(volume * 65536.0f); // Q16
|
if (volume >= 0.0f && volume < 1.0f) {
|
||||||
|
int32_t fract = (int32_t)(volume * (float)(1 << 16)); // Q16
|
||||||
for (int i = 0; i < numSamples; i++) {
|
for (int i = 0; i < numSamples; i++) {
|
||||||
samples[i] = (fract * (int32_t)samples[i]) >> 16;
|
samples[i] = (fract * (int32_t)samples[i]) >> 16;
|
||||||
}
|
}
|
||||||
|
@ -457,7 +456,6 @@ void Agent::executeScript() {
|
||||||
if (_isNoiseGateEnabled) {
|
if (_isNoiseGateEnabled) {
|
||||||
_audioGate.render(samples, samples, numSamples);
|
_audioGate.render(samples, samples, numSamples);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
computeLoudness(&audio, scriptedAvatar);
|
computeLoudness(&audio, scriptedAvatar);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
float position() const;
|
float position() const;
|
||||||
void seek(float position);
|
void seek(float position);
|
||||||
|
|
||||||
float getVolume() { return _volume; }
|
float getVolume() const { return _volume; }
|
||||||
void setVolume(float volume);
|
void setVolume(float volume);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in a new issue