Pure Data osc~ on/off switch
Asked Answered
S

3

5

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.

Solfeggio answered 1/7, 2014 at 12:26 Comment(0)
C
7

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

Conceivable answered 21/7, 2014 at 23:2 Comment(0)
P
6

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.

Philipphilipa answered 2/7, 2014 at 0:8 Comment(0)
S
2

One thing to keep in mind as well is that when switching on an LFO, the effect of its phase is audible. So depending on the frequency of your oscillator, controlling its phase while switching on is desirable. You can send number arguments (0-1) to the right inlet to control the phase. For instance, if you want the LFO to ramp down every time you turn on the osc~, you can send a 0 to the right inlet to start at the beginning of the phase.

If you go this route you must include a trigger that forces a bang to the ramp before you send one to the phase inlet. Otherwise you will hear clipping every time you turn it on. This is important especially with short ramp times. There is more information on bang order using triggers in PureData's help files, under "2. control.examples/03.connections.pd".

There is probably no reason to send a phase argument to the osc~ when you switch it off, so you can simply add a select atom to direct the switch depending on whether you are switching on or off.

Subgroup answered 31/3, 2015 at 1:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.