\(\text{LoadAudio}\)¶
You can use the \(\text{LoadAudio}\) function to load audio content from an
audio file. Note that this function is included as part of the audiofile
plug-in and requires the supplied libaudiofile
library to operate.
You can use the \loadaudio
backslash command to insert this function.
The following variants of this function are available:
\(\text{tuple } \text{LoadAudio} \left ( \text{<filename>} \right )\)
\(\text{tuple } \text{LoadAudio} \left ( \text{<filename>}, \text{<encoding>}, \text{<sample rate>}, \text{<number channels>} \right )\)
The \(\text{LoadAudio}\) function currently supports the following formats:
MPEG 1/2 Audio Layer III
Microsoft WAV format
Multiple raw audio formats
The \(\text{<filename>}\) parameter should be a text string holding the name of the audio file to be loaded.
The \(\text{<encoding>}\) parameter is used when loading raw audio files and is used to indicate how the audio data is encoded. Supported basic encoding formats are listed in Table 38.
Encoding |
\(\text{<encoding>}\) parameter value |
---|---|
A-law |
a-law |
alaw |
|
\(\mu\)-law (ITU-T Recommendation G.711) |
\(\mu\)-law |
\(\mu\text{law}\) |
|
8-bit differential pulse code modulation (DPCM) |
dpcm8 |
16-bit differential pulse code modulation (DPCM) |
dpcm16 |
8-bit pulse code modulation (PCM) |
pcm8 |
16-bit pulse code modulation (PCM) |
pcm16 |
24-bit pulse code modulation (PCM) |
pcm24 |
32-bit pulse code modulation (PCM) |
pcm32 |
Single precision floating point (32-bits/value, little-endian) |
float |
By default, all integer PCM formats are signed, little-endian. For the integer PCM formats, you can include any of the modifiers listed in Table 39. Note that each modifier can only be included once.
Function |
Modifier |
---|---|
Data is in little-endian format (default) |
|
|
|
Data is in big-endian format |
|
|
|
Data is signed |
|
Data is unsigned |
|
The \(\text{<sample rate}\) and \(\text{<number channels>}\) parameters are required for all raw audio formats and indicates the sample rate, in Hertz and the number of audio channels.
The function returns a tuple containing the sample rate, in Hz, followed by one or more real row matrices holding the audio samples for each channel. Floating point formats will provide the values as stored in the file, generally 0dBFS. Integer file formats will be converted to floating point and rescaled to 0dBFS.
Figure 168 shows the basic use of the \(\text{LoadAudio}\) function.