Skip to content

Commit 2fe24b3

Browse files
committed
Code review
1 parent f60e863 commit 2fe24b3

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

assignment-client/src/Agent.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,19 @@ void Agent::executeScript() {
442442

443443
QByteArray audio(frame->data);
444444

445+
int16_t* samples = reinterpret_cast<int16_t*>(audio.data());
446+
int numSamples = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL;
447+
445448
auto volume = player->getVolume();
446-
if (volume != 1.0f || _isNoiseGateEnabled) {
447-
int16_t* samples = reinterpret_cast<int16_t*>(audio.data());
448-
int numSamples = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL;
449-
450-
if (volume != 1.0f) {
451-
int32_t fract = (int32_t)(volume * 65536.0f); // Q16
452-
for (int i = 0; i < numSamples; i++) {
453-
samples[i] = (fract * (int32_t)samples[i]) >> 16;
454-
}
449+
if (volume >= 0.0f && volume < 1.0f) {
450+
int32_t fract = (int32_t)(volume * (float)(1 << 16)); // Q16
451+
for (int i = 0; i < numSamples; i++) {
452+
samples[i] = (fract * (int32_t)samples[i]) >> 16;
455453
}
454+
}
456455

457-
if (_isNoiseGateEnabled) {
458-
_audioGate.render(samples, samples, numSamples);
459-
}
456+
if (_isNoiseGateEnabled) {
457+
_audioGate.render(samples, samples, numSamples);
460458
}
461459

462460
computeLoudness(&audio, scriptedAvatar);

libraries/recording/src/recording/Deck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Deck : public QObject, public ::Dependency {
5757
float position() const;
5858
void seek(float position);
5959

60-
float getVolume() { return _volume; }
60+
float getVolume() const { return _volume; }
6161
void setVolume(float volume);
6262

6363
signals:

0 commit comments

Comments
 (0)