ToMono - Maple Help

AudioTools

 ToMono
 convert a multi-channel audio recording to monophonic
 ToStereo
 convert an audio record to stereophonic (or more channels)

 Calling Sequence ToMono(audArray) ToStereo(audArray, optNumChannels)

Parameters

 audArray - Array, Vector, or Matrix containing the audio data to convert optNumChannels - (optional) integer representing the number of input channels

Description

 • The ToMono command takes multi-channel audio data and produces a single-channel monophonic audio object.
 • The ToStereo command takes single channel monophonic audio data and produces two-channel stereo audio (with corresponding samples in both channels having the same values). This is useful if a monophonic recording is to be combined in some way with a stereo recording.
 The optional optNumChannels parameter of ToStereo can be used to specify that more than two channels are to be created. The number of channels must be a multiple of the number of input channels, and each input channel is repeated an appropriate number of times in the output.
 • The audArray parameter specifies the data to convert, and must be a dense, rectangular, one or two dimensional Array, Vector, or Matrix with datatype=float[8].
 • If either command is passed audio data that is already of the correct type, the audio data is returned. Otherwise, a new object of the appropriate type is created.

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{aud}\left[2000\right]$
 $\left[\begin{array}{cc}{-0.312500000000000}& {0.771653543307087}\end{array}\right]$ (2)
 > $\mathrm{mono}≔\mathrm{ToMono}\left(\mathrm{aud}\right)$
 ${\mathrm{mono}}{≔}\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{mono}\left[2000\right]$
 ${0.229576771653543}$ (4)
 > $\mathrm{stereo_mono}≔\mathrm{ToStereo}\left(\mathrm{mono}\right)$
 ${\mathrm{stereo_mono}}{≔}\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]$ (5)
 > $\mathrm{stereo_mono}\left[2000\right]$
 $\left[\begin{array}{cc}{0.229576771653543}& {0.229576771653543}\end{array}\right]$ (6)
 > $\mathrm{quad_stereo}≔\mathrm{ToStereo}\left(\mathrm{aud},4\right)$
 ${\mathrm{quad_stereo}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {4}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (7)
 > $\mathrm{quad_stereo}\left[2000\right]$
 $\left[\begin{array}{cccc}{-0.312500000000000}& {-0.312500000000000}& {0.771653543307087}& {0.771653543307087}\end{array}\right]$ (8)