Simple Audio Playback

[The feature associated with this page, Waveform Audio, is a legacy feature. It has been superseded by WASAPI and Audio Graphs. WASAPI and Audio Graphs have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use WASAPI and Audio Graphs instead of Waveform Audio, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

You can use the following functions to play waveform audio in your application in a single function call.

Function Description
MessageBeep Plays the sound that corresponds to a specified system-alert level.
sndPlaySound Plays the sound that corresponds to the system sound entered in the registry or the contents of the specified file.
PlaySound Provides all the functionality of sndPlaySound and can directly access resources.

 

The MessageBeep function is a standard part of the Win32 API; because its capabilities are very limited and it is documented elsewhere, it is not discussed here.

The functions listed support the following sources of waveform audio:

  • Waveform-audio files associated with system-alert levels
  • Waveform-audio files specified by entries in the registry
  • In-memory WAVE resources
  • Waveform-audio files specified by name

The sndPlaySound and PlaySound functions load an entire waveform-audio file into memory and, in effect, limit the size of the file they can play. Use sndPlaySound and PlaySound to play waveform-audio files that are small — up to about 100K. These two functions also require the sound data to be in a format that is playable by one of the installed waveform-audio drivers, including the wave mapper.

For larger sound files, use the Media Control Interface (MCI) services. For more information, see MCI.