The TeamSpeak Client Lib allows users to acces the raw playback and capture voice data and even modify it, for example to add effects to the voice. These callbacks are also used by the TeamSpeak client for the voice recording feature.
Using these low-level callbacks is not required and should be reserved for specific needs. Most SDK applications won't need to implement these callbacks.
This event is called when a voice packet from a client (not own client) is decoded and about to be played over your sound device, but before it is 3D positioned and mixed with other sounds.
You can use this function to alter the voice data (for example when you want to do effects on it) or to simply get voice data. The TeamSpeak client uses this function to record sessions.
void onEditPlaybackVoiceDataEvent( | serverConnectionHandlerID, | á |
á | clientID, | á |
á | samples, | á |
á | sampleCount, | á |
á | channels) ; | á |
uint64 serverConnectionHandlerID
;anyID clientID
;short* samples
;int sampleCount
;int channels
;Parameters
serverConnectionHandlerID
ID of the server connection handler from which the voice data was sent.
clientID
ID of the client whose voice data is received.
samples
Pointer to the voice data (signed 16 bit @ 48KHz).
sampleCount
Number of samples the "samples" variable points to.
channels
Number of channels in the sound data. Currently always 1.
This event is called when a voice packet from a client (not own client) is decoded and 3D positioned and about to be played over your sound device, but before it is mixed with other sounds.
You can use this function to alter/get the voice data after 3D positioning.
void onEditPostProcessVoiceDataEvent( | serverConnectionHandlerID, | á |
á | clientID, | á |
á | samples, | á |
á | sampleCount, | á |
á | channels, | á |
á | channelSpeakers, | á |
á | channelFillMask) ; | á |
uint64 serverConnectionHandlerID
;anyID clientID
;short* samples
;int sampleCount
;int channels
;const unsigned int* channelSpeakers
;unsigned int* channelFillMask
;Parameters
serverConnectionHandlerID
ID of the server connection handler from which the voice data was sent.
clientID
ID of the client whose voice data is received.
samples
Pointer to the voice data (signed 16 bit @ 48KHz).
sampleCount
Number of samples the "samples" variable points to.
channels
Number of channels in the sound data.
channelSpeakers
A pointer to a bit-mask of which speakers the channels represent. The values can be found in the SPEAKER_* defines within public_definitions.h
. Channels are always in order of this bit-mask, so if the sound data has 2 channels, and channelSpeakers is SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, the first channel (0) is always SPEAKER_FRONT_LEFT and the second channel (1) is always SPEAKER_FRONT_RIGHT.
channelFillMask
A pointer to a bit-mask of which channels are filled. For efficiency reasons, not all channels need to have actual sound data in it. So before this data is used, use this bit-mask to check if the channel is actually filled. If you decide to add data to a channel that is empty, set the bit for this channel in this mask.
For example, this callback reports:
channelsá=á6
*channelSpeakersá=
áááááááááááááááááááSPEAKER_FRONT_CENTERá|áSPEAKER_LOW_FREQUENCYá|
áááááááááááááááááááSPEAKER_BACK_LEFTá|áSPEAKER_BACK_RIGHTá|
áááááááááááááááááááSPEAKER_SIDE_LEFTá|áSPEAKER_SIDE_RIGHTáá//áQuoteáunusualásetup
*channelFillMaská=á1
This means "samples" points to 6 channel data, but only the SPEAKER_FRONT_CENTER channel has data, the other channels are undefined (not necessarily 0, but undefined).
So for the first sample, samples[0] has data and samples[1], samples[2], samples[3], samples[4] and samples[5] are undefined.
If you want to add SPEAKER_BACK_RIGHT channel data you would do something like:
*channelFillMask |= 1<<3; // SPEAKER_BACK_RIGHT is the 4th channel (is index 3) according to *channelSpeakers. for(int i=0; i<sampleCount; ++i){ samples[3 + (i*channels) ] = getChannelSoundData(SPEAKER_BACK_RIGHT, i); }
This event is called when all sounds that are about to be played back for this server connection are mixed. This is the last chance to alter/get sound.
You can use this function to alter/get the sound data before playback.
void onEditMixedPlaybackVoiceDataEvent( | serverConnectionHandlerID, | á |
á | samples, | á |
á | sampleCount, | á |
á | channels, | á |
á | channelSpeakers, | á |
á | channelFillMask) ; | á |
uint64 serverConnectionHandlerID
;short* samples
;int sampleCount
;int channels
;const unsigned int* channelSpeakers
;unsigned int* channelFillMask
;Parameters
serverConnectionHandlerID
ID of the server connection handler from which the voice data was sent.
samples
Pointer to the voice data (signed 16 bit @ 48KHz).
sampleCount
Number of samples the "samples" variable points to.
channels
Number of channels in the sound data.
channelSpeakers
A pointer to a bit-mask of which speakers the channels represent. The values can be found in the SPEAKER_* defines within public_definitions.h
. Channels are always in order of this bit-mask, so if the sound data has 2 channels, and channelSpeakers is SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, the first channel (0) is always SPEAKER_FRONT_LEFT and the second channel (1) is always SPEAKER_FRONT_RIGHT.
channelFillMask
A pointer to a bit-mask of which channels are filled. For efficiency reasons, not all channels need to have actual sound data in it. So before this data is used, use this bit-mask to check if the channel is actually filled. If you decide to add data to a channel that is empty, set the bit for this channel in this mask.
This event is called after sound is recorded from the sound device and is preprocessed. This event can be used to get/alter recorded sound. Also it can be determined if this sound will be send, or muted. This is used by the TeamSpeak client to record sessions.
If the sound data will be send, (*edited | 2) is true. If the sound data is changed, set bit 1 (*edited |=1). If the sound should not be send, clear bit 2. (*edited &= ~2)
void onEditCapturedVoiceDataEvent( | serverConnectionHandlerID, | á |
á | samples, | á |
á | sampleCount, | á |
á | channels, | á |
á | edited) ; | á |
uint64 serverConnectionHandlerID
;short* samples
;int sampleCount
;int channels
;int* edited
;Parameters
serverConnectionHandlerID
ID of the server connection handler from which the voice data was sent.
samples
Pointer to the voice data (signed 16 bit @ 48KHz).
sampleCount
Number of samples the "samples" variable points to.
channels
Number of channels in the sound data.
edited
When called, bit 2 indicates if the sound is about to be sent to the server.
On return, set bit 1 if the sound data was changed.
When using the above callbacks to record voice, you should notify the server when recording starts or stops with the following functions:
unsigned int ts3client_startVoiceRecording( | serverConnectionHandlerID) ; | á |
uint64 serverConnectionHandlerID
;unsigned int ts3client_stopVoiceRecording( | serverConnectionHandlerID) ; | á |
uint64 serverConnectionHandlerID
;Parameters
serverConnectionHandlerID
ID of the server connection handler on which voice recording should be started or stopped.
Returns ERROR_ok
on success, otherwise an error code as defined in public_errors.h
.