CTR Pia  4.11.3
Game Communication Engine
nn::pia::chat::VoiceProtocol Class Reference

Contains member functions that provide voice chat functionality. More...

+ Inheritance diagram for nn::pia::chat::VoiceProtocol:

Classes

struct  Setting
 Stores parameters used by the Initialize function. More...
 

Public Member Functions

nn::Result AddConferenceClient (StationId id)
 Adds a client to the conference. More...
 
void ClearStreaming (void)
 Clears the audio streaming.
 
nn::Result EnableAgc (bool bEnable)
 Enables or disables the Automatic Gain Control (AGC) feature. More...
 
nn::Result EnableEchoCanceller (bool bEnable)
 Enables or disables echo cancellation. More...
 
nn::Result EnableNoiseSuppressor (bool bEnable)
 Enables or disables noise suppression. More...
 
void Finalize (void)
 Finalizes the instance. More...
 
s32 GetAgcLevel () const
 Gets the AGC (Automatic Gain Control) level. More...
 
size_t GetAudioDataSize (void) const
 Gets the packet size of audio data. More...
 
u32 GetAudioFrameLength (void) const
 Gets the currently configured audio frame length. More...
 
nn::Result GetAudioInfo (StationId id, AudioInfo *pInfo) const
 Gets the audio streaming information of the remote station specified by StationId. More...
 
enum Codec GetCodec (void) const
 Gets the currently configured audio codec. More...
 
enum EcMode GetEchoCancellerMode () const
 Gets the echo cancellation operation mode. More...
 
u32 GetNoiseSkipTime (void) const
 Gets the time period not to send audio for SignalNoiseSkip. More...
 
s32 GetNoiseSuppressorLevel () const
 Gets the noise suppression level. More...
 
u16 GetVADActiveGain (void) const
 Gets the current speech frame detection threshold. More...
 
bool GetVADActivity (void) const
 Gets whether audio is detected using the VAD (Voice Activity Detection) algorithm. More...
 
u32 GetVADClampGain (void) const
 Gets the volume threshold as a volume scale value for unconditionally determining silence. More...
 
u16 GetVADInactiveGain (void) const
 Gets the current silent frame detection threshold. More...
 
u16 GetVADPower (void) const
 Gets the average power of audio data in the current audio frame. More...
 
u32 GetVADReleaseTime (void) const
 Gets the time in number of packets before the sending of packets stops after detecting silence. More...
 
void HandleReference (const u8 *pBuffer, u32 size)
 Supplies reference data for echo cancellation. More...
 
nn::Result Initialize (const VoiceProtocol::Setting &setting)
 Initializes the instance. More...
 
bool IsClientInConference (StationId id) const
 Determines whether a client exists in a conference. More...
 
bool IsEnableAgc () const
 Gets whether the Automatic Gain Control (AGC) feature is enabled or disabled. More...
 
bool IsEnableEchoCanceller () const
 Gets whether echo cancellation is enabled or disabled. More...
 
bool IsEnableNoiseSuppressor () const
 Gets whether noise suppression is enabled or disabled. More...
 
bool IsInCommunication (void) const
 Determines whether the system is in a communication state. More...
 
nn::Result Receive (void *pAudioBuf, u32 frameDataSize, StationIndex *pStationIndexArray)
 Extracts audio data from the receive buffer. More...
 
nn::Result RemoveConferenceClient (StationId id)
 Removes a client from the conference. More...
 
nn::Result Send (const void *pAudioBuf, u32 samples, u32 micOffset)
 Packs audio data in the send queue. More...
 
nn::Result Send (const s16 *pAudioBuf, size_t samples, const s16 *pRefLeftIn, const s16 *pRefRightIn)
 Uses the echo cancellation, AGC, and noise suppression features when sending audio. More...
 
nn::Result SetAgcLevel (s32 level)
 Sets the Automatic Gain Control (AGC) level. Values of at least AGC_LEVEL_MIN and no greater than AGC_LEVEL_MAX can be set. More...
 
nn::Result SetAudioFrameLength (u32 frameLength)
 Sets the audio frame length. More...
 
nn::Result SetCodec (enum Codec codec)
 Sets the audio codec. More...
 
nn::Result SetEchoCancellerMode (enum EcMode ecMode)
 Sets the echo cancellation operation mode. More...
 
void SetNoiseSkipTime (u32 msec)
 Sets the time period not to send audio for SignalNoiseSkip. More...
 
