Only set the sample rate, per block, and the worker in setEnable; don't recreate the synth
This commit is contained in:
parent
3d2ab24fa6
commit
5e40e31c83
1 changed files with 23 additions and 10 deletions
|
|
@ -46,6 +46,13 @@ tresult PLUGIN_API SfizzVstProcessor::initialize(FUnknown* context)
|
||||||
|
|
||||||
_state = SfizzVstState();
|
_state = SfizzVstState();
|
||||||
|
|
||||||
|
fprintf(stderr, "[sfizz] new synth\n");
|
||||||
|
_synth.reset(new sfz::Sfizz);
|
||||||
|
if (!_synth) {
|
||||||
|
fprintf(stderr, "[sfizz] Could not create synth!\n");
|
||||||
|
return kResultFalse;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,21 +112,27 @@ tresult PLUGIN_API SfizzVstProcessor::canProcessSampleSize(int32 symbolicSampleS
|
||||||
|
|
||||||
tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state)
|
tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state)
|
||||||
{
|
{
|
||||||
stopBackgroundWork();
|
sfz::Sfizz* synth = _synth.get();
|
||||||
_synth.reset();
|
|
||||||
|
if (!synth) {
|
||||||
|
fprintf(stderr, "[sfizz] Synth was destroyed? Trying to recreate...\n");
|
||||||
|
synth = new sfz::Sfizz;
|
||||||
|
if (!synth) {
|
||||||
|
fprintf(stderr, "[sfizz] Something is very wrong\n");
|
||||||
|
return kResultFalse;
|
||||||
|
}
|
||||||
|
_synth.reset(synth);
|
||||||
|
syncStateToSynth();
|
||||||
|
}
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
fprintf(stderr, "[Sfizz] new synth\n");
|
_synth->setSampleRate(processSetup.sampleRate);
|
||||||
sfz::Sfizz* synth = new sfz::Sfizz;
|
_synth->setSamplesPerBlock(processSetup.maxSamplesPerBlock);
|
||||||
_synth.reset(synth);
|
|
||||||
|
|
||||||
synth->setSampleRate(processSetup.sampleRate);
|
|
||||||
synth->setSamplesPerBlock(processSetup.maxSamplesPerBlock);
|
|
||||||
|
|
||||||
syncStateToSynth();
|
|
||||||
|
|
||||||
_workRunning = true;
|
_workRunning = true;
|
||||||
_worker = std::thread([this]() { doBackgroundWork(); });
|
_worker = std::thread([this]() { doBackgroundWork(); });
|
||||||
|
} else {
|
||||||
|
stopBackgroundWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
return kResultTrue;
|
return kResultTrue;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue