I've got this simple patch:
Now I connected a game controller to Pd where the keys give me 1 or 0 depending whether I press the button or not.
If I press my button I want the osc~ to "play" and if I release it it should stop.
BUT: I wasn't able to find a point where to attach a switch. I don't want to switch off the DSP as I want to play another sound at another key the same time.
It would be nice if anyone of you would have a solution
EDIT: Okay the below solution worked, If there is any need for the project I've done (using a game controller as an instrument) just contact me directly.
This is done with an audio multiply object [*~] and 0 or 1, as the previous answer stated.
Here's a simple example with a PureData toggle box (which outputs 0 or 1, same as your game pad buttons):
source
The object [line~] makes a smooth transition from 0 to 1 and back over the course of 100 milliseconds (the message box above replaces the token $1 with it's input), this provides a volume envelope and stop clicks, which can occur when the level of a tone change too abruptly. If you want this change to sound instant, still use a [line~] but change the 100 down to 10.
If it's any help to you, I also have a tutorial on using game pads in pure data
Switching a signal in Pd is done by multiplying the signal with 0 or 1. Multiplication of the signal is done with the object *~
. Since you already have 0 and 1 from your game controller, that should be easy. However, you will start to hear clicks, depending on where the sine wave is in the moment you abruptly switch it off. To fix this, ad a line~
object and ramp the oscillator in and out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With