mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:28:03 +02:00
clean AudioNoiseGate
This commit is contained in:
parent
0abcda86a8
commit
f43706dfe1
2 changed files with 13 additions and 36 deletions
|
@ -19,19 +19,13 @@
|
||||||
const float AudioNoiseGate::CLIPPING_THRESHOLD = 0.90f;
|
const float AudioNoiseGate::CLIPPING_THRESHOLD = 0.90f;
|
||||||
|
|
||||||
AudioNoiseGate::AudioNoiseGate() :
|
AudioNoiseGate::AudioNoiseGate() :
|
||||||
_inputBlockCounter(0),
|
|
||||||
_lastLoudness(0.0f),
|
_lastLoudness(0.0f),
|
||||||
_quietestBlock(std::numeric_limits<float>::max()),
|
|
||||||
_loudestBlock(0.0f),
|
|
||||||
_didClipInLastBlock(false),
|
_didClipInLastBlock(false),
|
||||||
_dcOffset(0.0f),
|
_dcOffset(0.0f),
|
||||||
_measuredFloor(0.0f),
|
_measuredFloor(0.0f),
|
||||||
_sampleCounter(0),
|
_sampleCounter(0),
|
||||||
_isOpen(false),
|
_isOpen(false),
|
||||||
_blocksToClose(0)
|
_blocksToClose(0) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioNoiseGate::removeDCOffset(int16_t* samples, int numSamples) {
|
void AudioNoiseGate::removeDCOffset(int16_t* samples, int numSamples) {
|
||||||
//
|
//
|
||||||
|
@ -104,20 +98,6 @@ void AudioNoiseGate::gateSamples(int16_t* samples, int numSamples) {
|
||||||
|
|
||||||
_lastLoudness = fabs(loudness / numSamples);
|
_lastLoudness = fabs(loudness / numSamples);
|
||||||
|
|
||||||
if (_quietestBlock > _lastLoudness) {
|
|
||||||
_quietestBlock = _lastLoudness;
|
|
||||||
}
|
|
||||||
if (_loudestBlock < _lastLoudness) {
|
|
||||||
_loudestBlock = _lastLoudness;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int FRAMES_FOR_NOISE_DETECTION = 400;
|
|
||||||
if (_inputBlockCounter++ > FRAMES_FOR_NOISE_DETECTION) {
|
|
||||||
_quietestBlock = std::numeric_limits<float>::max();
|
|
||||||
_loudestBlock = 0.0f;
|
|
||||||
_inputBlockCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If Noise Gate is enabled, check and turn the gate on and off
|
// If Noise Gate is enabled, check and turn the gate on and off
|
||||||
float averageOfAllSampleBlocks = 0.0f;
|
float averageOfAllSampleBlocks = 0.0f;
|
||||||
_sampleBlocks[_sampleCounter++] = _lastLoudness;
|
_sampleBlocks[_sampleCounter++] = _lastLoudness;
|
||||||
|
|
|
@ -33,10 +33,7 @@ public:
|
||||||
static const float CLIPPING_THRESHOLD;
|
static const float CLIPPING_THRESHOLD;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _inputBlockCounter;
|
|
||||||
float _lastLoudness;
|
float _lastLoudness;
|
||||||
float _quietestBlock;
|
|
||||||
float _loudestBlock;
|
|
||||||
bool _didClipInLastBlock;
|
bool _didClipInLastBlock;
|
||||||
float _dcOffset;
|
float _dcOffset;
|
||||||
float _measuredFloor;
|
float _measuredFloor;
|
||||||
|
|
Loading…
Reference in a new issue