How to use switches?

Hi, very new to the world of Daisy and Pure Data/ PlugData. Have been having a lot of fun and found Pd super intuitive and knocked up a few effects pretty quickly.

Today i managed to get a few of my simple patches onto the Daisy (I’m using the GuitarML FunBox PCB as a sort of dev board. So far i’ve customised a json file and mapped the pots and switches but what i’m really struggling with is how to use the toggle switches/foot switches. I understand how they work, and are connected with the middle pin grounded and the two outside pins connected to digital inputs on the Daisy, but i can’t figure out how to translate it into Pd. Is toggle object the correct thing to use? I think i’m too used to thinking of toggles as something physical that signal travels through. I’m by no means a coder but i feel like what i want to say is “in this pin is high, do this…if the other pin is high, do that” but can’t think how that translates into Pd. Any help would be greatly appreciated!

Thanks

Patrick

Check out the component reference: Pd2dsy JSON · electro-smith/DaisyWiki Wiki · GitHub

In the custom json you will need to set up the pins as “switches” and you will either get a “bang” when the pin enables (rising edge), the current pressed state as a value (0 or 1 message once every audio cycle), a bang on the falling edge (disable pin) or the number of seconds since the switch has been pressed.

You will need a component section like:

{
    "components": {
        "switch1": {
            "component": "switch",
            "pin": 20
        }
    }
}

And then in your patch you can use [r switch1 @hv_param] or the variants: switch1_press, switch1_fall or switch1_seconds.

Thanks for the reply (and also thanks for your vids on YouTube, a couple of those really helped me get going.

I think my json is set up fine to use the switches, and I think I understand how to call them using hv_param. I’m more confused about how to control things with them in the pd patches.

Let’s say I have a delay effect set up for example. And I wanted to use a toggle switch to set the feedback amount at 0 in the right position, at full in the left position, and an amount set by the feedback potentiometer when the toggle is in the middle. What objects would I use for that in pd? The Would it be bangs which were tied to [r switch1_left @hv_param], [switch1_right @hv_param]…etc

Thanks again for your help

Ok so your switch is using 2 pins?

I would try something like this. So you take the “bang” from the edge positions to activate a specific value (0 or 1), and both of the “falling edge” bangs to allow the feedback pot values to be used instead.

The outer positions closes the spigot (something that can pass or block a message flow):

Of course be careful with full feedback!

Ahh ok thank you, I think i kind of get that, will need to stare at that image for a while to fully work out whats going on. What’s the correct way to reference the falling edge in the json? Can’t seem to find any examples of that anywhere. Sorry for all the questions, i have tons more but taking it one step at a time ha.

Thanks again for your help

You don’t, simply creating the switch component gives you these optional receivers.

*Jimi Hendrix gasps* :pray:

I’m trying to use this toggle method to select between three LFO wave shapes; Sine, Ramp Up, and Ramp Down, but can’t get it connected. I’m clearly missing something here. How would i do it so middle toggle position is Sine, left position is Ramp Up, and right position is Ramp Down?

Is this still the method to use or is there a better way?

Thank you!

Something like this maybe?

You can’t “toggle” a signal, but you can fade it in or out.

That works perfectly, thanks so much. I was playing around some more after i initially posted and this isn’t a million miles away from where i ended up which is reassuring.

I’m off to switch lots of things!

1 Like

ok having fun changing the function of some pots so they either control delay modulation depth and speed, or filter depth and speed. However, when i move the toggle switch it automaticaly updates these values depending on where the pots are set. Is it possible/straight forward to only update these values when the knobs have been moved.

Ideally you would move toggle 2 to left position, set the delay modulation rate and depth, then move the toggle to the centre, set the filter rate and depth, and then if you toggled back to the left position the delay modulation rate and depth remain as they were initially set until the knobs were moved to update them.

Sounds straight forward so hoping that’s not a nightmare to implement

It does not make sense to use [$1 20( message here, the spigot will only listen to 0 or 1.
You could put a number object to make it convenient as a “proxy” to multiple other messages.

This is a separate topic and in the chat we’ve been playing with some abstractions that create a “latching” object.
This will then store your value and only when it is selected and the knob reaches the value will it “latch on” and continue to change after.

It is not straightforward and more advanced method of patching and creating such a UX.

Do you mean this is a separate topic that is already under discussion, or I should create a separate topic with this question?

Thanks

Please create a separate topic so this one can stay on using switches :slight_smile:

I’ll get round to that separate topic eventually, for now i’m still having some trouble with switching.

I have a stereo ping pong delay which is working nicely. I’m trying to use my second foot switch to turn on/off a reverse function.

As i couldn’t figure out how to simply reverse my current delwrites i opted for using another one which goes before the stereo pair.

Basically I’m trying to take the adc and send it either straight to a left and right delwrite called ping and pong, or send it through this reversing section and then into the left and right of the stereo delay.

It seems to all function correctly in plug data but when i flash it to my development pedal it works fine on power up, then works fine when the second foot switch turns on the reverse section, reverse sounds all good and trippy. But then when i turn off the reverse with the foot switch it seems to add an extra delay time to my normal stereo delay. I’m guessing this has got something to do with the metro in the reverse section…

So question is, is there a much better way to get a reverse option using the pre-existing stereo delay lines? and if not how can i use the switching to completely remove the reverse section so that it doesn’t bug out the regular stereo delay.

Sorry for the essay!