pdclip
Performs linear clipping on an audio signal or a phasor.
The pdclip opcode allows a percentage of the input range of a signal to be clipped to fullscale. It is similar to simply multiplying the signal and limiting the range of the result, but pdclip allows you to think about how much of the signal range is being distorted instead of the scalar factor and has a offset parameter for assymetric clipping of the signal range. pdclip is also useful for remapping phasors for phase distortion synthesis.
Syntax
Initialization
ibipolar -- an optional parameter specifying either unipolar (0) or bipolar (1) mode. Defaults to unipolar mode.
ifullscale -- an optional parameter specifying the range of input and output values. The maximum will be ifullscale. The minimum depends on the mode of operation: zero for unipolar or -ifullscale for bipolar. Defaults to 1.0 -- you should set this parameter to the maximum expected input value.
Performance
ain -- the input signal to be clipped.
aout -- the output signal.
kWidth -- the percentage of the signal range that is clipped (must be between 0 and 1).
kCenter -- an offset for shifting the unclipped window of the signal higher or lower in the range (essentially a DC offset). Values should be in the range [-1, 1] with a value of zero representing no shift (regardless of whether bipolar or unipolar mode is used).
The pdclip opcode performs linear clipping on the input signal ain. kWidth specifies the percentage of the signal range that is clipped. The rest of the input range is mapped linearly from zero to ifullscale in unipolar mode and from -ifullscale to ifullscale in bipolar mode. When kCenter is zero, equal amounts of the top and bottom of the signal range are clipped. A negative value shifts the unclipped range more towards the bottom of the input range and a positive value shifts it more towards the top. ibipolar should be 1 for bipolar operation and 0 for unipolar mode. The default is unipolar mode (ibipolar = 0). ifullscale sets the maximum amplitude of the input and output signals (defaults to 1.0).
This amounts to waveshaping the input with the following transfer function (normalized to ifullscale=1.0 in bipolar mode):
1| _______ x-axis is input range, y-axis is output
| /
| / width of clipped region is 2*kWidth
-1 |/ 1 width of unclipped region is 2*(1 - kWidth)
-------------------- kCenter shifts the unclipped region
/| left or right (up to kWidth)
/ |
/ |
------ |-1
Bipolar mode can be used for direct, linear distortion of an audio signal. Alternatively, unipolar mode is useful for modifying the output of a phasor before it is used to index a function table, effectively making this a phase distortion technique.
Examples
Here is an example of the pdclip opcode. It uses the file pdclip.csd.
See also
Credits
Author: Anthony Kozar
January 2008
New in Csound version 5.08