Help with code for on/off switch on attenuator


#1

Hey :slight_smile:

I have been trying to add an on/off button to the math/*c object Using Philoops phi/prob/%i sw object as reference, since it has got an On/off button implemented.

I have added the parameter bool32.tg for the on/off switch. It is called on.

I hav also added the highlighted to the existing k.rate code. But it doesnt work.

K-rate code:
outlet_out= (param_on) + __SMMUL(paramamp,inlet_in)<<1;

I tried moving the (param_on) to other places but it just wont work. The patch goes live, but the on off button does not work.

Any ideas?

atten on off 1.axp (2.3 KB)


#2

check my contrib , i made it for you. (and see the code for how it is done) you need an if statement...


#3

Hey @lokki :slight_smile:

Thanks :slight_smile: Ill check it out. I did think about the "if", cause it was in the other patch, but I wasnt sure how to implement it.


#4

Hey again!

I just checked it, but it seems like the on/off button only works when the attenuator is on zero. When attenuator is above zero, the on/off button does not work.


#5

yeah true , investigating......


#6

conoff.axp (6.4 KB)

now working ...please contribute @jaffasplaffa ..Your idea
maybe it would be better to have an on switch???


#7

well it works here, but maybe i did not get what you wanted.

i implemented the following:

multiplication is on when switch is turned off, when it is on, values are just passed, so there is no multiplication going on. so if you input 64, you get 64 out, regardless of the multiplication setting. the multiplication is off. is this not what you wanted?


#8

hmm, i would not call that an on/off switch, more like a kill switch.

on/off means to me that a signal is either affected or unaffected by the "effect" (in this case multiplication) but what you implemented is a kill switch. anyways, i will do a version of my object that includes a kill switch :slight_smile:


#9

hmm, not sure though. should the "kill" switch really be outlet_out = 0? should it not just stay at the last value? why would 0 be off? it could well be -64 or 64...


#10

yes! your approach is also very good , but how to name these diffrent approaches .....
I think ur approach would be hold switch
while mine is simple on/off switch ...kill switch sounds so harsh

anyway they should be in the same folder


#11

no, hold would be if the value would stay at the last value. (not yet implemented) but what i did, would be an on_off switch because it simply does not affect the signal at all. or how would you call my object? :slight_smile:


#12

but why 0? if you input a bipolar signal it could well be -64?


#13

just lokkied at ur approch ...urs should be named ctrl thru ....
what @jaffasplaffa meant was more an on/off approach

well its an attenuator/multiplier
so if if u multiply -64 with 0 = 0.
Lokki at phi/mix/cf1.... i want to build in a switch there too.....


#14

haha, that is funny because it is just different point of view.

let me explain my pov:

you have a signal coming in and a signal getting out of the object. if you turn the object off i would expect it to just let the signal go through unaffected, allowing the signal to pass. your approach is a kill aproach, because the signal can not flow anymore, it is 0 no matter what you let in....

and it makes no sense to me that 0 should be considered the off value. of course if you multiply by 0 every value is zero. but why would the off state of a multiplication be zero? it is much more logic for the off state of a multiplication to be 1 = NO multiplication.

anyways, getting "philoopsophical" here :slight_smile:


#15

conoffa.axp (7.1 KB)

nontheless we need an hold approach too

lokki = bypass
phi = kill it


#17

there you go...

(check my contrib) *c hold


#18

Sorry guys, I had go to bed early last night. I just saw the many posts this morning. I thank you for the effort. Will check them when I am home in the afternoon again.

I am mostly for the on switch, since thats what most buttons like that do.

When on, it wuld be great that it passes the attenuated value. When off it should not pass any values.

Who wpuld have thought there would be so much to making an on/off button :slight_smile:

Again, I thank you for your effort, will look into it in the afternoon :slight_smile:


#19

Following up on this thread, I made another version that is in the library now called "togam". It has got an amount knob and an on/off knob. Check com.lib!