Mute output audio if abnormal sample values detected

This commit is contained in:
xenakios 2018-08-21 12:17:34 +03:00
parent c691d6358d
commit fb710e0ec7

View File

@ -740,16 +740,24 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
buffer.addFrom(i, 0, m_input_buffer, i, 0, buffer.getNumSamples()); buffer.addFrom(i, 0, m_input_buffer, i, 0, buffer.getNumSamples());
} }
} }
bool abnordetected = false;
for (int i = 0; i < buffer.getNumChannels(); ++i) for (int i = 0; i < buffer.getNumChannels(); ++i)
{ {
for (int j = 0; j < buffer.getNumSamples(); ++j) for (int j = 0; j < buffer.getNumSamples(); ++j)
{ {
float sample = buffer.getSample(i,j); float sample = buffer.getSample(i,j);
if (std::isnan(sample) || std::isinf(sample)) if (std::isnan(sample) || std::isinf(sample))
{
++m_abnormal_output_samples; ++m_abnormal_output_samples;
abnordetected = true;
} }
} }
} }
if (abnordetected)
{
buffer.clear();
}
}
//============================================================================== //==============================================================================
bool PaulstretchpluginAudioProcessor::hasEditor() const bool PaulstretchpluginAudioProcessor::hasEditor() const