nn::Result SetNoiseSuppressorLevel (s32 level)
 Sets the noise suppression level. Values of at least NOISE_SUPPRESSOR_LEVEL_MIN and no greater than NOISE_SUPPRESSOR_LEVEL_MAX can be set. NOISE_SUPPRESSOR_LEVEL_DEFAULT is the recommended value. More...
 
void SetVADActiveGain (u16 value)
 Sets the speech frame detection threshold. More...
 
nn::Result SetVADClampGain (u32 value)
 Sets the volume threshold as a volume scale value (the square of the average power) for unconditionally determining silence. More...
 
void SetVADInactiveGain (u16 value)
 Sets the silent frame detection threshold. More...
 
void SetVADReleaseTime (u32 packetNum)
 Sets the time in number of packets before the sending of packets stops after detecting silence. More...
 
void SignalNoiseSkip (void)
 Stops VAD (Voice Activity Detection) from becoming active and sending audio on the sound of button presses when VAD is enabled but not active. More...
 
virtual void Trace (u64 flag) const
 Prints information that is useful for debugging. More...
 

Static Public Attributes

static const size_t AUDIO_DATA_SIZE_DEFAULT = (AUDIO_FRAME_LENGTH_DEFAULT * AUDIO_DATA_SIZE_PER_MILLI_SEC)
 Specifies the default audio data size.
 
static const size_t AUDIO_DATA_SIZE_MAX = (AUDIO_FRAME_LENGTH_MAX * AUDIO_DATA_SIZE_PER_MILLI_SEC)
 Specifies the maximum audio data size.
 
static const size_t AUDIO_DATA_SIZE_MIN = (AUDIO_FRAME_LENGTH_MIN * AUDIO_DATA_SIZE_PER_MILLI_SEC)
 Specifies the minimum audio data size.
 
static const size_t AUDIO_DATA_SIZE_PER_MILLI_SEC = 16
 Specifies the data size per millisecond (in bytes).
 
static const u32 AUDIO_FRAME_LENGTH_DEFAULT = 144
 Specifies the default audio frame length (in milliseconds).
 
static const u32 AUDIO_FRAME_LENGTH_MAX = 192
 Specifies the maximum audio frame length (in milliseconds).
 
static const u32 AUDIO_FRAME_LENGTH_MIN = 64
 Specifies the minimum audio frame length (in milliseconds).
 

Detailed Description

Contains member functions that provide voice chat functionality.

You cannot create more than one instance of VoiceProtocol.


Revision History:

2015-09-01 If the client specified for RemoveConferenceClient() cannot be found, the function now returns ResultNotFound instead of ResultInvalidArgument.

2015-09-01 If an invalid argument is given to Send(), the function now returns ResultInvalidArgument.

2015-09-01 If there is no audio data to get when Receive() is called, the function now returns ResultNoData.

2015-08-05 Added notes to the SetVADClampGain() and Send() functions.

2015-05-18 Made the GetVADPower function public.

2015-01-15 Changed the type of the third parameter of the Receive function to nn::pia::StationIndex*.

2014-11-20 Added information about the thread-safe APIs.

2014-05-12 Made the IsClientInConference function private.

2014-05-07 Expanded the Setting structure to include a parameter that allows you to configure the maximum number of stations that can participate in a conference chat.

2014-01-30 Specifying 2-bit ADPCM as the sound codec for main packets is no longer supported.

2014-01-30 Quality alert-related API functions have been made private.

2014-01-23 Changed the specifications so that the SetVADClampGain function returns nn::Result.

2014-01-23 Changed the specifications so that the SetQualityAlertThresholdRate function returns nn::Result.

2014-01-23 Changed the specifications so that calling the SetAudioFrameLength function in a state where communication is not occurring results in ResultInvalidState being returned.

2014-01-22 Added the IsInCommunication member function to determine whether communication is taking place.

2014-01-22 Changed the specifications so that the SetCodec function returns ResultInvalidState when in a state where communication is not occurring.

2013-10-02 Added a member function to set the number of receive buffers for UnreliableProtocol to the Setting structure.

2013-10-02 Stopped using ReliableProtocol internally.

2013-07-12 Defined various constants and enumerations.

2013-07-12 Ported set and get functions for various parameters.

2013-06-18 Initial version.


