hey, i have picked up that its good coding practice not to declare all variables at the top. how would you go about a structure like this, where i would like to declare a variable triggers followed by other variables and i already use triggers to send it to a bus, map the masked triggers from the bus to \trigMask.ar and send the maskedTriggers to an fx with feedback, so i would like to apply the grain window to the fx afterwards, so i send it to a bus. All these OffsetOuts…
so the question is in two parts, first how to go about variables in the SynthDef and the second how to deal with these different OffsetOuts and the mapping of busses, is there a more elegant way. thanks
huh - I definitely DO declare all var at the top, so I’m wondering why there is the impression that this is a problem?
I DO try to keep all my variables closely scoped (where a var is declared only within a block that will use it). But the nature of SC, as a language, in this regard, you are encouraged to declare all vars at the top. I honestly dislike the assignment of values to vars at the same time. It makes it harder (for me) to read. But - I’m also very used to C which has this requirement as well. And I prefer it (personally)
hey, thanks for your reply i dont know anymore which thread it was where this was said.
But considering all these OffsetOuts it would be nice to have several blocks of code instead of just putting them one after the other. Im normally using enough space between these different things,so its more readable, but i guess there could be some adjustments.
I declare all vars at the top like Josh, not because of C, but precisely because of the issue you’re describing – in many cases it is clearest and most readable to intersperse assignments with non-assignments.