Skip to content

Commit

Permalink
FX Mode handles block mod buffers better
Browse files Browse the repository at this point in the history
In the event we are in non-latent mode and our buffer is
not a multiple of block size, then

1: reset the inputs and outputs
2: Enter latent mode
3: set latency and
4: inform the host of a latency change

Addresses surge-synthesizer#6638 but some testing before we close it would be
super.
  • Loading branch information
baconpaul committed Mar 3, 2023
1 parent 6ad105a commit 51a8500
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/surge-fx/SurgeFXProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,20 @@ void SurgefxAudioProcessor::processBlock(juce::AudioBuffer<float> &buffer,
resetFxParams(true);
}

auto sampl = buffer.getNumSamples();
if (nonLatentBlockMode && ((sampl & ~(BLOCK_SIZE-1)) != sampl))
{
nonLatentBlockMode = false;
input_position = 0;
output_position = 0;
memset(output_buffer, 0, sizeof(output_buffer));
memset(input_buffer, 0, sizeof(input_buffer));
memset(sidechain_buffer, 0, sizeof(sidechain_buffer));

setLatencySamples(BLOCK_SIZE);
updateHostDisplay(ChangeDetails().withLatencyChanged(true));
}

auto mainInput = getBusBuffer(buffer, true, 0);

int inChanL = 0;
Expand Down
1 change: 1 addition & 0 deletions src/surge-fx/SurgeFXProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SurgefxAudioProcessor : public juce::AudioProcessor,
int output_position{-1};

bool nonLatentBlockMode{true};

//==============================================================================
void prepareToPlay(double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
Expand Down

0 comments on commit 51a8500

Please sign in to comment.