Revision History:
2014-02-26 Changed the specifications so that the high-pass filter is enabled by default.


Revision History:
2014-02-25 Corrected an incorrect default value in the description of the SetVADActiveGain function.

Member Function Documentation

nn::Result nn::pia::chat::VoiceProtocol::AddConferenceClient ( StationId  id)

Adds a client to the conference.

The local StationId does not need to be specified. To start a conference, this function must be called by all parties for each other. For example, if three systems with a StationId of 1, 2, and 3 are starting a conference, system 1 must add 2 and 3, system 2 must add 1 and 3, and system 3 must add 1 and 2. If N is the maximum number of people who can connect in a conference, the maximum number of clients that the local system can add to a conference is N-1. This function returns an error if called while not in conference mode.

Parameters
[in]idSpecifies the StationId of the client to add.
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that one or more arguments are invalid. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that this function is not in a callable state. Either preparations have not been made for the call, or the maximum number of participating clients has been reached. Programming error. Fix your program so that this error is not returned.

nn::Result nn::pia::chat::VoiceProtocol::EnableAgc ( bool  bEnable)

Enables or disables the Automatic Gain Control (AGC) feature.

By default, the AGC feature is enabled.

Parameters
[in]bEnabletrue - Enabled, false - Disabled
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:
ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.
See also
Send(const s16*, size_t, const s16*, const s16*), IsEnableAgc, SetAgcLevel, GetAgcLevel
nn::Result nn::pia::chat::VoiceProtocol::EnableEchoCanceller ( bool  bEnable)

Enables or disables echo cancellation.

By default, echo cancellation is enabled.

Parameters
[in]bEnabletrue - Enabled, false - Disabled
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:
ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.
See also
Send(const s16*, size_t, const s16*, const s16*), IsEnableEchoCanceller, SetEchoCancellerMode, GetEchoCancellerMode
nn::Result nn::pia::chat::VoiceProtocol::EnableNoiseSuppressor ( bool  bEnable)

Enables or disables noise suppression.

By default, noise suppression is enabled.

Parameters
[in]bEnabletrue - Enabled, false - Disabled
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:
ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.
See also
Send(const s16*, size_t, const s16*, const s16*), IsEnableNoiseSuppressor, SetNoiseSuppressorLevel, GetNoiseSuppressorLevel
void nn::pia::chat::VoiceProtocol::Finalize ( void  )

Finalizes the instance.

This function returns without doing anything if it is called before the Initialize function has been called.

See also
Initialize
s32 nn::pia::chat::VoiceProtocol::GetAgcLevel ( ) const

Gets the AGC (Automatic Gain Control) level.

Returns
Returns a value of at least AGC_LEVEL_MIN but not greater than AGC_LEVEL_MAX if successful.
Error Return Values:
-1 The AGC level is not in a state where it can be obtained.
See also
Send(const s16*, size_t, const s16*, const s16*), EnableAgc, IsEnableAgc, SetAgcLevel
size_t nn::pia::chat::VoiceProtocol::GetAudioDataSize ( void  ) const

Gets the packet size of audio data.

This function returns the data size calculated based on the currently configured audio frame length. You can get the currently configured audio frame length by using the GetAudioFrameLength function. If called prior to initialization, AUDIO_DATA_SIZE_DEFAULT, which corresponds to the recommended audio frame length value in AUDIO_FRAME_LENGTH_DEFAULT, is returned.

This API function is thread-safe.

Returns
Returns the packet size of audio data.
u32 nn::pia::chat::VoiceProtocol::GetAudioFrameLength ( void  ) const

Gets the currently configured audio frame length.

If you call this function before initialization, the recommended value AUDIO_FRAME_LENGTH_DEFAULT is returned.

This API function is thread-safe.

Returns
Returns either the value that was set in the frameLength member variable of the Setting structure at the time of initialization, or the value set using the SetAudioFrameLength function after initialization.
nn::Result nn::pia::chat::VoiceProtocol::GetAudioInfo ( StationId  id,
AudioInfo pInfo 
) const

Gets the audio streaming information of the remote station specified by StationId.

Parameters
[in]idSpecifies the StationId of the remote station from which to get the audio streaming information.
[out]pInfoSpecifies a pointer to a AudioInfo structure.
Returns
Returns a Result value for which the IsSuccess() function returns true if execution succeeds.
Error Return Values:
ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.
enum Codec nn::pia::chat::VoiceProtocol::GetCodec ( void  ) const

