AudioTools
Clip
clip audio sample values into the correct range
Calling Sequence
Parameters
Description
Examples
Clip(audArray, low=lowValue, high=highValue )
audArray
-
Array, Vector, or Matrix containing the audio data to clip
low=lowValue
(optional) the lower bound
high=highValue
(optional) the upper bound
The Clip command clips any sample value lower than a lower bound to that bound, and higher than an upper bound to that bound.
The audArray parameter specifies the audio data to clip, and must be a dense, rectangular, one or two dimensional Array, Vector, or Matrix, with datatype=float[8].
The low=lowValue option specifies the lower bound to which intensities will be clipped. Values below this will become equal to lowValue.
The high=highValue option specifies the upper bound to which intensities will be clipped. Values above this will become equal to highValue.
If only one of low=lowValue or high=highValue is specified, the other bound is left open (unbounded).
If neither low=lowValue or high=highValue is specified, the values -1.0 and 1.0 respectively are used.
The Clip command is often useful after performing other audio processing operations that may have produced out-of-bound values, and before performing operations that are not defined on out-of-bound values. It can also produce distortion-like effects (like electric guitar fuzz).
audiofile≔cat⁡kernelopts⁡datadir,/audio/stereo.wav:
with⁡AudioTools:
aud≔Read⁡audiofile
aud≔Sample Rate22050File FormatPCM File Bit Depth8Channels2Samples/Channel19962Duration0.90531⁢s
printf⁡%6.3f\n,aud1000..1015
0.378 -0.547 0.465 0.921 0.535 0.898 0.598 0.992 0.638 0.898 0.669 -0.625 0.685 -0.734 0.685 -0.945 0.669 0.669 0.646 -0.281 0.606 -0.828 0.559 -0.891 0.504 -0.586 0.449 0.976 0.378 -0.477 0.315 -0.602
too_loud≔aud⋅5
too_loud≔Sample Rate22050File FormatPCM File Bit Depth8Channels2Samples/Channel19962Duration0.90531⁢s
printf⁡%6.3f\n,too_loud1000..1015
1.890 -2.734 2.323 4.606 2.677 4.488 2.992 4.961 3.189 4.488 3.346 -3.125 3.425 -3.672 3.425 -4.727 3.346 3.346 3.228 -1.406 3.031 -4.141 2.795 -4.453 2.520 -2.930 2.244 4.882 1.890 -2.383 1.575 -3.008
fuzzed≔Clip⁡too_loud
fuzzed≔Sample Rate22050File FormatPCM File Bit Depth8Channels2Samples/Channel19962Duration0.90531⁢s
printf⁡%6.3f\n,fuzzed1000..1015
1.000 -1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000 1.000 1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000 1.000 1.000 1.000 -1.000 1.000 -1.000
See Also
Array
Matrix
Vector
Download Help Document