HolyLib Wiki

voicechat

voicechat

This library adds a few functions allowing handling of the voicechat.

Recently Changed

This was recently changed in version (0.72).

This module caused a crash on server shutdown in version 0.7 and 0.71, this was fixed in the 0.72 release.
See https://github.com/RaphaelIT7/gmod-holylib/issues/41 for more.

Methods

voicechat.ApplyEffect( table effectData, VoiceData voiceData, function callback = nil )
Applies the given effectData to the given Data/Stream.
If a callback is specified it WONT return anything and the callback will be called, as it will execute everythign async.
If you want it to not run async, simply provide no callback function, it will return true on success
It should be safe to modify/use the VoiceStream while it's being modified async BUT you should try to avoid doing that.
voicechat.BroadcastVoiceData( VoiceData voiceData, table plys )
Sends the given voice data all clients, or only the given table of clients.
VoiceData voicechat.CreateVoiceData( number plySlot = 0, string data = NULL, number length = 0 )
Creates a new VoiceData with the given data.
Creates a empty VoiceStream.
boolean voicechat.IsHearingClient( Player ply, Player targetPly )
Returns whether the given client can hear the target client.
boolean voicechat.IsPlayerTalking( Player ply )
Returns whether the given player is considered to be actively talking.
boolean voicechat.IsProximityHearingClient( Player ply, Player targetPly )
Returns whether the given client can hear the target client in it's proximity.
number voicechat.LastPlayerTalked( Player ply )
Returns the last time the given player has talked.
VoiceStream, number voicechat.LoadVoiceStream( string fileName, string gamePath = DATA, function callback = nil )
Tries to load a VoiceStream from the given file.
Meaning of the statusCode:
Number Meaning
-2 File not found
-1 Invalid type
0 None
1 Done
If async was used, it won't return anything. This function also supports .wav files to load from since 0.8
VoiceStream, number voicechat.LoadVoiceStreamFromWaveString( string waveData, function callback = nil, boolean promiseToNeverModify = false )
Tries to load a VoiceStream from the given data.
Meaning of the statusCode:
Number Meaning
-2 File not found
-1 Invalid type
0 None
1 Done
If async was used, it won't return anything.
voicechat.ProcessVoiceData( Player ply, VoiceData voiceData )
Let's the server process the VoiceData like it was received from the client.
This can be a bit performance intense.
This will ignore the set player slot!
number, string voicechat.SaveVoiceStream( VoiceStream voiceStream, string fileName = nil, string gamePath = DATA, function callback = nil, boolean returnWaveData = false )
Sends the given voice data to the given client.
Meaning of the statusCode:
Number Meaning
-2 File not found
-1 Invalid type
0 None
1 Done
If async was used, it won't return anything.
This function also supports .wav files to write the data into since 0.8.
You should always inform your players if you save their voice!

You can set both fileName and returnWaveData which will cause it to be written to disk and the data to be returned
If fileName and returnWaveData are both not set then it will error as atleast one of them needs to be enabled.
voicechat.SendEmptyData( Player ply, number plySlot = ply:EntIndex() - 1 )
Sends a empty voice data to the given client.
voicechat.SendVoiceData( Player ply, VoiceData voiceData )
Sends the given voice data to the given client.