normalize audio sample values to a specified maximum amplitude
Array, Vector, or Matrix containing the audio data to normalize
(optional) one or more equations of the form option = value, where option is amplitude or offset
amplitude=value - the peak amplitude of the result
offset=mode - specifies how a DC offset should be handled
The Normalize command adjusts the amplitude of samples in a recording so the maximum amplitude of any one sample is as specified.
The audArray parameter specifies the audio data to normalize, and must be a dense, rectangular, one or two dimensional Array, Vector, or Matrix with datatype=float.
The amplitude=value option specifies the maximum amplitude that any sample may have. If omitted, this defaults to 1.0.
The offset=mode option specifies what is to be done if the audio has a DC offset. Three modes are available:
offset='scale', which is the default, treats the audio data as if the offset were zero. The resulting audio will contain at least one sample with a value of amplitude or -amplitude, and the offset will have been scaled.
offset='remove' specifies that any DC offset is to be removed before normalizing. The resulting audio will contain at least one sample with a value of amplitude or -amplitude.
offset='ignore' completely ignores the offset. The audio data will be scaled so that at least one sample will have the value amplitude, and one will have the value -amplitude. The offset will have been shifted and scaled.
Both the remove and ignore modes have the potential to introduce a DC offset if the arithmetic mean of all the samples is not zero. Thus it is best to use scale mode if the DC offset is known to be zero.
The Normalize command is often useful after performing other audio processing operations that may have produced out-of-bound values or very low amplitudes.
audiofile ≔ cat⁡kernelopts⁡datadir,/audio/stereo.wav:
aud ≔ Read⁡audiofile
aud≔Sample Rate22050File FormatPCM File Bit Depth8Channels2Samples/Channel19962Duration0.90531⁢s
normed ≔ Normalize⁡aud1000..1015:
The offset option is new in Maple 2020.
Download Help Document