Merge pull request #1115 from paulfd/fix-loads-and-saves
Fix 2 bugs in LV2 and VST3 for loads and stores
This commit is contained in:
commit
894bafc455
3 changed files with 16 additions and 8 deletions
|
|
@ -899,6 +899,7 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
|
||||||
(int)ev->time.frames,
|
(int)ev->time.frames,
|
||||||
(int)cc,
|
(int)cc,
|
||||||
value);
|
value);
|
||||||
|
self->cc_current[cc] = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LV2_MIDI_CTL_ALL_NOTES_OFF:
|
case LV2_MIDI_CTL_ALL_NOTES_OFF:
|
||||||
|
|
@ -1682,7 +1683,6 @@ save(LV2_Handle instance,
|
||||||
self->atom_int_uri,
|
self->atom_int_uri,
|
||||||
LV2_STATE_IS_POD);
|
LV2_STATE_IS_POD);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
|
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
|
||||||
if (desc.ccUsed.test(cc) && !desc.sustainOrSostenuto.test(cc)) {
|
if (desc.ccUsed.test(cc) && !desc.sustainOrSostenuto.test(cc)) {
|
||||||
LV2_URID urid = sfizz_lv2_ccmap_map(self->ccmap, int(cc));
|
LV2_URID urid = sfizz_lv2_ccmap_map(self->ccmap, int(cc));
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ tresult PLUGIN_API SfizzVstProcessor::initialize(FUnknown* context)
|
||||||
_synth->setBroadcastCallback(onMessage, this);
|
_synth->setBroadcastCallback(onMessage, this);
|
||||||
|
|
||||||
_currentStretchedTuning = 0.0;
|
_currentStretchedTuning = 0.0;
|
||||||
loadSfzFileOrDefault({});
|
loadSfzFileOrDefault({}, false);
|
||||||
|
|
||||||
_synth->bpmTempo(0, 120);
|
_synth->bpmTempo(0, 120);
|
||||||
_timeSigNumerator = 4;
|
_timeSigNumerator = 4;
|
||||||
|
|
@ -220,7 +220,7 @@ void SfizzVstProcessor::syncStateToSynth()
|
||||||
if (!synth)
|
if (!synth)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
loadSfzFileOrDefault(_state.sfzFile);
|
loadSfzFileOrDefault(_state.sfzFile, true);
|
||||||
synth->setVolume(_state.volume);
|
synth->setVolume(_state.volume);
|
||||||
synth->setNumVoices(_state.numVoices);
|
synth->setNumVoices(_state.numVoices);
|
||||||
synth->setOversamplingFactor(1 << _state.oversamplingLog2);
|
synth->setOversamplingFactor(1 << _state.oversamplingLog2);
|
||||||
|
|
@ -602,7 +602,7 @@ tresult PLUGIN_API SfizzVstProcessor::notify(Vst::IMessage* message)
|
||||||
|
|
||||||
std::unique_lock<SpinMutex> lock(_processMutex);
|
std::unique_lock<SpinMutex> lock(_processMutex);
|
||||||
_state.sfzFile.assign(static_cast<const char *>(data), size);
|
_state.sfzFile.assign(static_cast<const char *>(data), size);
|
||||||
loadSfzFileOrDefault(_state.sfzFile);
|
loadSfzFileOrDefault(_state.sfzFile, false);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
else if (!std::strcmp(id, "LoadScala")) {
|
else if (!std::strcmp(id, "LoadScala")) {
|
||||||
|
|
@ -717,7 +717,7 @@ void SfizzVstProcessor::receiveOSC(int delay, const char* path, const char* sig,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SfizzVstProcessor::loadSfzFileOrDefault(const std::string& filePath)
|
void SfizzVstProcessor::loadSfzFileOrDefault(const std::string& filePath, bool initParametersFromState)
|
||||||
{
|
{
|
||||||
sfz::Sfizz& synth = *_synth;
|
sfz::Sfizz& synth = *_synth;
|
||||||
|
|
||||||
|
|
@ -729,7 +729,6 @@ void SfizzVstProcessor::loadSfzFileOrDefault(const std::string& filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string descBlob = getDescriptionBlob(synth.handle());
|
const std::string descBlob = getDescriptionBlob(synth.handle());
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<absl::optional<float>> newControllers(sfz::config::numCCs);
|
std::vector<absl::optional<float>> newControllers(sfz::config::numCCs);
|
||||||
const std::vector<absl::optional<float>> oldControllers = std::move(_state.controllers);
|
const std::vector<absl::optional<float>> oldControllers = std::move(_state.controllers);
|
||||||
|
|
@ -739,6 +738,15 @@ void SfizzVstProcessor::loadSfzFileOrDefault(const std::string& filePath)
|
||||||
if (desc.ccUsed.test(cc))
|
if (desc.ccUsed.test(cc))
|
||||||
newControllers[cc] = desc.ccValue[cc];
|
newControllers[cc] = desc.ccValue[cc];
|
||||||
}
|
}
|
||||||
|
// set CC from existing state
|
||||||
|
if (initParametersFromState) {
|
||||||
|
for (uint32 cc = 0; cc < sfz::config::numCCs; ++cc) {
|
||||||
|
if (absl::optional<float> value = oldControllers[cc]) {
|
||||||
|
newControllers[cc] = *value;
|
||||||
|
synth.automateHdcc(0, int(cc), *value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_state.controllers = std::move(newControllers);
|
_state.controllers = std::move(newControllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -841,7 +849,7 @@ void SfizzVstProcessor::doBackgroundIdle(size_t idleCounter)
|
||||||
if (_synth->shouldReloadFile()) {
|
if (_synth->shouldReloadFile()) {
|
||||||
fprintf(stderr, "[Sfizz] sfz file has changed, reloading\n");
|
fprintf(stderr, "[Sfizz] sfz file has changed, reloading\n");
|
||||||
std::lock_guard<SpinMutex> lock(_processMutex);
|
std::lock_guard<SpinMutex> lock(_processMutex);
|
||||||
loadSfzFileOrDefault(_state.sfzFile);
|
loadSfzFileOrDefault(_state.sfzFile, false);
|
||||||
}
|
}
|
||||||
if (_synth->shouldReloadScala()) {
|
if (_synth->shouldReloadScala()) {
|
||||||
fprintf(stderr, "[Sfizz] scala file has changed, reloading\n");
|
fprintf(stderr, "[Sfizz] scala file has changed, reloading\n");
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ private:
|
||||||
void receiveOSC(int delay, const char* path, const char* sig, const sfizz_arg_t* args);
|
void receiveOSC(int delay, const char* path, const char* sig, const sfizz_arg_t* args);
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
void loadSfzFileOrDefault(const std::string& filePath);
|
void loadSfzFileOrDefault(const std::string& filePath, bool initParametersFromState);
|
||||||
|
|
||||||
// note event tracking
|
// note event tracking
|
||||||
std::array<float, 128> _noteEventsCurrentCycle; // 0: off, >0: on, <0: no change
|
std::array<float, 128> _noteEventsCurrentCycle; // 0: off, >0: on, <0: no change
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue