Platform SDK: DirectX

Master Clock

[Visual Basic]

This topic pertains only to applications written in C++. DirectX for Visual Basic does not enable applications to select a different master clock.

[C++]

To guarantee accurate timing with an acceptably low latency, DirectMusic incorporates a master clock in kernel mode. This clock is based on a hardware timer. DirectMusic automatically selects the system clock as the master clock, but an application can select a different one, such as the wave-out crystal on a sound card.

The master clock is a high-resolution timer that is shared by all processes, devices, and applications that are using DirectMusic. The clock is used to synchronize all music playback in the system. It is a standard IReferenceClock interface. The IReferenceClock::GetTime method returns the current time as a 64-bit integer (defined as the REFERENCE_TIME type) in increments of 100 nanoseconds.

To obtain an interface to the master clock, call the IDirectMusic::GetMasterClock method.

You can choose a different master clock for your application, but only if there are no other DirectMusic applications running. First, you get descriptions of all devices that can serve as the master clock by using the IDirectMusic::EnumMasterClock method. Once you have obtained the GUID of the device that you want to use as the master clock, you pass this to the IDirectMusic::SetMasterClock method.