UVoxtaAudioInput Main public-facing class responsible for containing all AudioInput related logic. More...
#include <VoxtaAudioInput.h>
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 |
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() ]
|
overridevirtual |
Fallback in case the Cleanup was not called, should not be necessary though, but oh well.
void UVoxtaAudioInput::Cleanup | ( | ) |
Used for cleaning up resources, should only be triggered when shutting down the game.
void UVoxtaAudioInput::ConfigureSilenceThresholds | ( | float | micNoiseGateThreshold, |
float | silenceDetectionThreshold, | ||
float | micInputGain ) |
Configure values to help the microphone to pick up voice without background noise.
micNoiseGateThreshold | The linear amplitude, anything below this will output silent audio data. |
silenceDetectionThreshold | The linear amplitude, anything below this will not generate any audio data. |
micInputGain | The linear amplitude muliplier applied to the input. |
void UVoxtaAudioInput::ConnectToCurrentChat | ( | ) |
Connects the audio input to the current chat session.
UVoxtaAudioInput::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam | ( | FVoxtaAudioInputStateChanged | , |
VoxtaMicrophoneState | , | ||
newState | ) |
Delegate fired when the audio input state changes.
UVoxtaAudioInput::DECLARE_MULTICAST_DELEGATE_OneParam | ( | FVoxtaAudioInputStateChangedNative | , |
VoxtaMicrophoneState | ) |
Native C++ delegate for audio input state changes.
void UVoxtaAudioInput::DisconnectFromChat | ( | ) |
Disconnects the audio input from the current chat session.
VoxtaMicrophoneState UVoxtaAudioInput::GetCurrentState | ( | ) | const |
float UVoxtaAudioInput::GetInputDecibels | ( | ) | const |
Note: These values are roughly in the range of -100db (silence) and 0db (max loudness)
const FString & UVoxtaAudioInput::GetInputDeviceName | ( | ) | const |
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.
bufferMs | Microphone buffersize in Milliseconds. Bigger values is less taxing but introduces more delay. |
sampleRate | The samplerate used for microphone, 16000 is preferred due to serverside conversion. |
inputChannels | The input channels for the microphone, 1 is preferred. |
bool UVoxtaAudioInput::IsInitialized | ( | ) | const |
bool UVoxtaAudioInput::IsInputSilent | ( | ) | const |
bool UVoxtaAudioInput::IsRecording | ( | ) | const |
void UVoxtaAudioInput::StartAudioTesting | ( | int | sampleRate = 16000, |
int | inputChannels = 1 ) |
Starts audio testing mode with the given sample rate and input channels.
sampleRate | The sample rate to use. |
inputChannels | The number of input channels. |
void UVoxtaAudioInput::StartStreaming | ( | bool | isTestMode = false | ) |
Starts streaming audio data to the server.
void UVoxtaAudioInput::StopAudioTesting | ( | ) |
Stops audio testing mode.
void UVoxtaAudioInput::StopStreaming | ( | ) |
Stops streaming audio data to the server.
FVoxtaAudioInputStateChanged UVoxtaAudioInput::VoxtaAudioInputStateChangedEvent |
Event fired after both the audiosocket and the capturedevice are initialized.
FVoxtaAudioInputStateChangedNative UVoxtaAudioInput::VoxtaAudioInputStateChangedEventNative |