Documentation ¶
Overview ¶
Package steamvoice wraps Steam's voice chat API.
This package is only available on clients.
See the Steam Voice documentation for more details. <https://partner.steamgames.com/doc/features/voice>
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotInitialized = errors.New("steamworks/steamvoice: interface has not been initialized") ErrDataCorrupted = errors.New("steamworks/steamvoice: voice data has been corrupted") ErrRestricted = errors.New("steamworks/steamvoice: user is chat restricted") ErrUnknown = errors.New("steamworks/steamvoice: unknown error") )
Errors returned by this package.
Additional errors include io.EOF and io.ErrShortBuffer.
Functions ¶
func DecompressVoice ¶
DecompressVoice decodes the compressed voice data returned by GetVoice.
The output data is raw single-channel 16-bit PCM audio. The decoder supports any sample rate from 11025 to 48000. See OptimalSampleRate for more information.
func OptimalSampleRate ¶
func OptimalSampleRate() uint32
OptimalSampleRate returns the native sample rate of the Steam voice decoder.
Using this sample rate for DecompressVoice will perform the least CPU processing. However, the final audio quality will depend on how well the audio device (and/or your application's audio output SDK) deals with lower sample rates. You may find that you get the best audio output quality when you ignore this function and use the native sample rate of your audio output device, which is usually 48000 or 44100.
func SetInGameSpeaking ¶
func SetInGameSpeaking(speaking bool)
SetInGameSpeaking lets Steam know that the user is currently using voice chat in game.
This will suppress the microphone for all voice communication in the Steam UI.
func StartRecording ¶
func StartRecording()
StartRecording starts voice recording.
Once started, use Reader to get the data, and then call StopRecording when the user has released their push-to-talk hotkey or the game session has completed.
func StopRecording ¶
func StopRecording()
StopRecording stops voice recording.
Because people often release push-to-talk keys early, the system will keep recording for a little bit after this function is called. As such, Reader should continue to be read from until it returns io.EOF. Only then will voice recording be stopped.
Types ¶
type VoiceReader ¶
type VoiceReader struct{}
VoiceReader is the type of Reader. It contains no state and should not be used directly. Instead, use the steamvoice.Reader variable.
var Reader VoiceReader
Reader is a stream of captured audio data from the microphone buffer.
The compressed data can be transmitted by your application and decoded back into raw audio data using DecompressVoice on the other side. The compressed data provided is in an arbitrary format and is not meant to be played directly.
This should be read from once per frame, and at worst no more than four times a second to keep the microphone input delay as low as possible. Reading any less frequently may result in gaps in the returned stream.
It is recommended that you pass in an 8 kilobytes or larger destination buffer for compressed audio. Static buffers are recommended for performance reasons. However, if you would like to allocate precisely the right amount of space for a buffer before each call you may use Reader.Available() to find out how much data is available to be read.
func (VoiceReader) Available ¶
func (VoiceReader) Available() (int, error)
Available returns the number of bytes of compressed voice data currently available from Read.