mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
dryFraction factorisation
This commit is contained in:
parent
082b9ff59f
commit
a8c38aab64
1 changed files with 3 additions and 5 deletions
|
@ -567,7 +567,7 @@ void Audio::setReverbOptions(const AudioEffectOptions* options) {
|
||||||
|
|
||||||
void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioFormat, bool noEcho) {
|
void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioFormat, bool noEcho) {
|
||||||
float wetFraction = DB_CO(_reverbOptions->getWetLevel());
|
float wetFraction = DB_CO(_reverbOptions->getWetLevel());
|
||||||
float dryFraction = 1.0f - wetFraction;
|
float dryFraction = (noEcho) ? 0.0f : (1.0f - wetFraction);
|
||||||
|
|
||||||
float lValue,rValue;
|
float lValue,rValue;
|
||||||
for (int sample = 0; sample < numSamples; sample += audioFormat.channelCount()) {
|
for (int sample = 0; sample < numSamples; sample += audioFormat.channelCount()) {
|
||||||
|
@ -579,14 +579,12 @@ void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioF
|
||||||
for (int j = sample; j < sample + audioFormat.channelCount(); j++) {
|
for (int j = sample; j < sample + audioFormat.channelCount(); j++) {
|
||||||
if (j == sample) {
|
if (j == sample) {
|
||||||
// left channel
|
// left channel
|
||||||
int lResult = glm::clamp((int)(samplesData[j] * ((noEcho) ? 0.0f : dryFraction) +
|
int lResult = glm::clamp((int)(samplesData[j] * dryFraction + lValue * wetFraction),
|
||||||
lValue * wetFraction),
|
|
||||||
MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
||||||
samplesData[j] = (int16_t)lResult;
|
samplesData[j] = (int16_t)lResult;
|
||||||
} else if (j == (sample + 1)) {
|
} else if (j == (sample + 1)) {
|
||||||
// right channel
|
// right channel
|
||||||
int rResult = glm::clamp((int)(samplesData[j] * ((noEcho) ? 0.0f : dryFraction) +
|
int rResult = glm::clamp((int)(samplesData[j] * dryFraction + rValue * wetFraction),
|
||||||
rValue * wetFraction),
|
|
||||||
MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
|
||||||
samplesData[j] = (int16_t)rResult;
|
samplesData[j] = (int16_t)rResult;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue