Skip to content
Snippets Groups Projects
Commit 2169872e authored by Josh Siegle's avatar Josh Siegle
Browse files

Add check for buffer overrun in AudioNode

parent 13650eea
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@
<ProgramDataBaseFileName>$(IntDir)\</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
......
......@@ -336,7 +336,7 @@ void AudioNode::process(AudioSampleBuffer& buffer,
// std::cout << "Samples remaining in incoming buffer: " << orphanedSamples << std::endl;
if (orphanedSamples > 0)
if (orphanedSamples > 0 && (samplesInBackupBuffer + orphanedSamples < backupBuffer->getNumSamples()))
{
backupBuffer->addFrom(0, // destination channel
samplesInBackupBuffer, // destination start sample
......@@ -356,7 +356,11 @@ void AudioNode::process(AudioSampleBuffer& buffer,
gain // gain to apply
);
}
}
else {
samplesInBackupBuffer = 0; // just throw out the buffer in the case of an overrun
// not ideal, but the output still sounds fine
}
// Simple implementation of a "noise gate" on audio output
expander.process(buffer.getWritePointer(0), // left channel
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment