Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Sound file handling > wavread


reads sound data or querries data info from a .wav audio file


Info = wavread(wavfile, 'info')
s = wavread(wavfile, 'size')
y = wavread(wavfile)
y = wavread(wavfile, n)
y = wavread(wavfile, [i1 i2])
[y, Fs, bits] = wavread(..)



string: path and file name pointing to the audio file. Included heading constant strings SCI, TMPDIR, SCIHOME, or home are automatically expanded. The .wav extension is appended if no extension is given.


positive integer: number of first samples to get, per channel.

[i1 i2]

positive integers, to select and return from each channel the samples #i1 to #i2.


Matrix: values of sound amplitudes in [-1,+1], with one row per channel.


integer: sampling frequency in Hz = number of samples per second per channel.


Positive integer: number of bits for y values.


Row vector of 8 decimal integers describing the recorded signal. See the description section for details.


Utility function to read .wav sound file. wavread(wavfile) loads a sound file specified by the string wavfile, returning the sampled data in y. Amplitude values are in the range [-1,+1]. Supports multi-channel data in the following formats: 8-, 16-, and 32-bit linear, and floating point.

[y,Fs,bits]=wavread(wavfile) returns the sample rate (Fs) in Hertz and the number of bits per sample used to encode the data in the file.

wavread(wavfile,n) returns the first n samples from each channel.

wavread(wavfile,[n1,n2]) returns samples n1 to n2.

wavread(wavfile,'size') returns the size of the audio data contained in the file in place of the actual audio data, returning the vector as [channels samples].

wavread(wavfile,'info') returns information about the audio data contained in the file, instead of the actual audio data, returning a row vector with the following components:

(1) encoding code: AKA format category: positive integer = standard id of the type of data encoding. Supported formats: 1 (PCM), 3 (normalized floating point).
(2) number of channels: Number of simultaneous single-valued collected signals = size(y,1).
(3) sampling frequency: number of samples recorded for each channel, per second.
(4) average bytes per second: For plain PCM it is the sampling rate multiplied by the number of channels and the number of bytes per sample. For compressed formats it is approximately the total data length in bytes divided by the duration of the sound.
(5) block alignment: The number of bytes associated with each sampling instant. For the plain PCM uncompressed format, it is equal to the number of channels multiplied by the number of bytes per channel.
(6) bits per sample (per channel): Number of bits used to quantize each value of the sound amplitude.
(7) bytes per sample (per channel): Number of bytes assigned to each individual value of the sound amplitude.
(8) length of sound data (per channel): The total number of samples on each channel = size(y,2). Hence, the record's duration is Info(8)/Info(3).


File = "SCI/modules/sound/demos/chimes.wav";
wavread(File, "size")
wavread(File, "info")
y = wavread(File, 5)     // the first five samples
y = wavread(File, [4 7]) // only samples #4 to #7
[y, Fs, bits] = wavread(File); Fs, bits
plot2d(y(1,:)) // first channel
plot2d(y(2,:)) // second channel
--> wavread(File, "size")
 ans  =
   2.   13921.

--> wavread(File, "info")
 ans  =
   1.   2.   22050.   88200.   4.   16.   2.   13921.

--> y = wavread(File, 5)     // the first five samples
 y  =
   0.000061    0.0002747   0.0002136   0.0001526   0.0000916
   0.0000916   0.0001831   0.000061    0.          0.0000916

--> y = wavread(File, [4 7]) // only samples #4 to #7
 y  =
   0.0001526   0.0000916   0.0000305  -0.0000305
   0.          0.0000916   0.000061    0.0000916

--> [y, Fs, bits] = wavread(File); Fs, bits
 Fs  =

 bits  =

See also

Report an issue
<< soundsec Sound file handling wavwrite >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:49:21 CET 2020