UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
UVoxtaAudioInput Class Reference

UVoxtaAudioInput Main public-facing class responsible for containing all AudioInput related logic. More...

#include <VoxtaAudioInput.h>

Inheritance diagram for UVoxtaAudioInput:

Public Member Functions

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam (FVoxtaAudioInputStateChanged, VoxtaMicrophoneState, newState)
 Delegate fired when the audio input state changes.
 
 DECLARE_MULTICAST_DELEGATE_OneParam (FVoxtaAudioInputStateChangedNative, VoxtaMicrophoneState)
 Native C++ delegate for audio input state changes.
 
void InitializeSocket (int bufferMs=200, int sampleRate=16000, int inputChannels=1)
 Creates the AudioWebSocket and connects audioSocket input hosted on the VoxtaServer's IP and port.
 
void Cleanup ()
 Used for cleaning up resources, should only be triggered when shutting down the game.
 
bool IsInitialized () const
 
void ConnectToCurrentChat ()
 Connects the audio input to the current chat session.
 
void DisconnectFromChat ()
 Disconnects the audio input from the current chat session.
 
void StartAudioTesting (int sampleRate=16000, int inputChannels=1)
 Starts audio testing mode with the given sample rate and input channels.
 
void StopAudioTesting ()
 Stops audio testing mode.
 
void StartStreaming (bool isTestMode=false)
 Starts streaming audio data to the server.
 
void StopStreaming ()
 Stops streaming audio data to the server.
 
VoxtaMicrophoneState GetCurrentState () const
 
bool IsRecording () const
 
bool IsInputSilent () const
 
float GetInputDecibels () const
 
const FString & GetInputDeviceName () const
 
void ConfigureSilenceThresholds (float micNoiseGateThreshold, float silenceDetectionThreshold, float micInputGain)
 Configure values to help the microphone to pick up voice without background noise.
 
virtual void BeginDestroy () override
 Fallback in case the Cleanup was not called, should not be necessary though, but oh well.
 

Public Attributes

FVoxtaAudioInputStateChanged VoxtaAudioInputStateChangedEvent
 Event fired after both the audiosocket and the capturedevice are initialized.
 
FVoxtaAudioInputStateChangedNative VoxtaAudioInputStateChangedEventNative
 

Detailed Description

UVoxtaAudioInput Main public-facing class responsible for containing all AudioInput related logic.

Takes care of both the microphone input, as well as sending it over a websocket to the VoxtaServer.

Note: You should not instantiate this manually, just access it via the voxta subsystem: [ GetWorld()->GetGameInstance()->GetSubsystem<UVoxtaClient>() ]->GetVoiceInputHandler() ]

Member Function Documentation

◆ BeginDestroy()

void UVoxtaAudioInput::BeginDestroy ( )
overridevirtual

Fallback in case the Cleanup was not called, should not be necessary though, but oh well.

◆ Cleanup()

void UVoxtaAudioInput::Cleanup ( )

Used for cleaning up resources, should only be triggered when shutting down the game.

◆ ConfigureSilenceThresholds()

void UVoxtaAudioInput::ConfigureSilenceThresholds ( float micNoiseGateThreshold,
float silenceDetectionThreshold,
float micInputGain )

Configure values to help the microphone to pick up voice without background noise.

Parameters
micNoiseGateThresholdThe linear amplitude, anything below this will output silent audio data.
silenceDetectionThresholdThe linear amplitude, anything below this will not generate any audio data.
micInputGainThe linear amplitude muliplier applied to the input.

◆ ConnectToCurrentChat()

void UVoxtaAudioInput::ConnectToCurrentChat ( )

Connects the audio input to the current chat session.

◆ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam()

UVoxtaAudioInput::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ( FVoxtaAudioInputStateChanged ,
VoxtaMicrophoneState ,
newState  )

Delegate fired when the audio input state changes.

◆ DECLARE_MULTICAST_DELEGATE_OneParam()

UVoxtaAudioInput::DECLARE_MULTICAST_DELEGATE_OneParam ( FVoxtaAudioInputStateChangedNative ,
VoxtaMicrophoneState  )

Native C++ delegate for audio input state changes.

◆ DisconnectFromChat()

void UVoxtaAudioInput::DisconnectFromChat ( )

Disconnects the audio input from the current chat session.

◆ GetCurrentState()

VoxtaMicrophoneState UVoxtaAudioInput::GetCurrentState ( ) const
Returns
The current microphone state.

◆ GetInputDecibels()

float UVoxtaAudioInput::GetInputDecibels ( ) const
Returns
The decibels of the last recorded audiodata iteration (updated every ~30ms)

Note: These values are roughly in the range of -100db (silence) and 0db (max loudness)

◆ GetInputDeviceName()

const FString & UVoxtaAudioInput::GetInputDeviceName ( ) const
Returns
The an immutable reference to the name reported by the hardware device.

◆ InitializeSocket()

void UVoxtaAudioInput::InitializeSocket ( int bufferMs = 200,
int sampleRate = 16000,
int inputChannels = 1 )

Creates the AudioWebSocket and connects audioSocket input hosted on the VoxtaServer's IP and port.

Note: It will automatically connect the socket to the server initiate the JSON config handshake, so the server is ready to receive audio.

Parameters
bufferMsMicrophone buffersize in Milliseconds. Bigger values is less taxing but introduces more delay.
sampleRateThe samplerate used for microphone, 16000 is preferred due to serverside conversion.
inputChannelsThe input channels for the microphone, 1 is preferred.

◆ IsInitialized()

bool UVoxtaAudioInput::IsInitialized ( ) const
Returns
True if the audio input is initialized.

◆ IsInputSilent()

bool UVoxtaAudioInput::IsInputSilent ( ) const
Returns
True if the input is currently silent.

◆ IsRecording()

bool UVoxtaAudioInput::IsRecording ( ) const
Returns
True if VoiceInput is actively being captured at this moment.

◆ StartAudioTesting()

void UVoxtaAudioInput::StartAudioTesting ( int sampleRate = 16000,
int inputChannels = 1 )

Starts audio testing mode with the given sample rate and input channels.

Parameters
sampleRateThe sample rate to use.
inputChannelsThe number of input channels.

◆ StartStreaming()

void UVoxtaAudioInput::StartStreaming ( bool isTestMode = false)

Starts streaming audio data to the server.

◆ StopAudioTesting()

void UVoxtaAudioInput::StopAudioTesting ( )

Stops audio testing mode.

◆ StopStreaming()

void UVoxtaAudioInput::StopStreaming ( )

Stops streaming audio data to the server.

Member Data Documentation

◆ VoxtaAudioInputStateChangedEvent

FVoxtaAudioInputStateChanged UVoxtaAudioInput::VoxtaAudioInputStateChangedEvent

Event fired after both the audiosocket and the capturedevice are initialized.

◆ VoxtaAudioInputStateChangedEventNative

FVoxtaAudioInputStateChangedNative UVoxtaAudioInput::VoxtaAudioInputStateChangedEventNative

The documentation for this class was generated from the following files: