Documentação do Steamworks
Esta página não está disponível no seu idioma.Esta página de documentação não está atualmente disponível no seu idioma, portanto a versão em inglês será apresentada abaixo.
The Steam Voice API is a set of functions that allow you record audio from the user's microphone. This can be used to implement voice chat or a voice command system.
Voice Chat Integration
Voice chat in your game can be implemented using the following steps:
First call ISteamUser::StartVoiceRecording to begin recording the users microphone, this could be called whenever the user is pressing a push-to-talk hotkey or at the start of the gameplay session if the microphone should always be recording. Depending on your game either may be preferable, but giving players the option for both always-on, and push-to-talk is ideal. It's rarely a good idea to default to always-on though, and if your game supports more than 4 players then always-on is never recommended. Then when the player releases their push-to-talk hotkey, or the gameplay session ends you should call ISteamUser::StopVoiceRecording to stop recording.
If the user is using push-to-talk voice chat, you can call ISteamFriends::SetInGameVoiceSpeaking when you start and stop recording to mute any voice chat the user may be doing through the Steam friends UI. Ideally you would give players the option to enable/disable this functionality.
After you start recording you should call ISteamUser::GetAvailableVoice each frame to check if there's any compressed voice data available. If voice data is available, then you need to use ISteamUser::GetVoice to get the latest audio data from the microphone.
Once you have the voice data, you'll likely want to send it to the other players. The Steam Voice API does not provide the means of doing so directly but, this can be done with any networking library of your choice. The Steam peer-to-peer networking APIs are a great option for this.
When the target users receive the voice data, they call ISteamUser::DecompressVoice to turn the compressed data back into audio.
Optionally you may want to use ISteamUser::GetVoiceOptimalSampleRate to get the sample rate of the Steam Voice decompressor before calling ISteamUser::DecompressVoice, this will result in lower CPU usage, but may sound worse.
The Steamworks API Example Application (SpaceWar)
has a high quality implementation of the Steam Voice API. You can find the relevant pieces in the
Visit the Steamworks Developer Discussions
to search for questions others have asked, and ask questions of your own.