Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pure Data osc~ on/off switch

Tags:

puredata

I've got this simple patch:

Simple Patch Diagram

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.

like image 853
hGen Avatar asked Dec 19 '22 13:12

hGen


2 Answers

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):

Simple audio on-off in Pd

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

like image 50
AJFaraday Avatar answered Mar 08 '23 07:03

AJFaraday


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.

like image 23
Max N Avatar answered Mar 08 '23 09:03

Max N