3 or 4 way switch question

Is there a way to program a toggle switch to move in the direction it is dragged, or possibly move to an empty position clicked on?

Picture a 3 way toggle switch, and you want the user to be able to go from middle position to bottom position back and forth, from top to bottom, instead of stepping through the positions? Or do the same thing under CV control?
This is needed for live use …

Don @ STS

No, but you could probably easily create a subclass of Knob that renders as a switch (with snap=true to make values integers). Users could drag the “knob” up and down to increase/decrease the value, which would be rendered with multiple SVG frames.

For the “move to an empty position” style, that sounds like the same behavior as a radio button. (Does Rack not offer svg radio buttons in its plugin API?) If you don’t absolutely require CV control, here’s what I would try instead of a toggle switch:

Use 3 (or 4) separate buttons. Draw a background that looks as if each button is selected. On top of this background, render each button to show its “unselected” state. When a button is pressed, it tells the module to enable whatever thing the button represents, then turns itself invisible (showing the “selected” portion of background), and turns the others visible (showing their “unselected” state).

Note: I haven’t tried this. There may be problems I haven’t thought of.

Thanks for the ideas… I do miss radio buttons… The ‘fake knob’ will work for the first 3 way toggle…

1 Like

That would just be a SvgSwitch with two SVG frames and momentary=false (the default). The Param value toggles between 0.0 and 1.0 each time it is clicked. If more frames are added, it cycles between a set of higher integer values.

Radio Buttons don’t cycle, Any one can be pressed at any time, turning off the others, like the station selection buttons on an old car radio, hence the name. You can fool the switch assembly and press any combination of buttons, like the all on combination that is famous on an 1176 compressor. Gives me a project…

Oh, those kinds. The best way would be to make momentary switches and put an LED over them that modifies an internal state. Whenever you want a component in Rack think “How would a hardware module do it?”

A hardware module would do it with an off the shelf ganged switched assembly.

The mouse doesn’t have enough fingers to press selected multiple buttons at once.

It would have to work like Windows’ radio buttons, only one at a time

Not sure how this is relevant. You wouldn’t want to do this with radio buttons.

Users do it all the time on hardware. Press combinations of buttons at once. The 1176 compressor is a famous use of that trick.

Right, but this isn’t what you want, correct? If you do, make the params individual toggle switches. If not, use multiple switches. In Rack v1, you can write params, so you can manage your switched assembly login in Module::step(). In Rack v0.6, the user feedback must be an LED on the switches.

Only if you want to simulate a ‘real’ set of radio buttons, like in Dale’s comment… It can be done in various ways if the situation arises. I don’t need it for my use, but I can see uses for it down the road. A stock radio button simulation will do what I need for the 4 way switch, selecting positions in any order. The ‘fake knob’ will work for the 3 way, I think.

Thanks for the input.

This discussion made me realize that on a component that has snap = true, when we enter values of a knob/switch using the right-click dialog box, the param that gets written is not rounded by Rack. This will not be a problem for most components, but in some cases a dev may have set snap = true never expecting to get a non-integer value, which could potentially affect the behavior of the code.

I guess for good measure we should always round the param value that we read from a component that has snap = true, but I’m wondering if from a UI perspective it might be good for Rack to also round the param that gets written when we manuallay set a value though the right-click.