Gets the currently configured audio codec.

Returns
Returns the currently configured audio codec for main packets.
enum EcMode nn::pia::chat::VoiceProtocol::GetEchoCancellerMode ( ) const

Gets the echo cancellation operation mode.

Returns
Returns the echo cancellation operation mode.
Error Return Values:
EC_VOID Indicates that the echo cancellation operation mode is not in an obtainable state.
See also
Send(const s16*, size_t, const s16*, const s16*), EnableEchoCanceller, IsEnableEchoCanceller, SetEchoCancellerMode
u32 nn::pia::chat::VoiceProtocol::GetNoiseSkipTime ( void  ) const

Gets the time period not to send audio for SignalNoiseSkip.

Returns
Returns the time period not to send audio. The value is in milliseconds.
See also
SignalNoiseSkip, SetNoiseSkipTime
s32 nn::pia::chat::VoiceProtocol::GetNoiseSuppressorLevel ( ) const

Gets the noise suppression level.

Returns
Returns a value of at least NOISE_SUPPRESSOR_LEVEL_MIN but not greater than NOISE_SUPPRESSOR_LEVEL_MAX if successful.
Error Return Values:
–1 The noise suppression level is not in a state where it can be obtained.
See also
Send(const s16*, size_t, const s16*, const s16*), EnableNoiseSuppressor, IsEnableNoiseSuppressor, SetNoiseSuppressorLevel
u16 nn::pia::chat::VoiceProtocol::GetVADActiveGain ( void  ) const

Gets the current speech frame detection threshold.

Returns
Returns the speech frame detection threshold.
See also
SetVADActiveGain
bool nn::pia::chat::VoiceProtocol::GetVADActivity ( void  ) const

Gets whether audio is detected using the VAD (Voice Activity Detection) algorithm.

Returns true while frames with audio (speech frames) are present, or false while the frames without audio (silent frames) are present. When the VAD feature is disabled, this function always returns false regardless of whether there is any voice activity.

Returns
Returns true if it is determined that audio is present or false otherwise.
u32 nn::pia::chat::VoiceProtocol::GetVADClampGain ( void  ) const

Gets the volume threshold as a volume scale value for unconditionally determining silence.

The volume scale value is specified in the range from 0 through 0x3FFFFFFF.

Returns
Returns the volume threshold at which a frame is unconditionally determined to be silent.
See also
SetVADClampGain
u16 nn::pia::chat::VoiceProtocol::GetVADInactiveGain ( void  ) const

Gets the current silent frame detection threshold.

Returns
Returns the silent frame detection threshold.
See also
SetVADInactiveGain
u16 nn::pia::chat::VoiceProtocol::GetVADPower ( void  ) const

Gets the average power of audio data in the current audio frame.

The VAD algorithm detects audio based on the size of this value. This value is equivalent to the average power of the audio data (the square root of the volume scale of the audio data used in the GetAudioScale function or SetVADClampGain function) divided by a normalization factor (256).

Returns
Returns the average power of the audio data in the current audio frame.
u32 nn::pia::chat::VoiceProtocol::GetVADReleaseTime ( void  ) const

Gets the time in number of packets before the sending of packets stops after detecting silence.

Returns
Returns the release time (in number of packets).
See also
SetVADReleaseTime
void nn::pia::chat::VoiceProtocol::HandleReference ( const u8 *  pBuffer,
u32  size 
)

Supplies reference data for echo cancellation.

Call the nn::snd::GetMixedBusData function at every sound DSP interrupt (every 5 ms), and pass the 5 ms of 16-bit/32 kHz stereo data obtained by that function to the pBuffer of this function. This function does nothing if size is not the correct size for 5 milliseconds of 16-bit/32 kHz stereo data.

Parameters
[in]pBufferSpecifies reference data for echo cancellation.
[in]sizeSpecifies the size of the reference data for echo cancellation.
nn::Result nn::pia::chat::VoiceProtocol::Initialize ( const VoiceProtocol::Setting setting)

Initializes the instance.

Call between the BeginSetup and EndSetup functions.

Parameters
[in]settingSpecifies a settings parameter structure for VoiceProtocol.
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds. You must make sure that the implementation of this function in your application does not return any errors.
Error Return Values:

ResultNotInitialized Indicates that the chat module is not initialized. Programming error. Fix your program so that this error is not returned.

