Skip to content

Commit

Permalink
mitigate looped playback issue
Browse files Browse the repository at this point in the history
some hosts resize the buffer at the turnaround point of the playback loop. This seemed to cause issues with the feedbackbuffer. To mitigate this issue for now the feedbackbuffer will only be summed to the input, if the buffersize is unchanged.
  • Loading branch information
greyboxaudio committed Sep 12, 2023
1 parent 6d91e0d commit 04bbd9e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void SG323AudioProcessorEditor::paint(juce::Graphics& g)

g.setColour(juce::Colours::white);
g.setFont(15.0f);
g.drawFittedText ("v0.6.3", getLocalBounds(), juce::Justification::bottomRight, 1);
g.drawFittedText ("v0.6.3_20230912a", getLocalBounds(), juce::Justification::bottomRight, 1);
}

void SG323AudioProcessorEditor::resized()
Expand Down
18 changes: 12 additions & 6 deletions source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ void SG323AudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::M
preEmphasis.process(juce::dsp::ProcessContextReplacing<float>(monoBlock));
inputHighPass.process(juce::dsp::ProcessContextReplacing<float>(monoBlock));
inputLowPass.process(juce::dsp::ProcessContextReplacing<float>(monoBlock));
// pre-process feedback buffer
feedBackHighPass.process(juce::dsp::ProcessContextReplacing<float>(feedbackBlock));
feedBackLowPass.process(juce::dsp::ProcessContextReplacing<float>(feedbackBlock));
feedBackDip.process(juce::dsp::ProcessContextReplacing<float>(feedbackBlock));
// sum input buffer & feedback buffer together
monoBuffer.addFrom(0, 0, feedbackBuffer, 0, 0, bufferSize);
// mitigation for looped playback
if (lastBufferSize == bufferSize)
{
// sum input buffer & feedback buffer together
monoBuffer.addFrom(0, 0, feedbackBuffer, 0, 0, bufferSize);
}
// round samples to 16bit values
for (int i = 0; i < bufferSize; ++i)
{
Expand Down Expand Up @@ -668,6 +668,12 @@ void SG323AudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::M
buffer.copyFromWithRamp(channel, 0, drySignal, bufferSize, dryLevel, dryLevel);
buffer.addFromWithRamp(channel, 0, wetSignal, bufferSize, mixLevel, mixLevel);
}
// pre-process feedback buffer
feedBackHighPass.process(juce::dsp::ProcessContextReplacing<float>(feedbackBlock));
feedBackLowPass.process(juce::dsp::ProcessContextReplacing<float>(feedbackBlock));
feedBackDip.process(juce::dsp::ProcessContextReplacing<float>(feedbackBlock));
// set lastBufferSize variable
lastBufferSize = bufferSize;
}

//==============================================================================
Expand Down
1 change: 1 addition & 0 deletions source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class SG323AudioProcessor : public juce::AudioProcessor
unsigned int gainModContBaseAddr{};
unsigned int gainModBaseAddr{};
unsigned int delayModBaseAddr{};
unsigned int lastBufferSize{};

float s1a0{ 1.0f };
float s1a1{ 1.0f };
Expand Down

0 comments on commit 04bbd9e

Please sign in to comment.