Instantiate new gate with the correct number of channels

This commit is contained in:
Ken Cooke 2017-05-23 08:40:15 -07:00
parent 746b41e509
commit 71de3d5ca1
2 changed files with 10 additions and 0 deletions

View file

@ -1415,6 +1415,10 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn
delete _inputToNetworkResampler;
_inputToNetworkResampler = NULL;
}
if (_audioGate) {
delete _audioGate;
_audioGate = nullptr;
}
if (!inputDeviceInfo.isNull()) {
qCDebug(audioclient) << "The audio input device " << inputDeviceInfo.deviceName() << "is available.";
@ -1440,6 +1444,10 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn
qCDebug(audioclient) << "No resampling required for audio input to match desired network format.";
}
// the audio gate runs after the resampler
_audioGate = new AudioGate(_desiredInputFormat.sampleRate(), _desiredInputFormat.channelCount());
qCDebug(audioclient) << "Noise gate created with" << _desiredInputFormat.channelCount() << "channels.";
// if the user wants stereo but this device can't provide then bail
if (!_isStereoInput || _inputFormat.channelCount() == 2) {
_audioInput = new QAudioInput(inputDeviceInfo, _inputFormat, this);

View file

@ -46,6 +46,7 @@
#include <AudioLimiter.h>
#include <AudioConstants.h>
#include <AudioNoiseGate.h>
#include <AudioGate.h>
#include <shared/RateCounter.h>
@ -361,6 +362,7 @@ private:
AudioIOStats _stats;
AudioNoiseGate _noiseGate;
AudioGate* _audioGate { nullptr };
AudioPositionGetter _positionGetter;
AudioOrientationGetter _orientationGetter;