Documentation Center

  • Trial Software
  • Product Updates

auread

Read NeXT/SUN (.au) sound file

    Note:   auread will be removed in a future release. Use audioread instead.

Syntax

y = auread(aufile)
[y,Fs] = auread(aufile)
[y,Fs,nbits] = auread(aufile)
[___] = auread(aufile,N)
[___] = auread(aufile,[N1 N2])
siz = auread(aufile,'size')

Description

y = auread(aufile) loads a sound file specified by the string aufile, returning the sampled data in y. The .au extension is appended if no extension is given. Amplitude values are in the range [-1,+1]. auread supports multichannel data in the following formats:

  • 8-bit mu-law

  • 8-, 16-, and 32-bit linear

  • Floating-point

[y,Fs] = auread(aufile) returns the sample rate (Fs) in Hertz used to encode the data in the file.

[y,Fs,nbits] = auread(aufile) returns the number of bits per sample (nbits).

[___] = auread(aufile,N) returns only the first N samples from each channel in the file.

[___] = auread(aufile,[N1 N2]) returns only samples N1 through N2 from each channel in the file.

siz = auread(aufile,'size') returns the size of the audio data contained in the file in place of the actual audio data, returning the vector siz = [samples channels].

Examples

Create a sound file from the example file handel.mat, and read portions of the file back into MATLAB®:

% Create .au file in current folder.
load handel.mat
 
hfile = 'handel.au';
auwrite(y, Fs, hfile)
clear y Fs
 
% Read the data back into MATLAB, and listen to audio.
[y, Fs, nbits] = auread(hfile);
sound(y, Fs);

% Pause before next read and playback operation.
duration = numel(y) / Fs;
pause(duration + 2)
 
% Read and play only the first 2 seconds.
nsamples = 2 * Fs;
[y2, Fs] = auread(hfile, nsamples);
sound(y2, Fs);
pause(4)
 
% Read and play the middle third of the file.
sizeinfo = auread(hfile, 'size');
 
tot_samples = sizeinfo(1);
startpos = tot_samples / 3;
endpos = 2 * startpos;
 
[y3, Fs] = auread(hfile, [startpos endpos]);
sound(y3, Fs);

See Also

| | | | |

Was this topic helpful?