So I’m trying to figure out where the consumption of CPU is coming from in a program I am writing. On initializing csound I have many instruments, but none are called in the score and must be called by an external score event which will enable an instance of that instrument. Even when I don’t enable any of these instruments directly I am still getting a fairly large amount of CPU consumption. I noticed that if I eliminate half of the instruments from the .CSD file it yields about 50% reduction in CPU consumption so I’m assuming this is the culprit and somehow based on how csounds operates the instruments, while not activated, must still be executing some of their code as I can’t imagine the idle “waiting for event/activation” state itself would consume that much CPU on its own (I’m seeing about a 1-2% increase per instrument varying by its complexity)
My question is, do instruments that are not enabled still consume CPU each cycle and if so is there a way to limit/eliminate this consumption until they are enabled? I would think that after initialization they’d lie in a dormant state but maybe certain k/a-rate operations still execute even when no instances are currently present?
For context I am building a modular system so I anticipate a large amount of instruments but not necessarily a large amount of instruments to be enabled. Any insights appreciated
EDIT: I see a (sort of) similar question asked here: One or many instruments? - Csound Noobs - Cabbage Audio Forum but I’m not sure if the context is the same or if code within an instrument still executes even when no instances have been enabled directly (as I’m enabling instruments with fractional numbers). It looks like this was more of a “which would consume more/less CPU” than actually wondering if an instrument consumes CPU when no instances have been enabled
IMPORTANT NOTE: If non-enabled instruments should not be consuming CPU then it may be due to the fact that I am running this within Unity using the Csound Unity project. However I don’t see anything in the .cs files from Csound Unity that seem like it would be attempting to fetch audio from channels each fixed update (initially my thought was maybe somewhere it was checking every audio rate channel which was set but I don’t believe this is the case) so I’m guessing this is an unlikely source of the issue (but figured I’d throw it out there in case it is a possibility as I’m still getting familiar with that particular project’s source and have lots of holes in my understanding of its operation)