ResultAllocationFailed Indicates that the function failed to allocate memory. Consider providing more memory when calling the common::Initialize function. Programming error. Fix your program so that this error is not returned.

ResultAlreadyInitialized Indicates that the VoiceProtocol instance is already initialized. Programming error. Fix your program so that this error is not returned.

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that the function was not called between the BeginSetup and EndSetup functions. Programming error. Fix your program so that this error is not returned.

See also
Finalize
bool nn::pia::chat::VoiceProtocol::IsClientInConference ( StationId  id) const

Determines whether a client exists in a conference.

Parameters
[in]idSpecifies the StationId of the client to search for.
Returns
Returns true if the client is in the conference or false otherwise.
bool nn::pia::chat::VoiceProtocol::IsEnableAgc ( ) const

Gets whether the Automatic Gain Control (AGC) feature is enabled or disabled.

Returns
Returns true if the AGC feature is enabled or false otherwise.
See also
Send(const s16*, size_t, const s16*, const s16*), EnableAgc, SetAgcLevel, GetAgcLevel
bool nn::pia::chat::VoiceProtocol::IsEnableEchoCanceller ( ) const

Gets whether echo cancellation is enabled or disabled.

Returns
Returns true if echo cancellation is enabled, and returns false otherwise.
See also
Send(const s16*, size_t, const s16*, const s16*), EnableEchoCanceller, SetEchoCancellerMode, GetEchoCancellerMode
bool nn::pia::chat::VoiceProtocol::IsEnableNoiseSuppressor ( ) const

Gets whether noise suppression is enabled or disabled.

Returns
Returns true if the noise suppression feature is enabled or false otherwise.
See also
Send(const s16*, size_t, const s16*, const s16*), EnableNoiseSuppressor, SetNoiseSuppressorLevel, GetNoiseSuppressorLevel
bool nn::pia::chat::VoiceProtocol::IsInCommunication ( void  ) const

Determines whether the system is in a communication state.

This API function is thread-safe.

Returns
Returns true if the system is in a communication state or false otherwise.
nn::Result nn::pia::chat::VoiceProtocol::Receive ( void *  pAudioBuf,
u32  frameDataSize,
StationIndex pStationIndexArray 
)

Extracts audio data from the receive buffer.

This function also acts internally to mix the audio if it is playing on more than one channel. The audio data written to pAudioBuf is in 16-bit/8 kHz format. This buffer must be aligned to a 32-byte boundary.

This API can also be called from threads other than the one that calls the common::Scheduler::Dispatch() function.

Parameters
[out]pAudioBufSpecifies a pointer to the audio data buffer.
[in]frameDataSizeSpecifies the size of the audio data buffer.
[out]pStationIndexArrayStores the StationIndex array of the client that sent this stream. Specify NULL if this is unnecessary. The number of elements in the array must not exceed the maxStationNum member of the Setting structure passed when the Initialize function was called.
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that one or more arguments are invalid. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that the function was called at the wrong time. Programming error. Fix your program so that this error is not returned.

ResultNoData There was no audio data to get. Handle appropriately in the application.

See also
Send
nn::Result nn::pia::chat::VoiceProtocol::RemoveConferenceClient ( StationId  id)

Removes a client from the conference.

Have all participants in the conference call this function, and not just the one that is leaving.

Parameters
[in]idSpecifies the StationId of the client to remove.
Returns
Returns a Result value for which the IsSuccess() function returns true if execution succeeds.
Error Return Values:

ResultNotFound The client with the specified ID cannot be found. Handle appropriately in the application.

ResultInvalidArgument Indicates that one or more arguments are invalid. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that the function was called at the wrong time. Programming error. Fix your program so that this error is not returned.

nn::Result nn::pia::chat::VoiceProtocol::Send ( const void *  pAudioBuf,
u32  samples,
u32  micOffset 
)

Packs audio data in the send queue.

This API function can also be called from threads other than the one that calls the common::Scheduler::Dispatch() function.

The assumption is that this API will receive audio data actually picked up by the microphone. You must be careful when passing synthesized audio data. For more information, see the SetVADClampGain() function.

Parameters
[in]pAudioBufSpecifies a pointer to the start of the audio data.
[in]samplesSpecifies the sampling rate of the audio data.
[in]micOffsetSpecifies the offset (number of samples) between the latest mic sample and last sample of the input mic data.
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidState Indicates that the function was called at the wrong time. Programming error. Fix your program so that this error is not returned.

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

