Skip to content

Commit

Permalink
Vitalium: Notify host of changed parameters on patch load.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRTA committed Apr 17, 2024
1 parent 5c55f94 commit b130fe7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ports-juce6.0/vitalium/source/common/synth_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,41 @@ void SynthBase::loadTuningFile(const File& file) {

void SynthBase::loadInitPreset() {
pauseProcessing(true);

auto old_values = std::map<std::string, float>();
for (auto i = controls_.begin(); i != controls_.end(); i++) {
old_values.insert(std::pair<std::string, float>(i->first, i->second->value()));
}

engine_->allSoundsOff();
initEngine();
LoadSave::initSaveInfo(save_info_);

for (auto i = controls_.begin(); i != controls_.end(); i++) {
if (old_values.count(i->first) && old_values[i->first] != i->second->value()) {
setValueNotifyHost(i->first, i->second->value());
}
}

pauseProcessing(false);
}

bool SynthBase::loadFromJson(const json& data) {
pauseProcessing(true);

auto old_values = std::map<std::string, float>();
for (auto i = controls_.begin(); i != controls_.end(); i++) {
old_values.insert(std::pair<std::string, float>(i->first, i->second->value()));
}

engine_->allSoundsOff();
try {
bool result = LoadSave::jsonToState(this, save_info_, data);
for (auto i = controls_.begin(); i != controls_.end(); i++) {
if (old_values.count(i->first) && old_values[i->first] != i->second->value()) {
setValueNotifyHost(i->first, i->second->value());
}
}
pauseProcessing(false);
return result;
}
Expand Down

0 comments on commit b130fe7

Please sign in to comment.