Sounds Logical
Send Page To a Friend

Table Of Contents Previous Page

[M-Pack 1 overview]

M-Pack 1: WAV file processing: MATLAB function reference

winplaywav
Version 1.2 Requires MATLAB 6.0 (R12) or later

Play a WAV file on the default Windows soundcard from within the MATLAB environment.

Note: only supports sample rates and bit-resolutions compatible with given soundcard driver (typically 8000, 11025, 22050, or 44100 Hz and 8- or 16-bits).

File format: mex-file (dll)
Editable source code:
no
Utilises non-editable functions: yes (Windows API dll's)
Platform:
PC/Windows
Required MATLAB Toolboxes: none (except core MATLAB)
Demo version limitations: none (except for displaying of demo banner)
Syntax:
 

winplaywav(WavFileName);

  winplaywav(WavFileName,LoopFlag);
Arguments:
Inputs:
WavFileName

[Optional] string containing the filename (including full path if not located in working directory) of the WAV file to be played. By default, the WAV file is played in 'asynchronous mode', i.e. the function returns immediately after the playback is initiated.

If omitted, the currently-playing WAV file (if any) is stopped.

LoopFlag

[Optional] flag for setting loop and 'synchronous' mode. If value of 1, WAV file is looped indefinitely (in 'asynchronous mode'). If value of 2, the WAV file is played once in 'synchronous mode', i.e. the function does not return until the playback is completed. This is useful for playing files sequentially via successive calls to winplaywav.

Note: the looping playback can be stopped at any time by issuing a winplaywav command with no arguments.

 

This function is implemented as a mex function (Windows DLL) called winplaywav.dll. It utilizes the standard Windows MME WAVE drivers to access the soundcard. The accompanying winplaywav.m file simply contains the help comments for access via the usual MATLAB 'help' command.

 

  playwavgui GUI for convenient access to winplaywav
Examples:
Play once through the WAV file myWAVfile.wav located in the working directory, returning immediately after playback initiated:
  winplaywav('myWAVfile.wav');
   
Stop the playback:
  winplaywav;
   
Play once through (the first instance of) the file myWAVfile.wav found on the MATLAB path, returning immediately after playback initiated:
  winplaywav(which('myWAVfile.wav'));
   
Play once through the WAV file myWAVfile.wav located in directory C:\, returning immediately after playback initiated:
  winplaywav('C:\myWAVfile.wav');
   
Loop indefinitely through the file myWAVfile.wav until winplaywav is called without any arguments:
  winplaywav('C:\myWAVfile.wav',1);
   
Play once through the WAV file myWAVfile.wav located in directory C:\ in 'synchronous mode' i.e. witholding the function return until after playback completed:
  winplaywav('C:\myWAVfile.wav',2);

Top Of Page Table Of Contents Previous Page

Send Page To a Friend

home - news - products - store - support - site map - company info
© 2007 Sounds Logical. All rights reserved.
Sounds Logical
legal notice - privacy statement