next up previous contents index
Next: Non-looping sample player Up: Examples Previous: Sampling and foldover   Contents   Index

Converting controls to signals

Patch C03.zipper.noise.pd (Figure 3.13 part b) demonstrates the effect of converting a slowly-updated control stream to an audio signal. This introduces a new object:


\fbox{ $\mathrm{line}$}: a ramp generator with control output. Like $\mathrm{line}\sim$, $\mathrm{line}$ takes pairs of numbers as (target, time) pairs and ramps to the target in the given amount of time; however, unlike $\mathrm{line}\sim$, the output is a numeric control stream, appearing, by default, at 20 msec time intervals.

In the example you can compare the sound of the rising and falling amplitude controlled by the $\mathrm{line}$ output with one controlled by the audio signal generated by $\mathrm{line}\sim$.

The output of $\mathrm{line}$ is converted to an audio signal at the input of the $\mathrm{*}\sim$ object. The conversion is implied here by connecting a numeric control stream into a signal inlet. In Pd, implicit conversions from numeric control streams to audio streams is done in the fast-as-possible mode shown in Figure 3.4 part (a). The $\mathrm{line}$ output becomes a staircase signal with 50 steps per second. The result is commonly called ``zipper noise".

Whereas we were able to demonstrate the limitations of the $\mathrm{line}$ object for generating audio signals were clear even at such long time periods as 300 msec, the signal variant, $\mathrm{line}\sim$, does not yield audible problems until the time periods involved become much shorter. Patch C04.control.to.signal.pd (Figure 3.13 part c) demonstrates the effect of using $\mathrm{line}\sim$ to generate a 250 Hz. triangle wave. Here the effects shown in Figure 3.5 come into play. Since $\mathrm{line}\sim$ always aligns line segments to block boundaries, the exact durations of line segments vary, and in this case the variation (on the order of a millisecond) of the segments is a significant fraction of their length.

A more precise object (and a more expensive one, in terms of computation time) is provided for these situations:


\fbox{ $\mathrm{vline}\sim$}: exact line segment generator. This third member of the ``line" family not only outputs an audio signal, but aligns the endpoints of the signal to the desired time points, accurate to a fraction of a sample. (The accuracy is limited only by the floating-point numerical format used by Pd.) Further, many line segments may be specified withing a single audio block; $\mathrm{vline}\sim$ can generate waveforms at periods down to two samples (beyond which you will just get foldover instead).

The $\mathrm{vline}\sim$ object can also be used for converting numeric control streams to audio streams in the nearest-sample and two-point-interpolation modes as shown in Figure 3.4 parts (b) and (c). To get nearest-sample conversion, simply give $\mathrm{vline}\sim$ a ramp time of zero. For linear interpolation, give it a ramp time of one sample (0.0227 msec if the sample rate is 44100 Hz.)


next up previous contents index
Next: Non-looping sample player Up: Examples Previous: Sampling and foldover   Contents   Index
msp 2003-12-08