mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 04:27:57 +02:00
Removed the commented-out Gverb code
This commit is contained in:
parent
8ae3fa61c5
commit
1a7f06dc95
2 changed files with 2 additions and 115 deletions
|
@ -33,29 +33,6 @@
|
||||||
#include <QtMultimedia/QAudioInput>
|
#include <QtMultimedia/QAudioInput>
|
||||||
#include <QtMultimedia/QAudioOutput>
|
#include <QtMultimedia/QAudioOutput>
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#pragma warning (push)
|
|
||||||
#pragma warning (disable: 4273 4305)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <gverb/gverb.h>
|
|
||||||
#include <gverb/gverbdsp.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#pragma warning (pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <udt/PacketHeaders.h>
|
#include <udt/PacketHeaders.h>
|
||||||
#include <PositionalAudioStream.h>
|
#include <PositionalAudioStream.h>
|
||||||
|
@ -119,7 +96,6 @@ AudioClient::AudioClient() :
|
||||||
_audioSourceInjectEnabled(false),
|
_audioSourceInjectEnabled(false),
|
||||||
_reverb(false),
|
_reverb(false),
|
||||||
_reverbOptions(&_scriptReverbOptions),
|
_reverbOptions(&_scriptReverbOptions),
|
||||||
//_gverb(NULL),
|
|
||||||
_inputToNetworkResampler(NULL),
|
_inputToNetworkResampler(NULL),
|
||||||
_networkToOutputResampler(NULL),
|
_networkToOutputResampler(NULL),
|
||||||
_loopbackResampler(NULL),
|
_loopbackResampler(NULL),
|
||||||
|
@ -144,8 +120,6 @@ AudioClient::AudioClient() :
|
||||||
connect(updateTimer, &QTimer::timeout, this, &AudioClient::checkDevices);
|
connect(updateTimer, &QTimer::timeout, this, &AudioClient::checkDevices);
|
||||||
updateTimer->start(DEVICE_CHECK_INTERVAL_MSECS);
|
updateTimer->start(DEVICE_CHECK_INTERVAL_MSECS);
|
||||||
|
|
||||||
// create GVerb filter
|
|
||||||
//_gverb = createGverbFilter();
|
|
||||||
configureReverb();
|
configureReverb();
|
||||||
|
|
||||||
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
|
@ -159,10 +133,6 @@ AudioClient::AudioClient() :
|
||||||
|
|
||||||
AudioClient::~AudioClient() {
|
AudioClient::~AudioClient() {
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
//if (_gverb) {
|
|
||||||
// gverb_free(_gverb);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::reset() {
|
void AudioClient::reset() {
|
||||||
|
@ -172,8 +142,6 @@ void AudioClient::reset() {
|
||||||
_toneSource.reset();
|
_toneSource.reset();
|
||||||
_sourceGain.reset();
|
_sourceGain.reset();
|
||||||
_inputGain.reset();
|
_inputGain.reset();
|
||||||
|
|
||||||
//gverb_flush(_gverb);
|
|
||||||
_stereoReverb.reset();
|
_stereoReverb.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,29 +537,11 @@ bool AudioClient::switchOutputToAudioDevice(const QString& outputDeviceName) {
|
||||||
return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName));
|
return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//ty_gverb* AudioClient::createGverbFilter() {
|
|
||||||
// // Initialize a new gverb instance
|
|
||||||
// ty_gverb* filter = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(),
|
|
||||||
// _reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(),
|
|
||||||
// _reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(),
|
|
||||||
// _reverbOptions->getTailLevel());
|
|
||||||
//
|
|
||||||
// return filter;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void AudioClient::configureReverb() {
|
void AudioClient::configureReverb() {
|
||||||
// Configure the instance (these functions are not super well named - they actually set several internal variables)
|
|
||||||
//gverb_set_roomsize(filter, _reverbOptions->getRoomSize());
|
|
||||||
//gverb_set_revtime(filter, _reverbOptions->getReverbTime());
|
|
||||||
//gverb_set_damping(filter, _reverbOptions->getDamping());
|
|
||||||
//gverb_set_inputbandwidth(filter, _reverbOptions->getInputBandwidth());
|
|
||||||
//gverb_set_earlylevel(filter, DB_CO(_reverbOptions->getEarlyLevel()));
|
|
||||||
//gverb_set_taillevel(filter, DB_CO(_reverbOptions->getTailLevel()));
|
|
||||||
|
|
||||||
ReverbParameters p;
|
ReverbParameters p;
|
||||||
_stereoReverb.getParameters(&p);
|
_stereoReverb.getParameters(&p);
|
||||||
|
|
||||||
// for now, use the gverb settings
|
// for now, reuse the gverb parameters
|
||||||
p.sampleRate = _outputFormat.sampleRate();
|
p.sampleRate = _outputFormat.sampleRate();
|
||||||
p.roomSize = _reverbOptions->getRoomSize();
|
p.roomSize = _reverbOptions->getRoomSize();
|
||||||
p.reverbTime = _reverbOptions->getReverbTime();
|
p.reverbTime = _reverbOptions->getReverbTime();
|
||||||
|
@ -599,7 +549,7 @@ void AudioClient::configureReverb() {
|
||||||
p.bandwidth = 12000.0f * _reverbOptions->getInputBandwidth();
|
p.bandwidth = 12000.0f * _reverbOptions->getInputBandwidth();
|
||||||
//p.earlyGain = _reverbOptions->getEarlyLevel();
|
//p.earlyGain = _reverbOptions->getEarlyLevel();
|
||||||
//p.lateGain = _reverbOptions->getTailLevel();
|
//p.lateGain = _reverbOptions->getTailLevel();
|
||||||
p.wetDryMix = _shouldEchoLocally ? DB_CO(_reverbOptions->getWetLevel()) : 100.0f; // !_shouldEchoLocally apparently means 100% wet?
|
p.wetDryMix = _shouldEchoLocally ? powf(10.0f, _reverbOptions->getWetLevel() * (1/20.0f)) : 100.0f;
|
||||||
|
|
||||||
_stereoReverb.setParameters(&p);
|
_stereoReverb.setParameters(&p);
|
||||||
}
|
}
|
||||||
|
@ -614,7 +564,6 @@ void AudioClient::updateReverbOptions() {
|
||||||
}
|
}
|
||||||
if (_zoneReverbOptions.getWetLevel() != _receivedAudioStream.getWetLevel()) {
|
if (_zoneReverbOptions.getWetLevel() != _receivedAudioStream.getWetLevel()) {
|
||||||
_zoneReverbOptions.setWetLevel(_receivedAudioStream.getWetLevel());
|
_zoneReverbOptions.setWetLevel(_receivedAudioStream.getWetLevel());
|
||||||
// Not part of actual filter config, no need to set reverbChanged to true
|
|
||||||
reverbChanged = true;
|
reverbChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,8 +577,6 @@ void AudioClient::updateReverbOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reverbChanged) {
|
if (reverbChanged) {
|
||||||
//gverb_free(_gverb);
|
|
||||||
//_gverb = createGverbFilter();
|
|
||||||
configureReverb();
|
configureReverb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,7 +585,6 @@ void AudioClient::setReverb(bool reverb) {
|
||||||
_reverb = reverb;
|
_reverb = reverb;
|
||||||
|
|
||||||
if (!_reverb) {
|
if (!_reverb) {
|
||||||
//gverb_flush(_gverb);
|
|
||||||
_stereoReverb.reset();
|
_stereoReverb.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,50 +605,10 @@ void AudioClient::setReverbOptions(const AudioEffectOptions* options) {
|
||||||
|
|
||||||
if (_reverbOptions == &_scriptReverbOptions) {
|
if (_reverbOptions == &_scriptReverbOptions) {
|
||||||
// Apply them to the reverb instances
|
// Apply them to the reverb instances
|
||||||
//gverb_free(_gverb);
|
|
||||||
//_gverb = createGverbFilter();
|
|
||||||
configureReverb();
|
configureReverb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void AudioClient::addReverb(ty_gverb* gverb, int16_t* samplesData, int16_t* reverbAlone, int numSamples,
|
|
||||||
// QAudioFormat& audioFormat, bool noEcho) {
|
|
||||||
// float wetFraction = DB_CO(_reverbOptions->getWetLevel());
|
|
||||||
// float dryFraction = 1.0f - wetFraction;
|
|
||||||
//
|
|
||||||
// float lValue,rValue;
|
|
||||||
// for (int sample = 0; sample < numSamples; sample += audioFormat.channelCount()) {
|
|
||||||
// // Run GVerb
|
|
||||||
// float value = (float)samplesData[sample];
|
|
||||||
// gverb_do(gverb, value, &lValue, &rValue);
|
|
||||||
//
|
|
||||||
// // Mix, accounting for clipping, the left and right channels. Ignore the rest.
|
|
||||||
// for (int j = sample; j < sample + audioFormat.channelCount(); j++) {
|
|
||||||
// if (j == sample) {
|
|
||||||
// // left channel
|
|
||||||
// int lResult = glm::clamp((int)(samplesData[j] * dryFraction + lValue * wetFraction),
|
|
||||||
// AudioConstants::MIN_SAMPLE_VALUE, AudioConstants::MAX_SAMPLE_VALUE);
|
|
||||||
// samplesData[j] = (int16_t)lResult;
|
|
||||||
//
|
|
||||||
// if (noEcho) {
|
|
||||||
// reverbAlone[j] = (int16_t)lValue * wetFraction;
|
|
||||||
// }
|
|
||||||
// } else if (j == (sample + 1)) {
|
|
||||||
// // right channel
|
|
||||||
// int rResult = glm::clamp((int)(samplesData[j] * dryFraction + rValue * wetFraction),
|
|
||||||
// AudioConstants::MIN_SAMPLE_VALUE, AudioConstants::MAX_SAMPLE_VALUE);
|
|
||||||
// samplesData[j] = (int16_t)rResult;
|
|
||||||
//
|
|
||||||
// if (noEcho) {
|
|
||||||
// reverbAlone[j] = (int16_t)rValue * wetFraction;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// // ignore channels above 2
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
||||||
// If there is server echo, reverb will be applied to the recieved audio stream so no need to have it here.
|
// If there is server echo, reverb will be applied to the recieved audio stream so no need to have it here.
|
||||||
bool hasReverb = _reverb || _receivedAudioStream.hasReverb();
|
bool hasReverb = _reverb || _receivedAudioStream.hasReverb();
|
||||||
|
@ -733,30 +639,16 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
||||||
_loopbackResampler = new AudioSRC(_inputFormat.sampleRate(), _outputFormat.sampleRate(), channelCount);
|
_loopbackResampler = new AudioSRC(_inputFormat.sampleRate(), _outputFormat.sampleRate(), channelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static QByteArray reverbAlone; // Intermediary for local reverb with no echo
|
|
||||||
static QByteArray loopBackByteArray;
|
static QByteArray loopBackByteArray;
|
||||||
|
|
||||||
int numInputSamples = inputByteArray.size() / sizeof(int16_t);
|
int numInputSamples = inputByteArray.size() / sizeof(int16_t);
|
||||||
int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples);
|
int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples);
|
||||||
|
|
||||||
//reverbAlone.resize(numInputSamples * sizeof(int16_t));
|
|
||||||
loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t));
|
loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t));
|
||||||
|
|
||||||
int16_t* inputSamples = reinterpret_cast<int16_t*>(inputByteArray.data());
|
int16_t* inputSamples = reinterpret_cast<int16_t*>(inputByteArray.data());
|
||||||
//int16_t* reverbAloneSamples = reinterpret_cast<int16_t*>(reverbAlone.data());
|
|
||||||
int16_t* loopbackSamples = reinterpret_cast<int16_t*>(loopBackByteArray.data());
|
int16_t* loopbackSamples = reinterpret_cast<int16_t*>(loopBackByteArray.data());
|
||||||
|
|
||||||
//if (hasReverb) {
|
|
||||||
// updateGverbOptions();
|
|
||||||
// addReverb(_gverb, inputSamples, reverbAloneSamples, numInputSamples,
|
|
||||||
// _inputFormat, !_shouldEchoLocally);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//possibleResampling(_loopbackResampler,
|
|
||||||
// (_shouldEchoLocally) ? inputSamples : reverbAloneSamples, loopbackSamples,
|
|
||||||
// numInputSamples, numLoopbackSamples,
|
|
||||||
// _inputFormat, _outputFormat);
|
|
||||||
|
|
||||||
possibleResampling(_loopbackResampler,
|
possibleResampling(_loopbackResampler,
|
||||||
inputSamples, loopbackSamples,
|
inputSamples, loopbackSamples,
|
||||||
numInputSamples, numLoopbackSamples,
|
numInputSamples, numLoopbackSamples,
|
||||||
|
|
|
@ -75,8 +75,6 @@ class QAudioInput;
|
||||||
class QAudioOutput;
|
class QAudioOutput;
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
|
|
||||||
typedef struct ty_gverb ty_gverb;
|
|
||||||
|
|
||||||
|
|
||||||
class NLPacket;
|
class NLPacket;
|
||||||
|
|
||||||
|
@ -263,7 +261,6 @@ private:
|
||||||
AudioEffectOptions _scriptReverbOptions;
|
AudioEffectOptions _scriptReverbOptions;
|
||||||
AudioEffectOptions _zoneReverbOptions;
|
AudioEffectOptions _zoneReverbOptions;
|
||||||
AudioEffectOptions* _reverbOptions;
|
AudioEffectOptions* _reverbOptions;
|
||||||
//ty_gverb* _gverb;
|
|
||||||
AudioReverb _stereoReverb { AudioConstants::SAMPLE_RATE };
|
AudioReverb _stereoReverb { AudioConstants::SAMPLE_RATE };
|
||||||
|
|
||||||
// possible streams needed for resample
|
// possible streams needed for resample
|
||||||
|
@ -272,10 +269,8 @@ private:
|
||||||
AudioSRC* _loopbackResampler;
|
AudioSRC* _loopbackResampler;
|
||||||
|
|
||||||
// Adds Reverb
|
// Adds Reverb
|
||||||
//ty_gverb* createGverbFilter();
|
|
||||||
void configureReverb();
|
void configureReverb();
|
||||||
void updateReverbOptions();
|
void updateReverbOptions();
|
||||||
//void addReverb(ty_gverb* gverb, int16_t* samples, int16_t* reverbAlone, int numSamples, QAudioFormat& format, bool noEcho = false);
|
|
||||||
|
|
||||||
void handleLocalEchoAndReverb(QByteArray& inputByteArray);
|
void handleLocalEchoAndReverb(QByteArray& inputByteArray);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue