Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

auread - Read NeXT/SUN (.au) sound file

Graphical Interface

As an alternative to auread, use the Import Wizard. To activate the Import Wizard, select File > Import Data.

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:

[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 demo 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

audioplayer, audiorecorder, auwrite, mmfileinfo, sound, wavread

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS