Automatic slider in Pure Data?
Asked Answered
R

2

6

I am trying to simulate an ocean sound automatically on Pure Data. So far I have accomplished to achieve a very basic sound by filtering some noise with a [bp~]. I have seen that the best range of the cut-off frequency is from 300 to 500 Hz, therefore I would like to have a horizontal slider [hsl] that goes from 300 to 500 and back, automatically and on a loop until I tell it to stop. (I have already assigned the range (300,500) to the slider, I only need to control it automatically now). I have tried with [osc~] but it won't work because the slider is not an audio element and the [osc~]'s output is an audio signal. In the picture I show what I have this far:

Current distribution of my program

So how can I do it to control the slider automatically without having to vary it manually? So far everything works as I want it to, but I need the slider to increase and decrease periodically to simulate the sea waves.

Richey answered 14/5, 2015 at 19:23 Comment(0)
V
5

If your question would simply be: How do I automate a slider? The answer would be to look at the [line] object. Line interpolates from a current value to a target value in a given time.

Use the line object to interpolate between floats and automate a slider movement

(Note: When controlling signals, we use [line~] instead.)

However, your goal is the simulation of a sea shore wave. In the above slider automation are two issues: 1.) we are operating in control data rate as opposed to signal data rate and 2.) we would want an ease-in and ease-out of the ramping. An oscillator will solve both of the problems at the same time.

Oscillator  acting as an envelope to a signal

(Note: Omitted here for simplification is that the amplitude control should not be linear due to perception of volume not being equal to power increase.)

Since we don't want to change the amplitude only, but the timbre (cut-off frequency of the bandpass) we want to use an sine function we can run a counter through to achieve the desired output range animation including easing-in and -out. Note: The slider acts merely as a visualization in this patch.

Bandpass automation

(glitch in animation due too misaligned loop-point)

Venusian answered 18/5, 2015 at 4:29 Comment(4)
note that the [sin] object expects input in radian (0..2π), unlike the [cos~] object signal!) that takes normalized values (0..1).Parochial
also, when controlling signals, you should use [line~] rather than [line].Parochial
@umläute the cut-off inlet of [bp~] is a control rate input. Did you read the text?Venusian
@umläute adressed your point and changed input to radianVenusian
I
4

There are two objects in Pd that let you convert from the signal world to the control world. [sig~] converts controls into signals and [snapshot~] converts signals into controls. You can use your [osc~] solution by using [snapshot~].

[snapshot~] works by reporting the instant signal value as a number every time it receives a bang. You can set up a metro at a given rate to report these regularly.

Here is a test that bangs [snapshot~] 20 times per second to capture an [osc~] moving at 1 Hz. I have used some simple operators to scale the output from -1 to 1 to be between 300 and 500 to fit with your example. You can patch this to your slider and be off to the races.

Pd patch illustrating snapshot and metronome solution

Irretrievable answered 15/5, 2015 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.