Page 1 of 1
a trigger switching an int from 1 to 0 and then to 1 again
Posted: Thu Jun 02, 2016 11:01 pm
by aombk
ok i need help with that.
i want to press a button(trigger) that mutes the signal chain for three seconds
i am thinking of doing it with a button, a timer component, ruby code that changes an int (or bool) output when triggered and a selector component. (does this make sense or shall i attach a flowstone module?)
i dont know how to do that in ruby. is this doable? can someone help with that?
also, is there a better way to do this?
thanks
Re: a trigger switching an int from 1 to 0 and then to 1 aga
Posted: Fri Jun 03, 2016 1:23 am
by Tronic
this audio code crude mute the input for an N samples,
any new value in the trig input active the mute.
Code: Select all
streamin in;
streamin trig; // any new value generate un trig
streamin nSample; // mute the in for nr sample
streamout out;
float mute= 0;
float wait = 0;
float oldtrig=0;
wait = wait - (wait & (oldtrig!=trig));
wait = wait + (1 & (wait<nSample));
mute = (wait >= nSample);
out = in & mute;
oldtrig = trig;
Re: a trigger switching an int from 1 to 0 and then to 1 aga
Posted: Fri Jun 03, 2016 3:00 am
by aombk
thanks.
i seem to have a problem though.
i cannot connect the output of a trigger to the dsp input. should they be connectable?
Re: a trigger switching an int from 1 to 0 and then to 1 aga
Posted: Fri Jun 03, 2016 3:19 am
by tulamide
As Tronic explained in the code, the trig is generated from a value change. So just input a float, int or boolean. Everytime you change their value, the code mutes audio and starts the timer to unmute after N samples. The 'counter'-prim would be a good start.
Re: a trigger switching an int from 1 to 0 and then to 1 aga
Posted: Fri Jun 03, 2016 4:47 am
by aombk
ok thanks.
meanwhile i figured how to do it with ruby too by using this code:
Code: Select all
def event i,v
if i=="tr1" then output 0 end
if i=="tr2" then output 1 end
end
and then multiply the ruby output with the stream.
i also tried the tronics code with a counter and it works
shall i use dsp code instead of ruby? is it better?