mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Cleanup addReverb() code
This commit is contained in:
parent
f279030283
commit
17ce2e820f
1 changed files with 21 additions and 18 deletions
|
@ -658,6 +658,10 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
||||||
if (!_loopbackOutputDevice && _loopbackAudioOutput) {
|
if (!_loopbackOutputDevice && _loopbackAudioOutput) {
|
||||||
// we didn't have the loopback output device going so set that up now
|
// we didn't have the loopback output device going so set that up now
|
||||||
_loopbackOutputDevice = _loopbackAudioOutput->start();
|
_loopbackOutputDevice = _loopbackAudioOutput->start();
|
||||||
|
|
||||||
|
if (!_loopbackOutputDevice) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do we need to setup a resampler?
|
// do we need to setup a resampler?
|
||||||
|
@ -670,32 +674,31 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int numInputSamples = inputByteArray.size() / sizeof(int16_t);
|
static QByteArray reverbAlone; // Intermediary for local reverb with no echo
|
||||||
int16_t* inputSamples = reinterpret_cast<int16_t*>(inputByteArray.data());
|
static QByteArray loopBackByteArray;
|
||||||
|
|
||||||
static QByteArray reverbAlone;
|
int numInputSamples = inputByteArray.size() / sizeof(int16_t);
|
||||||
reverbAlone.resize(inputByteArray.size());
|
int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples);
|
||||||
|
|
||||||
|
reverbAlone.resize(numInputSamples * sizeof(int16_t));
|
||||||
|
loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t));
|
||||||
|
|
||||||
|
int16_t* inputSamples = reinterpret_cast<int16_t*>(inputByteArray.data());
|
||||||
int16_t* reverbAloneSamples = reinterpret_cast<int16_t*>(reverbAlone.data());
|
int16_t* reverbAloneSamples = reinterpret_cast<int16_t*>(reverbAlone.data());
|
||||||
|
int16_t* loopbackSamples = reinterpret_cast<int16_t*>(loopBackByteArray.data());
|
||||||
|
|
||||||
if (hasReverb) {
|
if (hasReverb) {
|
||||||
updateGverbOptions();
|
updateGverbOptions();
|
||||||
addReverb(_gverb, inputSamples, reverbAloneSamples, numInputSamples,
|
addReverb(_gverb, inputSamples, reverbAloneSamples, numInputSamples,
|
||||||
_outputFormat, !_shouldEchoLocally);
|
_inputFormat, !_shouldEchoLocally);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_loopbackOutputDevice) {
|
possibleResampling(_loopbackResampler,
|
||||||
static QByteArray loopBackByteArray;
|
(_shouldEchoLocally) ? inputSamples : reverbAloneSamples, loopbackSamples,
|
||||||
int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples);
|
numInputSamples, numLoopbackSamples,
|
||||||
loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t));
|
_inputFormat, _outputFormat);
|
||||||
|
|
||||||
possibleResampling(_loopbackResampler,
|
_loopbackOutputDevice->write(loopBackByteArray);
|
||||||
(_shouldEchoLocally) ? inputSamples : reverbAloneSamples,
|
|
||||||
reinterpret_cast<int16_t*>(loopBackByteArray.data()),
|
|
||||||
numInputSamples, numLoopbackSamples,
|
|
||||||
_inputFormat, _outputFormat);
|
|
||||||
|
|
||||||
_loopbackOutputDevice->write(loopBackByteArray);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::handleAudioInput() {
|
void AudioClient::handleAudioInput() {
|
||||||
|
|
Loading…
Reference in a new issue