Standby/on off switch that takes the load off of processor


#1

Is there a way to have standby or on/off switches for objects or modules that can take the load off of the processor when object is in the off position? Pleas help.


Jaffasplaffas contributions
#2

You can add a toggle button parameter to the modules, and wrap all the object k/s-rate routines in an

if(param_buttonname) {
code..
}

a|x


#3

easier than that add to only k-rate as first line

if(!param_active) return;

(its not needed in s-rate, as the above terminates the dsp routine)

however, either, will leave any audio buffer, or other outlet in-initialised.
to do 'properly' , you would have to also (before this line) set outlets and audio buffer to what you expect. e.g. with an audio buffer this normally would be to copy the inlet to the outlet.
(obviously you would want to only do this when not active, so as not to impose the overhead when the object is active)

also be aware doing this, makes it quite possible you will possibly start encountering cpu overloads.
e.g. imagine you have lots of objects like this in a patch whilst 'testing' then in a live performance you turn them all on , if you have not tested before, you may suddenly find you don't have enough cpu for all objects... so this (like all conditional code in dsp), has to be 'handled with care', you should test your patch with ALL code active whilst testing.


#4

Thank you guys I really appreciate your help.


#5

Hello again guys

seams like my skills are not exactly up to the task.

I implemented the codes suggested to me and this is the only way I made it work;
with partial success.....

eq5hqE.axo (3.4 KB)


#6

I said partial because when the toggle switch is activated everything is fine but when is in the on position the only thing I hear is a loud high tone generated and I have no idea why?

I need to implement 2 different codes for 2 different situations.

one in which there is no sound produced by the object when the toggle switch is in the off position(on/off switch) which is the one I am actually trying first.

and a different one when the output is equal to the input ( standby).


#7

I don't know why the code did not show properly but anyways here is the object...

eq5hqE.axo (3.4 KB)


#8

Hi @ed76

I think that
the output buffer is not set to 0 when your object is in standby, the last 16 samples before the standby are looped at 3kHz hence the high tone.

You can try something like:

if(param_b){
....
} else {
  for(int i=0;i<BUFSIZE;i++)
    outlet_out[i] = 0;
}

#9

Will try that one thanks


#10

I get this errors


#11

Try this one:

eq5hqE.axo (3.3 KB)
(when it is disabled, the input is copied to the output without processing).

The xml <![CDATA[ was somewhat mixed with C "}" brackets in the code.
Using the axoloti editor (instead of a text editor) to avoid this kind of problem.


#12

I can't download the file for some reason


#13

eq5hqE.axo (3.3 KB)


#14

Hi @ed76, does it work as you intend ?


#15

yes is working perfect thank you.

you guys are the best!