See also
Receive
nn::Result nn::pia::chat::VoiceProtocol::Send ( const s16 *  pAudioBuf,
size_t  samples,
const s16 *  pRefLeftIn,
const s16 *  pRefRightIn 
)

Uses the echo cancellation, AGC, and noise suppression features when sending audio.

This API uses approximately 16 KB of the stack. Make sure that you allocate a stack of adequate size for the thread that calls this API.

This API blocks for about 14 to 20 milliseconds. It blocks because it runs internal audio signal processes related to echo cancellation, AGC, and noise suppression.

This API can also be called from threads other than the one that calls the common::Scheduler::Dispatch() function.

The assumption is that this API will receive audio data actually picked up by the microphone. You must be careful when passing synthesized audio data. For more information, see the SetVADClampGain() function.

Parameters
[in]pAudioBufThe audio data to send (generally microphone input). The sampling frequency is 8 kHz.
[in]samplesNumber of samples. These samples must correspond to the audio data frame length.
[in]pRefLeftInReference data input for the left channel. The sampling frequency is 32 kHz.
[in]pRefRightInReference data input for the right channel. The sampling frequency is 32 kHz.
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that this API function was called at the wrong time. Programming error. Fix your program so that this error is not returned.

See also
Receive
nn::Result nn::pia::chat::VoiceProtocol::SetAgcLevel ( s32  level)

Sets the Automatic Gain Control (AGC) level. Values of at least AGC_LEVEL_MIN and no greater than AGC_LEVEL_MAX can be set.

If the argument is set to AGC_LEVEL_MIN, AGC is not actually being used because the amplification rate is 1×.

The greater the value set, the more the amplification rate increases, but it also becomes easier for feedback to occur. Setting a value of 1 or 2 is recommended.

Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.

See also
Send(const s16*, size_t, const s16*, const s16*), EnableAgc, IsEnableAgc, GetAgcLevel
nn::Result nn::pia::chat::VoiceProtocol::SetAudioFrameLength ( u32  frameLength)

Sets the audio frame length.

For frameLength, you must specify a value between AUDIO_FRAME_LENGTH_MIN and AUDIO_FRAME_LENGTH_MAX that is also an integer multiple of 8.

Parameters
[in]frameLengthSpecifies the length of the audio frame (in milliseconds).
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that the function was called at the wrong time. Programming error. Fix your program so that this error is not returned.

nn::Result nn::pia::chat::VoiceProtocol::SetCodec ( enum Codec  codec)

Sets the audio codec.

The codec can be changed even while streaming. You can specify 4-bit ADPCM or 2-bit ADPCM, but 2-bit ADPCM is not supported. This function returns ResultInvalidArgument if an unsupported audio codec is specified.

Parameters
[in]codecThe changed audio codec type for the sender.
Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that an argument is invalid. An unsupported codec may have been specified. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that the function was called at the wrong time. Communication might not have been started. Programming error. Fix your program so that this error is not returned.

nn::Result nn::pia::chat::VoiceProtocol::SetEchoCancellerMode ( enum EcMode  ecMode)

Sets the echo cancellation operation mode.

Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.

See also
Send(const s16*, size_t, const s16*, const s16*), EnableEchoCanceller, IsEnableEchoCanceller, GetEchoCancellerMode
void nn::pia::chat::VoiceProtocol::SetNoiseSkipTime ( u32  msec)

Sets the time period not to send audio for SignalNoiseSkip.

Parameters
[in]msecSpecifies the time period not to send audio. The value is in milliseconds.
See also
SignalNoiseSkip, GetNoiseSkipTime
nn::Result nn::pia::chat::VoiceProtocol::SetNoiseSuppressorLevel ( s32  level)

Sets the noise suppression level. Values of at least NOISE_SUPPRESSOR_LEVEL_MIN and no greater than NOISE_SUPPRESSOR_LEVEL_MAX can be set. NOISE_SUPPRESSOR_LEVEL_DEFAULT is the recommended value.

Returns
Returns a Result value for which the IsSuccess function returns true if execution succeeds.
Error Return Values:

ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.

ResultNotInitialized Indicates that this API was called when the VoiceProtocol instance was not in an initialized state. Programming error. Fix your program so that this error is not returned.

