Skip to content

Commit

Permalink
Merge pull request #24684 from RomanPudashkin/vst_audio_glitch_fix_442
Browse files Browse the repository at this point in the history
vst_audio_glitch_fix_442
  • Loading branch information
RomanPudashkin authored Sep 13, 2024
2 parents b8dd18a + a1b9d9d commit 3130f97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/framework/vst/internal/synth/vstsynthesiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ samples_t VstSynthesiser::process(float* buffer, samples_t samplesPerChannel)
return 0;
}

if (samplesPerChannel > m_vstAudioClient->maxSamplesPerBlock()) {
m_vstAudioClient->setMaxSamplesPerBlock(samplesPerChannel);
}

const msecs_t nextMsecs = samplesToMsecs(samplesPerChannel, m_sampleRate);
const VstSequencer::EventSequenceMap sequences = m_sequencer.movePlaybackForward(nextMsecs);
samples_t sampleOffset = 0;
Expand Down
9 changes: 7 additions & 2 deletions src/framework/vst/internal/vstaudioclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,18 @@ void VstAudioClient::allNotesOff()
m_playingParams.clear();
}

void VstAudioClient::setMaxSamplesPerBlock(unsigned int samples)
samples_t VstAudioClient::maxSamplesPerBlock() const
{
return m_samplesInfo.maxSamplesPerBlock;
}

void VstAudioClient::setMaxSamplesPerBlock(samples_t samples)
{
if (m_samplesInfo.maxSamplesPerBlock == samples) {
return;
}

m_processData.numSamples = samples;
m_processData.numSamples = static_cast<Steinberg::int32>(samples);
m_samplesInfo.maxSamplesPerBlock = samples;
m_needUnprepareProcessData = true;

Expand Down
6 changes: 4 additions & 2 deletions src/framework/vst/internal/vstaudioclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ class VstAudioClient
void flush();
void allNotesOff();

void setMaxSamplesPerBlock(unsigned int samples);
audio::samples_t maxSamplesPerBlock() const;
void setMaxSamplesPerBlock(audio::samples_t samples);

void setSampleRate(unsigned int sampleRate);

ParamsMapping paramsMapping(const std::set<Steinberg::Vst::CtrlNumber>& controllers) const;

private:
struct SamplesInfo {
unsigned int sampleRate = 0;
unsigned int maxSamplesPerBlock = 0;
audio::samples_t maxSamplesPerBlock = 0;

bool isValid()
{
Expand Down

0 comments on commit 3130f97

Please sign in to comment.