sound

Purpose

Convert vector into sound.

Synopsis

sound(y)
sound(y,Fs)

Description

sound(y) sends the signal in vector y to the speaker on the following computers:

  • SPARC
  • Hewlett-Packard
  • SGI
  • Macintosh
  • IBM-compatible
    The vector is auto-scaled to provide maximum amplitude. If your system does not include the hardware needed to play sound files, the sound function displays an error message.

    The sound is played at the default sample rate. On the SPARC, for example, the sample rate is fixed at 8192 Hz. On the Macintosh, the default sample rate is 22.255K Hz.

    sound(y,Fs), on the PC, Macintosh, and SGI, plays the sound at the specified sample frequency Fs, where Fs is measured in Hz.

    The sound input vector y is automatically scaled so that the maximum and minimum values in y correspond to the maximum and minimum input ranges allowed by the sound hardware. On the Macintosh a,d SGI, the volume control on the Control Panel determines the final sound level.

    See the function saxis to override the automatic scaling and control the sound range explicitly.

    Examples

    There are a number of MAT-files in the sounds directory that contain example sounds, mostly sampled at 8192 Hz. List a directory of them with the command what sounds. Each MAT-file contains a vector y with the sound, and a scalar Fs with its associated sample frequency. Load one of them into the workspace, play it, and plot it with

    load handel
    sound(y,Fs)
    t = (0:length(y)-1)/Fs;
    plot(t,y)
    

    See Also

    auread, auwrite, saxis
    

    (c) Copyright 1994 by The MathWorks, Inc.