ID Number: Q77700
1.00
WINDOWS
Summary:
This article discusses two methods to improve playback performance for
a series of MCI wave files in an application developed for the
Microsoft Multimedia Windows environment.
The following code fragment demonstrates opening the device and wave
file at the same time. This method does not give the best performance.
mciopen.lpstrDeviceType = (LPSTR)"waveaudio";
mciopen.lpstrElementName = (LPSTR)lpWavefile;
// The following two fields must be initialized or the debugging
// version of MMSYSTEM will cause an unrecoverable application
// error (UAE).
mciopen.lpstrDeviceType = "\0";
mciopen.lpstrAlias = "\0";
dwFlags = MCI_OPEN_TYPE | MCI_OPEN_ELEMENT;
dwRes = mciSendCommand(0, MCI_OPEN, dwFlags,
(DWORD)(LPSTR)&mciopen);
To improve performance, open the device separately from the wave file
(element) and leave the device open until the last element in the
series has been played. Alternately, open and close elements but leave
the global (waveaudio) device open during the entire process. The
following code fragment demonstrates this process:
// Open the waveaudio driver separate from the element.
mciopen.lpstrDeviceType = (LPSTR)MCI_DEVTYPE_WAVEFORM_AUDIO;
dwFlags = MCI_OPEN_TYPE;
dwRes = mciSendCommand(0, MCI_OPEN, dwFlags,
(DWORD)(LPSTR)&mciopen);
The following code fragment demonstrates using the global device ID to
open the wave file separately:
dwFlags = MCI_OPEN_ELEMENT;
mciopen.lpstrElementName = (LPSTR)lpWaveName;
dwRes = mciSendCommand(wGlobalDeviceID, MCI_OPEN, dwFlags,
(DWORD)(LPSTR)&mciopen);
This allows the application to open and play wave files without
incurring the performance penalty involved with opening the device.
Another method to speed loading a wave file is to use the fully
qualified path. For example, rather than specifying LASER.WAV, specify
C:\MMWIN\MMDATA\LASER.WAV. If this is done, MCI is not required to
search the directories in the MS-DOS PATH environment variable for the
wave file.
Additional reference words: 1.00