No longer applying volume when reading audio injector buffer

Since we also apply the gain in HRTF (on both server and client), the
mono sources sort of had volume^2 applied to them.
This commit is contained in:
David Kelly 2016-12-12 12:01:02 -08:00
parent 8719d36cd9
commit 3f3d922eca
2 changed files with 4 additions and 15 deletions

View file

@ -1132,7 +1132,7 @@ void AudioClient::mixLocalAudioInjectors(float* mixBuffer) {
// stereo gets directly mixed into mixBuffer
for (int i = 0; i < AudioConstants::NETWORK_FRAME_SAMPLES_STEREO; i++) {
mixBuffer[i] += (float)_scratchBuffer[i] * (1/32768.0f);
mixBuffer[i] += (float)_scratchBuffer[i] * (1/32768.0f) * injector->getVolume();
}
} else {

View file

@ -36,17 +36,6 @@ bool AudioInjectorLocalBuffer::seek(qint64 pos) {
}
}
void copy(char* to, char* from, int size, qreal factor) {
int16_t* toArray = (int16_t*) to;
int16_t* fromArray = (int16_t*) from;
int sampleSize = size / sizeof(int16_t);
for (int i = 0; i < sampleSize; i++) {
*toArray = factor * (*fromArray);
toArray++;
fromArray++;
}
}
qint64 AudioInjectorLocalBuffer::readData(char* data, qint64 maxSize) {
if (!_isStopped) {
@ -60,7 +49,7 @@ qint64 AudioInjectorLocalBuffer::readData(char* data, qint64 maxSize) {
bytesRead = bytesToEnd;
}
copy(data, _rawAudioArray.data() + _currentOffset, bytesRead, _volume);
memcpy(data, _rawAudioArray.data() + _currentOffset, bytesRead);
// now check if we are supposed to loop and if we can copy more from the beginning
if (_shouldLoop && maxSize != bytesRead) {
@ -88,7 +77,7 @@ qint64 AudioInjectorLocalBuffer::recursiveReadFromFront(char* data, qint64 maxSi
}
// copy that amount
copy(data, _rawAudioArray.data(), bytesRead, _volume);
memcpy(data, _rawAudioArray.data(), bytesRead);
// check if we need to call ourselves again and pull from the front again
if (bytesRead < maxSize) {
@ -97,4 +86,4 @@ qint64 AudioInjectorLocalBuffer::recursiveReadFromFront(char* data, qint64 maxSi
_currentOffset = bytesRead;
return bytesRead;
}
}
}