Windows uses a structure called MMTIME to represent time. Low-level audio functions that use MMTIME include waveInGetPosition and waveOutGetPosition. The timeGetSystemTime function also uses MMTIME to represent system time.
The MMTIME structure is defined in the MMSYSTEM.H header file as follows:
typedef struct mmtime_tag {
UINT wType; // Contents of the union
union {
DWORD ms; // Milliseconds (wType = TIME_MS)
DWORD sample; // Samples (wType = TIME_SAMPLES)
DWORD cb; // Byte count (wType = TIME_BYTES)
struct { // SMPTE (wType = TIME_SMPTE)
BYTE hour; // Hours
BYTE min; // Minutes
BYTE sec; // Seconds
BYTE frame; // Frames
BYTE fps; // Frames per second
BYTE dummy; // Pad byte
} smpte;
struct { // MIDI (wType = TIME_MIDI)
DWORD songptrpos; // Song pointer position
} midi;
} u;
} MMTIME;
MMTIME can represent time in one or more different formats including milli-seconds, samples, SMPTE, and MIDI song-pointer formats. The wType field specifies the format used to represent time. Before calling a function that uses the MMTIME structure, you must set the wType field to indicate your requested time format. Be sure to check wType after the call to see if the requested time format is supported. If the requested time format is not supported, the time is specified in an alternate time format selected by the device driver and the wType field is changed to indicate the selected time format. MMSYSTEM.H defines the following flags for the wType field of the MMTIME structure:
Flag | Description |
TIME_MS | Milliseconds |
TIME_SAMPLES | Number of waveform audio samples |
TIME_BYTES | Number of waveform audio bytes |
TIME_SMPTE | SMPTE time |
TIME_MIDI | MIDI song-position pointer |
For details on using MMTIME with the waveOutGetPosition function, see “Getting the Current Playback Position,” later in this chapter.
Use the timeGetSystemTime or timeGetTime functions to get the system time. System time is defined as the time (in milliseconds) since Windows was started. For more information on timeGetSystemTime and timeGetTime, see Chapter 6, “Timer and Joystick Services.”