The Microsoft Cross-Platform Audio Creation Tool (XACT) engine provides a set of implicit variables that are available solely for use with runtime parameter controls to specify the behavior of attack and release envelopes for playback of a wave.
Variable Name | Type | Description |
---|---|---|
AttackTime | Cue-Instance | Counts the amount of time elapsed since the start of playback. This counter begins at zero and continues to increment until the cue is stopped. |
ReleaseTime | Cue-Instance | Counts the amount of time elapsed since a non-immediate request to stop playback. A stop request can occur either from programmer control or from a Stop event. This counter begins at zero and continues to increment until the cue is retriggered. |
These "time" variables are implicit for each instance of the cue. Unlike other implicit variables (such as NumCueInstances and Distance), they do not appear in the project tree. They are only accessible through the Variable column of the Runtime Parameter Control dialog box. They cannot be set or queried by the programmer, and they are not accessible through the XACT APIs.
The default behavior for playing a wave is to play it at a constant volume and pitch level, and to stop playback immediately when requested to stop.
The implicit time-related variables AttackTime and ReleaseTime can be used to define envelopes for volume and/or pitch levels, and override the default behavior. Levels controlled by envelopes are additive to the setting in the track; that is, from -96.00 dB to +6.00 dB for volume and -12 to 12 semitones for pitch.
For example, the audio designer might create a Runtime Parameter Control (RPC) that defines attack and release envelopes as shown in Figure 1.
Figure 1. Example RPC configuration
In a curve using the AttackTime variable, the leftmost point marks the start of playback, and the initial level for that setting. Remember that this is a relative level to the track's setting for that level. In this way, a volume level of 0 means the same as the track's volume level, while -96dB equates to silence.
The rightmost point of a curve using the AttackTime variable defines the sustain envelope, or the relative level at which the setting is held throughout the remainder of playback.
In a curve using the ReleaseTime variable, the leftmost point represents the initial request to stop playback (either from the program or a Stop event) and the initial amount to add to the sustain envelope's level. Therefore, this should always begin at zero for a smooth transition.
The rightmost point of a curve using the ReleaseTime variable represents the point at which playback is completely stopped. Note that a ReleaseTime curve will have no effect if either the program or the Stop event uses the IMMEDIATE flag.
It is possible for the content creator to create multiple curves for the same time variable and level, either within a single RPC or in several RPCs assigned to the same sound. This is not desirable, however, as it makes the behavior of stopping the wave ambiguous. If a conflict occurs for a volume release envelope, the shortest envelope takes precedence, although all others are still be applied. This is likely to produce unexpected results, and applying only a single envelope per level to a sound is recommended.