audioread
Gets audio data and the sampling rate from an audio file using functions defined in the Audio library.
Syntax
[m, r] = audioread(filename)
[m, r] = audioread(filename, type)
[m, r] = audioread(filename, range)
[m, r] = audioread(filename, range, type)
Inputs
- filename
- Audio file name. Currently, only .wav format files are supported.
- type
- Optional data type which the output m will contain. Valid values are 'double' (default value) are 'native'.
- range
- Optional two-element positive integral vector specifying the start and end frames that the output m will contain.
Outputs
- m
- Two dimensional real matrix containing the audio data.
- r
- Sample rate or the samples(blocks) per second.
Examples
Get audio file data and the sample rate:
[m, r] = audioread('audio1.wav');
sz = size(m);
printf('Size of audio data is [%d x %d], sample rate is %d\n', sz(1), sz(2), r)
Size of audio data is [268237 x 2], sample rate is 8000
Get audio file data with native data type for a defined range of samples:
m = audioread('audio1.wav', [1 5], 'native')
m = [Matrix] 4 x 2
-241 3
-285 -29
-109 44
-50 12