Clip - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim

AudioTools

 Clip
 clip audio sample values into the correct range

 Calling Sequence Clip(audArray, low=lowValue, high=highValue )

Parameters

 audArray - Array, Vector, or Matrix containing the audio data to clip low=lowValue - (optional) the lower bound high=highValue - (optional) the upper bound

Description

 • 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).

Examples

 > $\mathrm{audiofile}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/audio/stereo.wav"\right):$
 > $\mathrm{with}\left(\mathrm{AudioTools}\right):$
 > $\mathrm{aud}≔\mathrm{Read}\left(\mathrm{audiofile}\right)$
 ${\mathrm{aud}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (1)
 > $\mathrm{printf}\left("%6.3f\n",\mathrm{aud}\left[1000..1015\right]\right)$
 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
 > $\mathrm{too_loud}≔\mathrm{aud}\cdot 5$
 ${\mathrm{too_loud}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (2)
 > $\mathrm{printf}\left("%6.3f\n",\mathrm{too_loud}\left[1000..1015\right]\right)$
 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
 > $\mathrm{fuzzed}≔\mathrm{Clip}\left(\mathrm{too_loud}\right)$
 ${\mathrm{fuzzed}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (3)
 > $\mathrm{printf}\left("%6.3f\n",\mathrm{fuzzed}\left[1000..1015\right]\right)$
 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