Skip to content

audioplayer

audio · scripts/audio/audioplayer.m

AUDIOPLAYER  Play audio data through an audio output device.

  P = AUDIOPLAYER (Y, FS)
  P = AUDIOPLAYER (Y, FS, NBITS)
  P = AUDIOPLAYER (Y, FS, NBITS, ID)
  P = AUDIOPLAYER (R)
  P = AUDIOPLAYER (R, ID)

  Y is a vector (one channel) or a samples-by-channels matrix of audio
  samples: floating point values in [-1, 1], or int8 / uint8 / int16 /
  int32 samples.  FS is the sample rate in Hz, NBITS the playback
  resolution (8, 16 or 24; default 16, or 8 for 8-bit data) and ID the
  output device (see AUDIODEVINFO; -1 or omitted selects the system
  default).  R is an audiorecorder object whose recording is played.

  Methods: play, playblocking, pause, resume, stop, isplaying, get, set.
  Properties: SampleRate, BitsPerSample, NumberOfChannels, DeviceID,
  CurrentSample, TotalSamples, Running, Tag, UserData, StartFcn, StopFcn,
  TimerFcn, TimerPeriod, Type.

  The player is a handle object.  Playback is done by the Java Sound API
  of the bundled Java runtime; PLAY returns immediately while the sound
  plays in the background.  StartFcn runs when playback starts; StopFcn
  runs when STOP is called, when PLAYBLOCKING finishes, and when the end
  of a background playback is noticed by ISPLAYING / Running; TimerFcn
  runs every TimerPeriod seconds during PLAYBLOCKING.  Without a usable
  audio device PLAY raises an error.