Welcome to %s forums

BrainModular Users Forum

Login Register

how to correctly pass parameters into module

Create your own modules in C++
Post Reply
drakh
Member
Posts: 198
Location: Bratislava, SK
Contact:

Unread post by drakh » 13 Apr 2018, 10:33

Here is a linkt to image for one patch

https://drive.google.com/file/d/1-V7NsB ... sp=sharing

tehere are three identical patches, each one using my module "Advanced euclidean generator" ( the code is abialable here https://github.com/drakh/Hollyhock-Modu ... nGenerator )

Now the problem.

when i change input value for one module for example - "beats" this input value is changed in each module in the workspace you can see it in linked screenshot - i changed beats and accetns in first patch, then clicked to generate in each of those other patches, and the output is the same for each instance of the module.

When i will change for example "accents" in the middle patch to "3" and then i generate the sequence for each module, each module will output 3 ticks in accents array.

I know that HH SDK modules shares memory, so the question is how to fill those data in .cpp that each instance of the module will have its "own" input parameters

thank you

drakh
Member
Posts: 198
Location: Bratislava, SK
Contact:

Unread post by drakh » 13 Apr 2018, 10:35

when you take a look at
https://github.com/drakh/Hollyhock-Modu ... erator.cpp

those needed parameters sits on lines 8-10, so the question is where to put them that thay will be "private" for each instance of the module

sm_jamieson
Member
Posts: 551
Contact:

Unread post by sm_jamieson » 13 Apr 2018, 10:47

drakh wrote:when you take a look at
https://github.com/drakh/Hollyhock-Modu ... erator.cpp

those needed parameters sits on lines 8-10, so the question is where to put them that thay will be "private" for each instance of the module
As you have found, the thing that is unique to an instance of the module is the class. At least on windows, anything else will be shared by all intances of the module. I don't know if user modules on MAC behave the same way.

So you put the parameters in the class where you put the events, e.g.

class AdvancedEuclideanGenerator : public UserModuleBase
{
public:
AdvancedEuclideanGenerator(){};
virtual ~AdvancedEuclideanGenerator(){};
public:
void onGetModuleInfo (MasterInfo* pMasterInfo, ModuleInfo* pModuleInfo);
void onInitModule (MasterInfo* pMasterInfo, ModuleInfo* pModuleInfo);
void onGetParamInfo (int ParamIndex, TParamInfo* pParamInfo);
void onCallBack (UsineMessage *Message);
private:
//-------------------------------------------------------------------------
// parameters events
UsineEventPtr dtfInputSteps;
UsineEventPtr dtfInputBeats;
UsineEventPtr dtfInputAccents;
UsineEventPtr dtfInputGenerate;
UsineEventPtr dftBeatsOut;
UsineEventPtr dftAccentsOut;
inline void updateCellsValues();

int steps = 16;
int beats = 0;
int accents = 0;
};

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests