mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:49:27 +02:00
User separate gverb instance for local reverb
This commit is contained in:
parent
b48c2c2717
commit
5eac93dcfd
2 changed files with 19 additions and 6 deletions
|
@ -99,6 +99,7 @@ Audio::Audio(QObject* parent) :
|
||||||
_muted(false),
|
_muted(false),
|
||||||
_reverb(false),
|
_reverb(false),
|
||||||
_reverbOptions(&_scriptReverbOptions),
|
_reverbOptions(&_scriptReverbOptions),
|
||||||
|
_gverbLocal(NULL),
|
||||||
_gverb(NULL),
|
_gverb(NULL),
|
||||||
_iconColor(1.0f),
|
_iconColor(1.0f),
|
||||||
_iconPulseTimeReference(usecTimestampNow()),
|
_iconPulseTimeReference(usecTimestampNow()),
|
||||||
|
@ -504,12 +505,23 @@ bool Audio::switchOutputToAudioDevice(const QString& outputDeviceName) {
|
||||||
|
|
||||||
void Audio::initGverb() {
|
void Audio::initGverb() {
|
||||||
// Initialize a new gverb instance
|
// Initialize a new gverb instance
|
||||||
|
_gverbLocal = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(),
|
||||||
|
_reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(),
|
||||||
|
_reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(),
|
||||||
|
_reverbOptions->getTailLevel());
|
||||||
_gverb = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(),
|
_gverb = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(),
|
||||||
_reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(),
|
_reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(),
|
||||||
_reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(),
|
_reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(),
|
||||||
_reverbOptions->getTailLevel());
|
_reverbOptions->getTailLevel());
|
||||||
|
|
||||||
// Configure the instance (these functions are not super well named - they actually set several internal variables)
|
// Configure the instance (these functions are not super well named - they actually set several internal variables)
|
||||||
|
gverb_set_roomsize(_gverbLocal, _reverbOptions->getRoomSize());
|
||||||
|
gverb_set_revtime(_gverbLocal, _reverbOptions->getReverbTime());
|
||||||
|
gverb_set_damping(_gverbLocal, _reverbOptions->getDamping());
|
||||||
|
gverb_set_inputbandwidth(_gverbLocal, _reverbOptions->getInputBandwidth());
|
||||||
|
gverb_set_earlylevel(_gverbLocal, DB_CO(_reverbOptions->getEarlyLevel()));
|
||||||
|
gverb_set_taillevel(_gverbLocal, DB_CO(_reverbOptions->getTailLevel()));
|
||||||
|
|
||||||
gverb_set_roomsize(_gverb, _reverbOptions->getRoomSize());
|
gverb_set_roomsize(_gverb, _reverbOptions->getRoomSize());
|
||||||
gverb_set_revtime(_gverb, _reverbOptions->getReverbTime());
|
gverb_set_revtime(_gverb, _reverbOptions->getReverbTime());
|
||||||
gverb_set_damping(_gverb, _reverbOptions->getDamping());
|
gverb_set_damping(_gverb, _reverbOptions->getDamping());
|
||||||
|
@ -565,7 +577,7 @@ void Audio::setReverbOptions(const AudioEffectOptions* options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioFormat, bool noEcho) {
|
void Audio::addReverb(ty_gverb* gverb, int16_t* samplesData, int numSamples, QAudioFormat& audioFormat, bool noEcho) {
|
||||||
float wetFraction = DB_CO(_reverbOptions->getWetLevel());
|
float wetFraction = DB_CO(_reverbOptions->getWetLevel());
|
||||||
float dryFraction = (noEcho) ? 0.0f : (1.0f - wetFraction);
|
float dryFraction = (noEcho) ? 0.0f : (1.0f - wetFraction);
|
||||||
|
|
||||||
|
@ -573,7 +585,7 @@ void Audio::addReverb(int16_t* samplesData, int numSamples, QAudioFormat& audioF
|
||||||
for (int sample = 0; sample < numSamples; sample += audioFormat.channelCount()) {
|
for (int sample = 0; sample < numSamples; sample += audioFormat.channelCount()) {
|
||||||
// Run GVerb
|
// Run GVerb
|
||||||
float value = (float)samplesData[sample];
|
float value = (float)samplesData[sample];
|
||||||
gverb_do(_gverb, value, &lValue, &rValue);
|
gverb_do(gverb, value, &lValue, &rValue);
|
||||||
|
|
||||||
// Mix, accounting for clipping, the left and right channels. Ignore the rest.
|
// Mix, accounting for clipping, the left and right channels. Ignore the rest.
|
||||||
for (int j = sample; j < sample + audioFormat.channelCount(); j++) {
|
for (int j = sample; j < sample + audioFormat.channelCount(); j++) {
|
||||||
|
@ -627,7 +639,7 @@ void Audio::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
||||||
int16_t* loopbackSamples = reinterpret_cast<int16_t*>(loopBackByteArray.data());
|
int16_t* loopbackSamples = reinterpret_cast<int16_t*>(loopBackByteArray.data());
|
||||||
int numLoopbackSamples = loopBackByteArray.size() / sizeof(int16_t);
|
int numLoopbackSamples = loopBackByteArray.size() / sizeof(int16_t);
|
||||||
updateGverbOptions();
|
updateGverbOptions();
|
||||||
addReverb(loopbackSamples, numLoopbackSamples, _outputFormat, !hasEcho);
|
addReverb(_gverbLocal, loopbackSamples, numLoopbackSamples, _outputFormat, !hasEcho);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_loopbackOutputDevice) {
|
if (_loopbackOutputDevice) {
|
||||||
|
@ -1018,7 +1030,7 @@ void Audio::processReceivedSamples(const QByteArray& inputBuffer, QByteArray& ou
|
||||||
|
|
||||||
if(_reverb || _receivedAudioStream.hasReverb()) {
|
if(_reverb || _receivedAudioStream.hasReverb()) {
|
||||||
updateGverbOptions();
|
updateGverbOptions();
|
||||||
addReverb((int16_t*)outputBuffer.data(), numDeviceOutputSamples, _outputFormat);
|
addReverb(_gverb, (int16_t*)outputBuffer.data(), numDeviceOutputSamples, _outputFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,7 @@ private:
|
||||||
AudioEffectOptions _scriptReverbOptions;
|
AudioEffectOptions _scriptReverbOptions;
|
||||||
AudioEffectOptions _zoneReverbOptions;
|
AudioEffectOptions _zoneReverbOptions;
|
||||||
AudioEffectOptions* _reverbOptions;
|
AudioEffectOptions* _reverbOptions;
|
||||||
|
ty_gverb* _gverbLocal;
|
||||||
ty_gverb* _gverb;
|
ty_gverb* _gverb;
|
||||||
GLuint _micTextureId;
|
GLuint _micTextureId;
|
||||||
GLuint _muteTextureId;
|
GLuint _muteTextureId;
|
||||||
|
@ -269,7 +270,7 @@ private:
|
||||||
// Adds Reverb
|
// Adds Reverb
|
||||||
void initGverb();
|
void initGverb();
|
||||||
void updateGverbOptions();
|
void updateGverbOptions();
|
||||||
void addReverb(int16_t* samples, int numSamples, QAudioFormat& format, bool noEcho = false);
|
void addReverb(ty_gverb* gverb, int16_t* samples, int numSamples, QAudioFormat& format, bool noEcho = false);
|
||||||
|
|
||||||
void handleLocalEchoAndReverb(QByteArray& inputByteArray);
|
void handleLocalEchoAndReverb(QByteArray& inputByteArray);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue