diff --git a/src/engine/group.h b/src/engine/group.h index 6075fece..09484d61 100644 --- a/src/engine/group.h +++ b/src/engine/group.h @@ -103,6 +103,7 @@ struct Group : MoveableOnly, size_t addZone(std::unique_ptr &z) { z->parentGroup = this; + z->engine = getEngine(); zones.push_back(std::move(z)); return zones.size(); } @@ -110,6 +111,7 @@ struct Group : MoveableOnly, size_t addZone(std::unique_ptr &&z) { z->parentGroup = this; + z->engine = getEngine(); zones.push_back(std::move(z)); return zones.size(); } diff --git a/src/engine/zone.cpp b/src/engine/zone.cpp index 9b65c96a..0317ef06 100644 --- a/src/engine/zone.cpp +++ b/src/engine/zone.cpp @@ -188,20 +188,6 @@ void Zone::clearNormalizedSampleLevel(const int associatedSampleID) } } -engine::Engine *Zone::getEngine() -{ - if (parentGroup && parentGroup->parentPart && parentGroup->parentPart->parentPatch) - return parentGroup->parentPart->parentPatch->parentEngine; - return nullptr; -} - -const engine::Engine *Zone::getEngine() const -{ - if (parentGroup && parentGroup->parentPart && parentGroup->parentPart->parentPatch) - return parentGroup->parentPart->parentPatch->parentEngine; - return nullptr; -} - void Zone::initialize() { for (auto &v : voiceWeakPointers) diff --git a/src/engine/zone.h b/src/engine/zone.h index 173ff489..698a7885 100644 --- a/src/engine/zone.h +++ b/src/engine/zone.h @@ -249,8 +249,17 @@ struct Zone : MoveableOnly, HasGroupZoneProcessors, SampleRateSuppor void onProcessorTypeChanged(int, dsp::processor::ProcessorType) {} void setupOnUnstream(const engine::Engine &e); - engine::Engine *getEngine(); - const engine::Engine *getEngine() const; + engine::Engine *engine{nullptr}; + engine::Engine *getEngine() + { + assert(engine); + return engine; + } + const engine::Engine *getEngine() const + { + assert(engine); + return engine; + } sst::basic_blocks::dsp::UIComponentLagHandler mUILag; void onSampleRateChanged() override;