reads audio data from a file into an Array, Vector, or Matrix - Maple Help

Online Help

All Products    Maple    MapleSim

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

AudioTools[Read] - reads audio data from a file into an Array, Vector, or Matrix

Calling Sequence

Read(fileName, optArray, format=fmtDesc)




string; the pathname of the audio file to read



(optional) Array, Vector, or Matrix to read the audio into



(optional) specification of the audio file format



The Read command reads an audio file in one of the supported formats and returns an Array containing the audio.


If optArray is specified, it must be a dense, rectangular, one or two dimensional Array, Vector, or Matrix with datatype=float[8]. If not specified, the Read command will allocate an Array appropriate for the audio data being read.


If the option format=fmtDesc is specified, fmtDesc must correspond to one of the values in AudioTools[Formats]. If not specified, the Read attempts to determine the format from the fileName.


If the audio data has a single channel, the Array will have only one dimension. If the audio data has more than one channel, the Array will have two dimensions.  The second dimension will range from 1 to C where C is the number of channels, 1 for mono, 2 for stereo, and so on.


The first dimension of the Array corresponds to the length, in samples, of the audio data. A single channel occupies a single column in the Array.


When Read is passed and Array, Vector, or Matrix, it must be writable and have one or two dimensions. The first dimension must correspond to the length of the audio data, for example M..M+length1.


If the second (possibly omitted) dimension does not correspond to the number of channels in the audio data, it will be converted appropriately while being read. For example, reading Stereo audio into a Vector or one-dimensional Array will produce Mono audio data.


Sample values are stored in the audio Array, Vector, or Matrix as floating point values ranging from -1.0 to 1.0.


On return from Read, the returned Array, Vector, or Matrix will have three numeric attributes describing the data. The first is the sample rate, in samples per second. The second is the number of bits per sample that were recorded in the file. The third is the sub-format of the file, if applicable (or zero otherwise - some file formats, like ".WAV", have a number of sub-formats, like PCM and ADPCM).


For compressed formats such as an ADPCM ".WAV" file, Read decompresses the data. The resulting Array, Vector, or Matrix will contain the decompressed data, although the attributes will still reflect the origin of the data. For example, an ADPCM file sampled at 11.025kHz will have attributes 11025,4,2, since ADPCM records 4 bits per sample, and is sub-format 2.





aud:= 1..19962 x 1..2 ArrayData Type: float8Storage: rectangularOrder: C_order









mono:= 1 .. 19962 ArrayData Type: float8Storage: rectangularOrder: C_order





See Also

Array, AudioTools, AudioTools[Create], AudioTools[Formats], AudioTools[Write], Matrix, Vector

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam