Genexpr parameter variable name
Hello! I am struggling with the codbox in mc.gen~.
Is there any possibility to make such a statement of the parameter that it's name changes according to the channel number it is operating in? For example I have:
Param X_modulation(0);
where X stands for 1, 2, 3, 4... depending on the channel the code operate in.
Thank you!
after thinking more about this and the other thread, what might work better is if you do away with mc, and just put gen~ within poly~, and instead of 'param', use full signal inlets, but within the outer poly~ voice, have 'receive~' objects which are dynamically named according to the poly~ voice number, then you can at least send from one poly~ voice to another(and address them all individually outside the poly~ altogether pretty easily), even though there might be a vector of delay(this is something you can't do with mc.gen~, because you can't name params by individual mc-voices like you can with 'receive~'/'send~' within poly~-voices)
hope that helps to make more sense of it all 🍻
Thank you Raja for all your help on both threads! You are right that mc.gen~ could be too paralel for what I intend to do, but maybe with a deeper knowledge, who knows...
Here is my patch, for the very first time written in [codebox] (I have no programming background unfortunately). The thing I was struggling with is that I have plenty of similar parameters like: pitch_1, pitch_2, pitch_3 etc. for each instance of the osc function: osc_1, osc_2... What I want to do is to simplify make the number of instances a variable. For example, I would have a parameter "number_of_osc_instances" and it would decide, how many "pitch" parameters the program recognises.
outside the gen~ environment I would do this easily with some clever patching, but this is not the case here :/ now I'm working with 4 instances, but when I will start to work with 8 I will be just writing _1 _2 _3 _4... _8 all the time instead of thinking about the code :D
Thank you for idea with poly~ :) this is what I normally do; now however I want to learn something new (gen code), so for practice I try to do everything inside one gen patcher :) and there is a substantial lack of good Codebox tutorials...
It might not fit what you want to do here, but sometimes using a buffer~ can be a way to do multidimensional parameter setting. Each instance has a [voice] id which corresponds to a channel of a buffer of params. The voices look up the corrsponding frame (param) & channel (voice) of a buffer via peek(). External to the gen~, parameters are set per voice by setting the corresponding frame & channel of the buffer~ using peek~ etc. The downside to this is that all voices are peeking the buffer, but that could be mitigated somewhat by placing the peeks in an if() that only looks up when a param update is needed (e.g. start of a new note).
Another workaround is to [latch] parameters only when the current [voice] id matches (rather like the voice message in poly~). The drawback to this is that only one voice can be updated per passing sample frame of time.
Another workaround could be to use some code generation for your subpatches in another language (e.g. javascript, python etc.), to generate the parameter names with prefixes and store the code to genexpr or gendsp files. Or if you feel ambitous, using patcher-scripting, which also works with gen patchers.
Thank you very much for all your help! In the end I didn't use the mc.gen~, but an ordinary gen~ and coding and function calling.
@Graham Wakefield, I used your buffer~ method. I've never consider to use buffers as the data information before, which broaden my horizons, thanks! Now I plan to switch for the [data] method in the [gen]. Having such an internal copy of external data will be very useful for morphing or complex modulations. Thank you once more!