a trigger switching an int from 1 to 0 and then to 1 again

For general discussion related FlowStone
Post Reply
User avatar
aombk
Posts: 34
Joined: Tue May 24, 2016 2:44 pm
Location: athens, greece
Contact:

a trigger switching an int from 1 to 0 and then to 1 again

Post 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
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: a trigger switching an int from 1 to 0 and then to 1 aga

Post 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;
User avatar
aombk
Posts: 34
Joined: Tue May 24, 2016 2:44 pm
Location: athens, greece
Contact:

Re: a trigger switching an int from 1 to 0 and then to 1 aga

Post 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?
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: a trigger switching an int from 1 to 0 and then to 1 aga

Post 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.
"There lies the dog buried" (German saying translated literally)
User avatar
aombk
Posts: 34
Joined: Tue May 24, 2016 2:44 pm
Location: athens, greece
Contact:

Re: a trigger switching an int from 1 to 0 and then to 1 aga

Post 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?
Post Reply