diff --git a/include/engine/Engine.hpp b/include/engine/Engine.hpp index 47dc18ed..c6051836 100644 --- a/include/engine/Engine.hpp +++ b/include/engine/Engine.hpp @@ -58,6 +58,9 @@ struct Engine { int getStepFrames(); // Modules + size_t getNumModules(); + void getModuleIds(int* moduleIds, int len); + std::vector getModuleIds(); /** Adds a module to the rack engine. The module ID must not be taken by another module. If the module ID is -1, an ID is automatically assigned. diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 396364eb..0ec7d66b 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -559,6 +559,34 @@ int Engine::getStepFrames() { } +size_t Engine::getNumModules() { + return internal->modules.size(); +} + + +void Engine::getModuleIds(int* moduleIds, int len) { + SharedLock lock(internal->mutex); + int i = 0; + for (Module* m : internal->modules) { + if (i >= len) + break; + moduleIds[i] = m->id; + i++; + } +} + + +std::vector Engine::getModuleIds() { + SharedLock lock(internal->mutex); + std::vector moduleIds; + moduleIds.reserve(internal->modules.size()); + for (Module* m : internal->modules) { + moduleIds.push_back(m->id); + } + return moduleIds; +} + + void Engine::addModule(Module* module) { ExclusiveSharedLock lock(internal->mutex); assert(module);