wave_hdr_new
Allocates a new WaveHdr and return a handle to it.
wave_hdr_free hdr
Deallocate the WaveHdr hdr.
wave_hdr_get_format hdr
wave_hdr_get_num_of_chan hdr
wave_hdr_get_samples_per_sec hdr
wave_hdr_get_block_align hdr
wave_hdr_get_bits_per_sample hdr
wave_hdr_get_bytes_per_sec hdr
wave_hdr_get_data_len hdr
These functions or macros return the value of the corresponding slot in the WaveHdr data structure.
- Format should be either 1 (PCM), 6 (A-law), or 7 (μ-law)
- Number of channels is 1 for mono, 2 for stereo.
- Sampling rate is in sample/sec (Hz)
- block Alignment = numOfChan * bitsPerSample / 8
1 for 8-bit mono, 2 for 16-bit mono, 2 for 8-bit stereo, 4 for 16-bit stereo- Bits per sample is the sample resolution in bits (8 or 16).
- Streaming rate of the data (samplesPerSec * blockAlign)
- Data length is the length of audio data in bytes.
wave_hdr_set_format hdr format
wave_hdr_set_num_of_chan hdr numOfChan
wave_hdr_set_samples_per_sec hdr rate
wave_hdr_set_block_align hdr blockAlign
wave_hdr_set_bits_per_sample hdr resolution
wave_hdr_set_bytes_per_sec hdr resolution
wave_hdr_set_data_len hdr len
These functions or macros set the corresponding slot in the WaveHdr data structure.
- Format should be either 1 (PCM), 6 (A-law), or 7 (μ-law)
- Number of channels is 1 for mono, 2 for stereo.
- Sampling rate is in sample/sec (Hz)
- Sets the blockAlign field in the header.
- block Alignment = numOfChan * bitsPerSample / 8
- Bits per sample is the sample resolution in bits (8 or 16).
- Streaming rate of the data (samplesPerSec * blockAlign)
- Data length is the length of audio data in bytes.
wave_hdr_parse bp hdr
Parses the header chunk from the wave file in bp and stores it into WaveHeader hdr. Returns the number of bytes advanced in bp, or 0 if the file being read is an invalid wave file
wave_hdr_encode hdr bp
Encodes the WaveHdr hdr into the BitParser bp, and returns the number of bytes written into the BitStream.
The following functions are used to control output to Wave compatible audio devices (e.g., SoundBlaster cards). They are supported only on Win32 platforms.
A typical calling sequence for this library is:
# Assume hdr is an initialized WaveHdr, and # audio is an AudioBuffer wave_out_open $hdr; # open the output device wave_out_prep_play $audio; # Get setup wave_out_play 8000; # Play it while {![wave_out_done]} { after 10; # Wait for play to finish } wave_out_close; # clean up
wave_out_open hdr
Opens a wave audio output device for the wave format specified by hdr. Only one device can be open at a time.
This function throws an error if the device is already open or another error occurs (e.g., unsupported format)
wave_out_close
Closes the current opened Wave Output Device. This function throws an error if the wave output device is not open.
wave_audio_prep_play audio
This function does any preparation needed before sending audio to the output device. This allows for the lowest latency possible when calling WaveAudioPlay(). The implementation makes a copy of the pointer to the audio buffer, so this pointer should not be free'd if WaveAudioPlay will be called later (the contents of the buffer can be modified, but not the buffer itself). This function throws an error if the wave output device is not open.
wave_audio_play length
Plays length bytes of the audio data previously specified via WaveAudioPrepPlay This function throws an error if the wave output device is not open.
wave_out_done
Determine whether the audio data currently playing (via a previous call to WaveAudioPlay) is finished. Returns 1 if and only if the previously played wave audio is finished. Note it returns 0 if nothing has been played before. (i.e., initially right after the device is opened).
Last updated : Saturday, November 14, 1998, 07:50 PM