• No results found

As we get into more complex patches it will take more space to walk through the individual steps to create a patch, so from now on we’ll rely more heavily on looking at a patch to understand how it’s made. One of the great things

about Pd is that looking at a patch tells you almost everything you need to do to reproduce it.

Create a new patch called lfo~.pd and save it in the same directory as grapher~.pd. Then re-create in the patch what you see in the following figure.

osc~

depth rate

*~ 0.5

*~

swap 1

+~

-

outlet~ signal +~ 1

This LFO is meant to be used as a subpatch, like grapher~. This diagram shows the patch with most of the controls in place, so you can see them a little more easily. Then we’ll go back to the parent patch and add other labels and controls that we want the user to see. That will get a little cramped visually. Let’s go over the patch so far.

Controls and Display

First we have rate and depth controls. Those controls are horizontal sliders with a width of 30 and a height of 10. The rate slider’s output-range properties are set to 0.05 for left and 200 for right, which will give us the Hz range we want. The depth slider’s output-range is 0 to 1 for 0% depth to 100% depth. The Rate and Depth labels on the sliders can be added from their property windows.

Getting the Rate in Range

The rate slider is also connected to an osc~ object with no argument, so it controls the oscillator’s frequency. This is the LFO’s engine, so to speak.

Signals in Pd generally have values between 1 and –1, but we want the LFO to output only a positive number. To make this happen we do a little massag-ing of the signal commassag-ing out of the osc~ so that it never goes below 0—we add 1 and then halve the value so the lowest possible signal value is 0 and the highest is 1. The signal is then sent to a *~ to mix in the depth control’s effect.

Getting Depth Working as Expected

The depth value is sent to the *~ object to regulate the osc~ signal, but then we have to do a little more work to make sure the depth works the way we’d expect. If the depth is set to 0, we don’t want the LFO to output a signal of 0. When the depth is set to 0 the intention is that the LFO has no effect when, for instance, we multiply the signal from an osc~ with the LFO. To make this work we need a depth of 0 to output a signal of 1. We send the output of the depth control to a swap object with an argument of 1. This object will send the scalar value received at its left inlet to its right outlet, and either the value of its right inlet or its argument to the left outlet. These values are sent to a subtraction object (-), which will send the value of 1 minus the depth control’s value to its outlet. That way a depth of 0 will cause a 1 to be calculated at this stage, and a depth of 1 will calculate a 0.

Mixing Rate and Depth for Output

The value of 1 - depth is sent to a +~ object to be added to the signal derived by multiplying the rate by the osc~. Therefore if the depth is 1, it will not affect the already fully affected osc~ output, but if it’s 0 it will add 1 to the signal of 0 coming from *~ and send a signal of 1 to the outlet~.

Adding Readout Controls

Now let’s go back to the top of the patch and add some controls that will cal-culate and display information to the subpatch’s user—useful controls that will show when the patch is used in a parent patch. Just like with the grapher~

patch, right-click on the canvas and choose Properties and set them as follows:

Graph-on-Parent checked, an X size of 100, Y of 85, and margins of 0. Figure 5, Final LFO Patch, on page 38 shows the patch again, this time annotated;

you can create comments with the key sequence C5. Also, note that in this figure I added two inlet objects, one each for rate and depth, to allow the parent patch to specify the rate and depth.

When a patch is set up to graph on its parent, remember that the red box shows the area that will display on the parent. Inside this box is where the rate and depth controls are arranged.

osc~

0.05 100

depth rate

Hz

20 Seconds inv

*~ 0.5

*~

swap 1

+~

-

outlet~ signal +~ 1

% * 100 Convert depth to percent

The rate controls this oscillator Move minimum value above 0

Bring amplitude back down to between 1 and 0

Multiply by depth of effect

Subtract depth from 1 and sum with output so a depth of 0 has an output of 1

These controls will display on the parent

Calculate seconds and display (seconds = 1/Hz)

inlet rate inlet depth

Figure 5—Final LFO Patch

To provide a bit more information to the LFO’s user, there are boxes under-neath. Numbers are created with C3. A number can display a scalar value sent to its inlet. There is a number for the rate slider’s direct output, which is labeled Hz, and another underneath labeled Seconds. We can edit the label in the number’s properties.

Hertz is defined as a rate per second, so to convert Hz to seconds we can simply invert it. To derive seconds for the rate control’s Hz value, the Rate slider is connected to an inv object, which inverts the scalar value and sends it to its outlet, which is then connected to the number displaying seconds.

The Depth slider is connected to a * 100 object, which converts its scalar value to a percent, and sends that display to the number labeled with a percent symbol (%).

Now that we have an LFO control that will allow us to easily control the rate and depth of a control signal, let’s test it out.