This little post aims at providing you with tips for writing effect patches for your guitar that are glitch-free (using an A/B switch) and that can be turned off when not in use. You can download the template at the end and adjust it to your needs.
By “turned off” i mean that the audio computation can be turned off, thus freeing resources in your computer. This can reduce the risk of glitches due to x-runs in JACK, and allow CPU-intensive effects to be used (like fft-based effects for instance).
To turn off audio computation, we use the [switch~] object that comes with the standard Pure Data package (“pd-vanilla”). Sending it a “1” turns the audio on, and a “0” turns it off. It only affects the audio in the subpatch or abstraction which contains this object, which makes it possible to turn off an effect individually without turning off the rest of the main multi-effect patch.
While turning on and off a subpatch or an abstraction, it is also necessary to route the audio signal appropriately to the wet or the dry paths, much like a hardware A/B switch. We use the [line~] object to aboid glitches when switching from one path to the other.
Here’s what the template looks like in a patch.
And here’s what’s inside. You can see how the A/B switch works, and also how the GUI is connected to the inside of the template.
And finally, the subpatch in which the actual effect should be. Notice the [switch~] object to turn audio computation on and off within the subpatch.
Please note that the actual template that you should use for your own effects is the object with the GUI in the first picture. In can be inserted into any effects chain. The template is a subpatch (a [pd something] object). I suggest saving this as an abstraction for a particular effect if you plan on using your effect in different patches. Please also note that your actual effect patch should be put in the “core” subpatch of the template, bewteen the [inlet~] and the [outlet~] (the template does not alter the sound as such, it is not an effect).
You can download the template here.