?/TD> |
Microsoft DirectX 9.0 |
To keep the performance requirements of Microsoft?DirectPlay?Voice low, voice data should be transmitted only when the user is speaking. There are three ways to control voice data transmission.
You select which transmission control method to use when you call IDirectPlayVoiceClient::Connect to connect to a voice session. To specify the type of transmission control you want to use, set the appropriate flag in the DVCLIENTCONFIG structure's dwFlags member. You can change the method during the session by calling IDirectPlayVoiceClient::SetClientConfig and changing the flag setting.
Push-to-talk transmission control is analogous to pushing the Talk button on a two-way radio. It adds reality to certain game genres such as first-person shooters. Push-to-talk requires users to actively select when they want to transmit voice data. There is no danger that anything besides voice data will activate transmission. In addition, requiring users to actively select when they want to speak reduces the number of users speaking at once.
Push-to-talk transmission control requires more design and development than voice activation. In particular, you must have some way of detecting when the user has chosen to start transmitting, typically by pushing a controller button or a key on the keyboard. When you detect that the user wants to start talking, you must start transmission by calling IDirectPlayVoiceClient::SetTransmitTargets, and provide an array of target identifiers (IDs) that will receive the transmission. When you detect that the user is finished, stop transmission by calling IDirectPlayVoiceClient::SetTransmitTargets again, with the target array set to NULL and the number of targets set to 0.
Push-to-talk is the default transmission control method. It is enabled unless you explicitly select voice activation by setting the DVCLIENTCONFIG_AUTOVOICEACTIVATED or DVCLIENTCONFIG_MANUALVOICEACTIVATED flag in the DVCLIENTCONFIG structure.
With voice activated transmission control, the microphone input is constantly analyzed to determine if the user is speaking. When the input exceeds a threshold level, voice activation is triggered, and the user begins transmitting. Ideally, transmission starts when the user starts speaking, and stops when the user finishes.
Voice activation is simpler for the user than push-to-talk, because the user must only speak into the microphone. It is also more easily coded because you do not need to detect when the user wants to start or stop transmitting. You specify voice activation when you connect, and transmission control is handled by the system from that point on. However, one drawback of voice activation is that it can result in unwanted transmissions. In addition to speech, transmission can be triggered by sounds such as the user breathing directly on the microphone, high levels of ambient sound in a noisy environment, or a set of external speakers playing the game's audio background. Low-quality microphones can increase the probability of unwanted transmission.
Voice activation can be either automatic or manual. To specify one of these modes, set the DVCLIENTCONFIG_AUTOVOICEACTIVATED or DVCLIENTCONFIG_MANUALVOICEACTIVATED flag, respectively, when you connect to the voice session.
Automatic voice activation is the preferred transmission control method for most applications. In this mode, the threshold for transmission is determined automatically by the system. The threshold level is adaptive, adjusting itself automatically to the input signal.
With manual voice activation, you must explicitly set a threshold when you connect to the voice session by assigning a value to the dwThreshhold member of DVCLIENTCONFIG. The system will not change this value for you. If conditions change, and the threshold value is no longer adequate, you must call IDirectPlayVoiceClient::SetClientConfig and specify a new value for dwThreshhold.