Microsoft DirectX 8.1 (Visual Basic)

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 DirectMusicPerformance8.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 (ms). An application can change this value by using the DirectMusicPerformance8.SetBumperLength method, and retrieve the current value by calling DirectMusicPerformance8.GetBumperLength.

Here's an example of how latency time and bumper time are combined. Suppose an event is supposed to play at 10,000 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.

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 DirectMusicPerformance8.Invalidate or the DirectMusicPerformance8.StopEx method. The first message that can be invalidated has a time stamp equal to or greater than the current time plus the latency and bumper time. This value can be retrieved by using the DirectMusicPerformance8.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.

The methods in the illustration are from the C++ API, but most have similar names in DirectX for Visual Basic. The GetTime method in the illustration is equivalent to DirectMusicPerformance8.GetClockTime.

Playback times