mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Magic numbers and casts
This commit is contained in:
parent
81888b9f83
commit
011e531971
1 changed files with 7 additions and 6 deletions
|
@ -574,11 +574,11 @@ void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioF
|
|||
for (unsigned int j = sample; j < sample + audioFormat.channelCount(); j++) {
|
||||
if (j == sample) {
|
||||
// left channel
|
||||
int lResult = glm::clamp((int)(samplesData[j] * dryFraction + lValue * wetFraction), -32768, 32767);
|
||||
int lResult = glm::clamp((int)(samplesData[j] * dryFraction + lValue * wetFraction), MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
||||
samplesData[j] = (int16_t)lResult;
|
||||
} else if (j == (sample + 1)) {
|
||||
// right channel
|
||||
int rResult = glm::clamp((int)(samplesData[j] * dryFraction + rValue * wetFraction), -32768, 32767);
|
||||
int rResult = glm::clamp((int)(samplesData[j] * dryFraction + rValue * wetFraction), MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
||||
samplesData[j] = (int16_t)rResult;
|
||||
} else {
|
||||
// ignore channels above 2
|
||||
|
@ -610,7 +610,8 @@ void Audio::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
|||
(_outputFormat.channelCount() / _inputFormat.channelCount());
|
||||
loopBackByteArray.resize(inputByteArray.size() * loopbackOutputToInputRatio);
|
||||
loopBackByteArray.fill(0);
|
||||
linearResampling((int16_t*)inputByteArray.data(), (int16_t*)loopBackByteArray.data(),
|
||||
linearResampling(reinterpret_cast<int16_t*>(inputByteArray.data()),
|
||||
reinterpret_cast<int16_t*>(loopBackByteArray.data()),
|
||||
inputByteArray.size() / sizeof(int16_t), loopBackByteArray.size() / sizeof(int16_t),
|
||||
_inputFormat, _outputFormat);
|
||||
}
|
||||
|
@ -621,16 +622,16 @@ void Audio::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
|||
loopbackCopy = loopBackByteArray;
|
||||
}
|
||||
|
||||
int16_t* loopbackSamples = (int16_t*) loopBackByteArray.data();
|
||||
int16_t* loopbackSamples = reinterpret_cast<int16_t*>(loopBackByteArray.data());
|
||||
int numLoopbackSamples = loopBackByteArray.size() / sizeof(int16_t);
|
||||
updateGverbOptions();
|
||||
addReverb(loopbackSamples, numLoopbackSamples, _outputFormat);
|
||||
|
||||
if (!hasEcho) {
|
||||
int16_t* loopbackCopySamples = (int16_t*) loopbackCopy.data();
|
||||
int16_t* loopbackCopySamples = reinterpret_cast<int16_t*>(loopbackCopy.data());
|
||||
for (int i = 0; i < numLoopbackSamples; ++i) {
|
||||
loopbackSamples[i] = glm::clamp((int)loopbackSamples[i] - loopbackCopySamples[i],
|
||||
-32768, 32767);
|
||||
MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue