SynthLab SDK
DynamicModuleManager Class Reference

This object maintains a set of SynthLab-DM Dynamic Modules. More...

#include <synthlabdm.h>

Public Member Functions

 DynamicModuleManager ()
 empty constructor
 
virtual ~DynamicModuleManager ()
 virtual deleter More...
 
bool loadDMConfig (std::string folderPath, SynthLab::DMConfig &config)
 Loads the DM configuration from the config.txt file; if the file does not exist, the default config is used. More...
 
void setConfigData (std::string fileline, SynthLab::DMConfig &config)
 Sets the DM configuration booleans from the config.txt file; if the file does not exist, the default config is used.
 
uint32_t loadAllDynamicModulesInFolder (std::string folderPath)
 Opens a folder and loads all of the modules it finds in succession. More...
 
uint32_t loadAllDynamicModulesInSubFolder (std::string folderPath)
 Opens a folder and loads all of the modules it finds in succession. More...
 
uint32_t loadDynamicModule (std::string modulePath)
 Tries to load a DLL or dylib. More...
 
void addLoadableModule (uint32_t module)
 
bool haveDynamicModules ()
 
std::vector< std::shared_ptr< SynthLab::ModuleCore > > getDynamicModules ()
 
uint32_t getModuleCountForType (uint32_t type)
 
void setDoubleOscillators (bool b)
 

Protected Attributes

std::vector< std::shared_ptr< SynthLab::ModuleCore > > modules
 set of pointers fo modules
 
std::vector< uint32_t > loadableModules
 set of module types that may be loaded in this synth; see synthconstants.h e.g. LFO_MODULE
 
bool doubleOscillatorSet = false
 

Detailed Description

This object maintains a set of SynthLab-DM Dynamic Modules.

  • creates the module from a DLL or dylib file
  • maintains a vector of shared pointers to modules
  • includes the module deleter function that is needed for the shared pointers and that is called when the pointer's ref count hits zero; this function is NOT a member function
  • used in conjunction with the ModuleGetter object
  • note: not namespaced for generalized use
Author
Will Pirkle http://www.willpirkle.com
Remarks
This object is included and described in further detail in Designing Software Synthesizer Plugins in C++ 2nd Ed. by Will Pirkle
Version
Revision : 1.0
Date
Date : 2021 / 04 / 26

Constructor & Destructor Documentation

◆ ~DynamicModuleManager()

DynamicModuleManager::~DynamicModuleManager ( )
virtual

virtual deleter

The destructor clears out the shared pointers, that delete themselves just afterwards.

  • in a proper implementation, this will be the last object that owns a shared pointer just prior to self-destruction

Member Function Documentation

◆ haveDynamicModules()

bool DynamicModuleManager::haveDynamicModules ( )
inline

query functions

◆ loadAllDynamicModulesInFolder()

uint32_t DynamicModuleManager::loadAllDynamicModulesInFolder ( std::string  folderPath)

Opens a folder and loads all of the modules it finds in succession.

  • uses the loadableModules list as a mechanism for deciding if an object should be loaded. This is mainly for the different oscillator objects.
  • there are two parts to the function for Windows and MacOS
  • ultimately calls the loadDynamicModule( ) function that does the DLL load
  • this function can be called more than once to append the list of modules but that is not done in SynthLab

\ param folderPath the fully qualified path to the folder

Returns
the number of dynamic modules that were loaded

◆ loadAllDynamicModulesInSubFolder()

uint32_t DynamicModuleManager::loadAllDynamicModulesInSubFolder ( std::string  folderPath)

Opens a folder and loads all of the modules it finds in succession.

  • uses the loadableModules list as a mechanism for deciding if an object should be loaded. This is mainly for the different oscillator objects.
  • there are two parts to the function for Windows and MacOS
  • ultimately calls the loadDynamicModule( ) function that does the DLL load
  • this function can be called more than once to append the list of modules but that is not done in SynthLab

\ param folderPath the fully qualified path to the folder

Returns
the number of dynamic modules that were loaded

◆ loadDMConfig()

bool DynamicModuleManager::loadDMConfig ( std::string  folderPath,
SynthLab::DMConfig config 
)

Loads the DM configuration from the config.txt file; if the file does not exist, the default config is used.

loading functions

◆ loadDynamicModule()

uint32_t DynamicModuleManager::loadDynamicModule ( std::string  modulePath)

Tries to load a DLL or dylib.

  • loads the module
  • them, checks the loadableModules list to make sure this is a legal module for the synth
  • if loadable it stores the pointer
  • if not loadable, it simply returns; the smart pointer will delete itself when the function returns

\ param modulePath the fully qualified path to the DLL or dylib file

Returns
number of modules loaded, or 0 if not loaded

The documentation for this class was generated from the following files: