AudioTools - Maple Programming Help

Home : Support : Online Help : Programming : Audio Processing : AudioTools/Modulate

AudioTools

 Modulate
 modulate one audio recording using another

Parameters

 audArray - Array, Vector, or Matrix containing the audio to be modulated maskArray - Array, Vector, or Matrix specifying the modulation mask

Description

 • The Modulate command uses one audio recording to modulate another.
 • The audArray parameter specifies the audio to be modulated, and must be a dense, rectangular, one or two dimensional Array, Vector, or Matrix with datatype=float[8].
 • The maskArray parameter specifies the modulation mask, and must be a dense rectangular Array, Vector, or Matrix with datatype=float[8], and the same dimensions as audArray.
 • The Modulate operation consists of multiplying each sample in the audArray by the corresponding sample in the maskArray, and writing the result to the output. Notice that this operation is commutative; the data and mask can be interchanged and will still give the same result.
 Samples with a value of 1.0 in the maskArray will cause the corresponding audArray sample to be copied verbatim into the output. Samples of value 0.0 in the mask will result in 0.0 in the output, regardless of the value of the corresponding audio sample. Samples of value -1.0 in the mask will invert the value of the corresponding audio sample.
 • For example, consider a mask M that gradually transitions from 1.0 on the left to 0.0 on the right. Using the Modulate command with this mask and audio data A produces audio data that starts out sounding like A and fades to silence. Modulating audio B with the inverse of M, namely $1-M$, will produce audio data that starts out silent and intensifies to full volume.
 Combining these two audio objects by simple addition, $A+B$, yields audio data that fades from A to B.

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{AudioTools}:-\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{dims}≔\left[\mathrm{rtable_dims}\left(\mathrm{aud}\right)\right]$
 ${\mathrm{dims}}{≔}\left[{1}{..}{19962}{,}{1}{..}{2}\right]$ (2)
 > $\mathrm{left}≔\mathrm{aud}\left[\mathrm{dims}\left[1\right],1\right]$
 ${\mathrm{left}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (3)
 > $\mathrm{right}≔\mathrm{aud}\left[\mathrm{dims}\left[1\right],2\right]$
 ${\mathrm{right}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (4)
 > $\mathrm{weird}≔\mathrm{Modulate}\left(\mathrm{left},\mathrm{right}\right)$
 ${\mathrm{weird}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (5)