Hello,
I wanted to do a polyphonic sound with each voice panned differently. With the patch/polyindex object I can get access to the current voice number. But how do I get access to the total number of voices? Looking at the C++-Code generated, I can't see where this info would be available. voice.polyIndex
gives the voice number but the only place that actually contains the total number of voices are a bunch of arrays (e.g. int8_t notePlaying[8];
and int32_t voicePriority[8];
) and a bunch of other places, including this loop:
public: void Init(rootc * _parent) {
[..]
int vi; for(vi=0;vi<8;vi++) {
voice *v = &getVoices()[vi];
v->polyIndex = vi;
v->common = this;
v->Init(&getVoices()[vi]);
[..]
The upper limit (in my example: 8) is hardcoded into this loop and I don't see how I could access this information.
My idea to work around this was to create a polyCount
object that has some sort of shared variable in it that each of the instantiated voices increases by one. However, that doesn't work as none of the code segments (local data, init, krate, srate, dispose) allow to declare such a shared type. I can have a static uint8_t counter = 0
in the local data section, but that inline initializer doesn't compile with ISO C++, so it doesn't work. My last idea was to use C-style linkage but then it would not be possible to have multiple polyphonic subpatches in a main patch.
So... I'm starting to guess that there might be a preprocessor statement or some sort of placeholder that I can use in the code instead. Is there something like this?
Thanks!