HolyLib Wiki

voicechat.SaveVoiceStream

 number, string voicechat.SaveVoiceStream( VoiceStream voiceStream, string fileName = nil, string gamePath = DATA, function callback = nil, boolean returnWaveData = false )

Description

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.

Recently Changed

This was recently changed in version (0.8 - DEV).

The async argument was removed and the behavior was changed
If a callback is specified it WONT return anything and the callback will be called, as it will execute everythign async.

Arguments

1VoiceStream voiceStream

the VoiceStream to save

2string fileName = nil

the fileName to use. This can also be the callback function, in which case it will internally enable returnWaveData & behave like it

3string gamePath = DATA

the gamePath to use

4function callback = nil

the callback function to use

Function argument(s):
1VoiceStream voiceStream -

the loaded VoiceStream or nil on failure

2number statusCode -

the statusCode. 1 on success

3string waveData -

the wave data. nil if returnWaveData wasn't set to true

Function return argument(s):

5boolean returnWaveData = false

If the function should return the wave data as a string

Returns

1number statusCode

the statusCode. 1 on success

2string waveData

the wave data. nil if returnWaveData wasn't set to true

Example

Showing the agument overloads

Default version: -- Either you set the last false / returnWaveData to true to receive the wavData as a string, or you provide no file name voicechat.SaveVoiceStream(stream, "file.wav", "DATA", function(stream, status, wav) end, false) Argument Overload version: -- This will always return wav data since we never get a file name. voicechat.SaveVoiceStream(stream, function(stream, status, wav) end)