Microsoft DirectX 8.1 (Visual Basic)

Changing the Tempo

The tempo of a performance dictates the conversion between the two types of time used in DirectMusic, which in turn controls the resolution of events to musical boundaries. (See Clock Time vs. Music Time.) The tempo track of the control segment usually manages the tempo, but it is also possible for an application to set the tempo dynamically.

There are two ways to do so: by setting the master tempo and by sending a tempo message.

The master tempo is a factor by which all tempos in the performance are multiplied. For example, if you set the master tempo by calling DirectMusicPerformance8.SetMasterTempo with a parameter of 0.75, and then play a segment that has a tempo of 120 beats per minute, the segment plays with a tempo of 90.

Sending a tempo by using the DirectMusicPerformance8.SendTempoPMSG method changes the tempo at the time for which the message is stamped. The new tempo is valid until another tempo message is sent or the tempo is changed by a control segment. The tempo value can be modified by the master tempo.

The following call, where perf is a DirectMusicPerformance8 object, immediately sets the tempo to 100 beats per minute. Note that if you pass 0 as the lTime parameter to signify that the message is to go out immediately, you must also set the DMUS_PMSGF_REFTIME flag.

Call perf.SendTempoPMSG(0, DMUS_PMSGF_REFTIME, 100)