See also
Send(const s16*, size_t, const s16*, const s16*), EnableNoiseSuppressor, IsEnableNoiseSuppressor, GetNoiseSuppressorLevel
void nn::pia::chat::VoiceProtocol::SetVADActiveGain ( u16  value)

Sets the speech frame detection threshold.

When the previous audio frame is recognized as a silent frame, this threshold value is used to determine whether the current audio frame includes audio. A frame is recognized as a speech frame when the following conditions are met: Ts is the threshold value, Ec is the average speech power of the audio data in the current frame, and En is the average speech power of the audio data in the four frames immediately prior to the current one. The difference between Ec and En are compared.
Ec > En * Ts / 100
The value parameter takes the Ts value. The default value is 350. In this case, the threshold of the power difference between En and Ec is equivalent to 20 * log (350 / 100) = 10.9 dB.

Parameters
[in]valueSpecifies the speech frame detection threshold.
See also
GetVADActiveGain
nn::Result nn::pia::chat::VoiceProtocol::SetVADClampGain ( u32  value)

Sets the volume threshold as a volume scale value (the square of the average power) for unconditionally determining silence.

value takes a volume scale value in the range from 0 through 0x3FFFFFFF, and any audio frame with a volume scale set below this threshold is treated as silence.

The volume scale of the audio data as obtained by the GetAudioScale function is used for this value. The default value is 49.

Audio frames with volumes below the value set by this API are treated as silence by the library and the VAD status is not updated. For this reason, if you want to pass synthesized audio data to a function that sends audio data, you must make sure its volume is higher than the threshold set by this function. Operations could be impaired if data at very low volume below this threshold (for example, data to fill the memory with zeros) continues to be passed to a function that sends audio data.

Parameters
[in]valueSpecifies the volume threshold at which a frame is unconditionally determined to be silent.
Returns
Returns a Result value for which the IsSuccess() function returns true if execution succeeds.
Error Return Values:
ResultInvalidArgument Indicates that an argument is invalid. Programming error. Fix your program so that this error is not returned.
See also
GetVADClampGain
void nn::pia::chat::VoiceProtocol::SetVADInactiveGain ( u16  value)

Sets the silent frame detection threshold.

When the previous audio frame is recognized as a speech frame, this threshold value is used to determine whether the current audio frame is silent. A frame is recognized as silent when the following condition is met, where Tn is the threshold value, Ec is the average speech power of the audio data in the nearest four frames, and En is the average speech power of the audio data in the four frames before the last frame to be deemed a silent frame.
Ec < En * Tn / 100
However, the sending of audio frames is not actually stopped until the consecutive number of frames deemed silent reaches the value specified with the SetVADReleaseTime function. The value parameter takes the Tn value. The default value is 280. In this case, the threshold of the power difference between En and Ec is equivalent to 20 * log (280 / 100) = 8.94 dB.

Parameters
[in]valueSpecifies the silent frame detection threshold.
See also
GetVADInactiveGain
void nn::pia::chat::VoiceProtocol::SetVADReleaseTime ( u32  packetNum)

Sets the time in number of packets before the sending of packets stops after detecting silence.

To prevent VAD from detecting silence in the middle of a conversation because, for example, the user takes a breath, set the release time to at least 500 ms. Set the parameter to the time to wait in number of packets before actually stopping the sending of packets after silence is detected. The default is 5 packets (144 * 5 = 720 ms).

Parameters
[in]packetNumSpecifies the release time (in number of packets).
See also
GetVADReleaseTime
void nn::pia::chat::VoiceProtocol::SignalNoiseSkip ( void  )

Stops VAD (Voice Activity Detection) from becoming active and sending audio on the sound of button presses when VAD is enabled but not active.

Setting up this function enables you to prevent the VAD feature from activating and sending audio on the sound of button presses when VAD is enabled but not active. By not sending audio for a certain time period after button presses, you can minimize the button pressing sounds received by other players. When VAD is active and audio is being sent, the sound of button presses cannot be removed. Specify the time period not to send audio using the SetNoiseSkipTime function.

See also
SetNoiseSkipTime, GetNoiseSkipTime
virtual void nn::pia::chat::VoiceProtocol::Trace ( u64  flag) const
virtual

Prints information that is useful for debugging.

Parameters
[in]flagSpecifies the bitwise OR of trace flags. For more information, see the TraceFlag type.

Reimplemented from nn::pia::transport::Protocol.