Latency and Bumper Time

Latency is the delay between when the port receives a musical message and when it has synthesized enough of a wave to play. The IDirectMusicPerformance::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 execute between the time that a musical event is put into the port buffer and the time that the port actually starts to process it. By default the bumper length is 50 milliseconds. An application can change this value by using the IDirectMusicPerformance::SetBumperLength method and retrieve the current value by calling IDirectMusicPerformance::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. 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.

Note that 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 IDirectMusicPerformance::Invalidate or IDirectMusicPerformance::Stop methods. The first message that can be invalidated will have 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 IDirectMusicPerformance::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.