Hey again
Yeah there are a lot of example in the rack code for sure. Personally I think it has gotten a lot harder to understand the code since polyphony has been introduced. I mean I love then functionality. no doubt, but I think it gets a bit hard to understand at times.
But the thing is, I have the functionality I’d like. It works in the the process block, as I like. But I just can’t get it to work outside of the process block, in a function or a struct.
I managed to build a very simple struct/class, with a member function. I tested I can get in/output of the struct, by passing the gate trough, with nothing done to it. What comes in comes out of the member function.
But the issue is still the same with the counter, which is inside the member function. The counter just still wont count the same it does in process block. It just outputs 0 1 0 1 0 1, on each input gate, no matter what I do, instead of counting 1,2,3,4,5.etc… til i stop the gate input.
It’s nice that I learned how to make a struct/class, with members, but anything time based, like a counter, just don’t work. I am obviously missing something important.
My struct looks like this, in my functions.hpp file:
struct PulseG{
public:
bool Trigger;
int Count = 0;
int Pulse(){
if(Trigger > 0){
Count = Count+1;
}
return Count; // Output of member function
}
};
In the process block:
PulseG Pulse1; // Declare struct and create a version of PulseG
Pulse1.Trigger = inputs[TEST2_INPUT].getVoltage(); // Gate in
outputs[SINE_OUTPUT].setVoltage(Pulse1.Pulse()); // Return of Pulse member
This should make the counter go every time it get a gate high on the input. But counter just goes 1,0,1,0,1,0,etc, when it gets a gate input. Only changes on input change, it doesn’t go on, like in main process.
It’s almost like time doesn’t exists in the struct or function, it only does something when an input is applied, the counter doesn’t run same way, on it’s own, as in the process block.
So turning it into a struct didn’t do the trick either. Counter still doesn’t run at samplerate.