Microsoft DirectX 8.1 (C++)

Latency and Bumper Time

Latency is the delay between the time at which the port receives a message and the time at which it has synthesized enough of a wave to play. The IDirectMusicPerformance8::GetLatencyTime method retrieves the current time plus the latency for the performance as a whole. This is the largest value returned by any of the ports' latency clocks.

The bumper is an extra amount of time allotted for code to run between the time that an event is put into the port buffer and the time that the port starts to process it. By default, the bumper length is 50 milliseconds. An application can change this value by using the IDirectMusicPerformance8::SetBumperLength method, and retrieve the current value by calling IDirectMusicPerformance8::GetBumperLength.

Here's an example of how latency time and bumper time are combined. Suppose an event is supposed to play at 10,000 milliseconds (ms). The latency of the port is known to be 100 ms, and the bumper length is at its default value of 50 ms. The performance therefore places the message into the port buffer at 9,850 ms.

Any tools that alter the time of messages must take latency and bumper time into account. If a tool stamps a message with a time that is already past the latency time, the note or other event will not play at the correct time.

Once a message has been placed in the port buffer, it no longer belongs to the performance and cannot be stopped from playing by using the IDirectMusicPerformance8::Invalidate method or by stopping the segment. The first message that can be invalidated has a time stamp equal to or greater than the current time plus the latency time and the bumper time. This value can be retrieved by using the IDirectMusicPerformance8::GetQueueTime method.

The following diagram, not to scale, illustrates the relationship of the times and durations retrieved by various methods. The current time is at the left, and the last time for which messages have been prepared is at the right. Remember that prepare time is only an approximation of the total timespan of messages in the queue at any given moment.

Playback times