Skip to content

Commit a1b9d9d

Browse files
fixed an audio glitch at the first note in exported mp3 file
Update the max samples per block for all sequences (rather than in each process call)
1 parent 39af7f6 commit a1b9d9d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/framework/vst/internal/synth/vstsynthesiser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ samples_t VstSynthesiser::process(float* buffer, samples_t samplesPerChannel)
199199
return 0;
200200
}
201201

202+
if (samplesPerChannel > m_vstAudioClient->maxSamplesPerBlock()) {
203+
m_vstAudioClient->setMaxSamplesPerBlock(samplesPerChannel);
204+
}
205+
202206
const msecs_t nextMsecs = samplesToMsecs(samplesPerChannel, m_sampleRate);
203207
const VstSequencer::EventSequenceMap sequences = m_sequencer.movePlaybackForward(nextMsecs);
204208
samples_t sampleOffset = 0;

src/framework/vst/internal/vstaudioclient.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,18 @@ void VstAudioClient::allNotesOff()
210210
m_playingParams.clear();
211211
}
212212

213-
void VstAudioClient::setMaxSamplesPerBlock(unsigned int samples)
213+
samples_t VstAudioClient::maxSamplesPerBlock() const
214+
{
215+
return m_samplesInfo.maxSamplesPerBlock;
216+
}
217+
218+
void VstAudioClient::setMaxSamplesPerBlock(samples_t samples)
214219
{
215220
if (m_samplesInfo.maxSamplesPerBlock == samples) {
216221
return;
217222
}
218223

219-
m_processData.numSamples = samples;
224+
m_processData.numSamples = static_cast<Steinberg::int32>(samples);
220225
m_samplesInfo.maxSamplesPerBlock = samples;
221226
m_needUnprepareProcessData = true;
222227

src/framework/vst/internal/vstaudioclient.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ class VstAudioClient
4747
void flush();
4848
void allNotesOff();
4949

50-
void setMaxSamplesPerBlock(unsigned int samples);
50+
audio::samples_t maxSamplesPerBlock() const;
51+
void setMaxSamplesPerBlock(audio::samples_t samples);
52+
5153
void setSampleRate(unsigned int sampleRate);
5254

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

5557
private:
5658
struct SamplesInfo {
5759
unsigned int sampleRate = 0;
58-
unsigned int maxSamplesPerBlock = 0;
60+
audio::samples_t maxSamplesPerBlock = 0;
5961

6062
bool isValid()
6163
{

0 commit comments

Comments
 (0)