diff --git a/include/engine/Module.hpp b/include/engine/Module.hpp index da4045a0..49d16914 100644 --- a/include/engine/Module.hpp +++ b/include/engine/Module.hpp @@ -389,7 +389,7 @@ struct Module { float sampleRate; float sampleTime; }; - /** Called after the Engine sample rate changes. + /** Called when the Engine sample rate changes, and when the Module is added to the Engine. */ virtual void onSampleRateChange(const SampleRateChangeEvent& e) { // Call deprecated event method by default diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index e7279f7c..ce473eab 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -806,6 +806,11 @@ void Engine::addModule(Module* module) { // Dispatch AddEvent Module::AddEvent eAdd; module->onAdd(eAdd); + // Dispatch SampleRateChangeEvent + Module::SampleRateChangeEvent eSrc; + eSrc.sampleRate = internal->sampleRate; + eSrc.sampleTime = internal->sampleTime; + module->onSampleRateChange(eSrc); // Update ParamHandles' module pointers for (ParamHandle* paramHandle : internal->paramHandles) { if (paramHandle->moduleId == module->id)