VII. Voice/audio related development questions

1. How do I play or record a .WAV file over the phone?
2. Can I use MCI (the Multimedia Control Interface) to play or record wave files?
3. Why do I keep getting an "invalid wave format" error when I call waveOutOpen?
4. What audio file formats does TAPI support?

Back to the FAQ index...


1. How do I play or record a .WAV file over the phone?

TAPI relies on the Windows low-level multimedia (wave) API to play and record audio files. Briefly, the TAPI application should call lineGetID with a device ID of "wave/out" to obtain the ID of the wave device associated with the telephony hardware. This ID that is returned is then used to call waveOutOpen, etc. Similarly, to record a call, call lineGetID with "wave/in" as the device ID, then use the returned ID to call waveInOpen, etc.

The actual implementation of the wave API is too complex to go into in a FAQ such as this. For a fully functional example program (including C source code) see the Voicemail sample application. If you are not familiar with working with the wave API, there are plenty of good multimedia programming books available that describe how to use it. "Windows 95 Multimedia & ODBC API Bible" is one book that covers the wave API, and it also contains a section on TAPI programming.

2. Can I use MCI (the Multimedia Control Interface) to play or record wave files?

No. MCI was considered as a means of playing and recording audio files when TAPI was first released by Microsoft. In fact some of the first TAPI applications and TSP's that supported audio did in fact use MCI. However it quickly became apparent that MCI did not provide the level of control nor the flexibility required by most TAPI voice applications. MCI was quickly dropped in favor of the low level multimedia (wave) API.

3. Why do I keep getting an "invalid wave format" error when I call waveOutOpen?

Not all TAPI hardware and service providers support the same wave audio file formats. Many TAPI environments don't even support standard Windows audio formats such as 11Khz PCM. Rather than writing your application so that it handles potentially dozens of audio file formats, you can take advantage of the Audio Compression Manager (ACM) component of the Windows multimedia system. ACM will convert between different audio formats in real-time so that an application can play or record one format when the hardware actually playing or recording the audio uses a different format. To enable ACM, simply include the WAVE_MAPPED flag (not to be confused with the WAVE_MAPPER device ID) in your calls to waveOutOpen or waveInOpen. Note that the WAVE_MAPPED flag is only available when writing 32-bit applications. This flag does not exist in the 16-bit wave API.

4. What audio file formats does TAPI support?

The formats of audio files depend on the application as well as the TSP being used. Different TSP's support different file formats, so it is in the best interest of TAPI application developers to support as many formats as possible. In most cases an application developer can significantly increase the number of supported formats by simply including the WAVE_MAPPED flag in all calls to waveOutOpen.

Because many TSP's use non-standard audio formats (meaning formats other than standard Windows PCM formats), you shouldn't rely on using the waveOutGetDevCaps function to identify the audio formats supported by the TSP. Many TSP's do not accurately report supported audio formats through waveOutGetDevCaps. The better approach is to call waveOutOpen with the WAVE_FORMAT_QUERY flag set (and most likely with WAVE_MAPPED set as well). The application would need to do this with each file format it plans to support in order to determine what file format(s) the TSP being used can support.


Back to the FAQ index...



charity-complexity