VoiceSynchronizable Class

Synchronizable component for voice chat.

Definition

Namespace: Alteruna.Multiplayer.Unity
Assembly: Alteruna.Multiplayer.UnityFiles (in Alteruna.Multiplayer.UnityFiles.dll) Version: 1.0.0+c5328b35489e83c42e288435f5acf6115fd519e0
C#
public class VoiceSynchronizable : Synchronizable
Inheritance
Object    Object    Component    Behaviour    MonoBehaviour    CommunicationBridge    CommunicationBridgeUID    Synchronizable    VoiceSynchronizable

Remarks

The delay from microphone to audio output on other clients consists of several parts.
1. Microphone recording buffer.
2. Lenght of the packet being sent. Default is 100ms (SendFrequency)
3. Network latency / ping.
4. Unity audio stream delay.
5. Playback buffer. 200ms or less.

Ways of improving delay are decreasing SendFrequency, changing unity playback buffer (DSP Buffer Size), and using an alternative solution for audio streaming.

Constructors

Properties

Activity Value between 0 and 1 representing the activity of the microphone. 1 means that that the volume is above the silence threshold. 0 means that the volume is below the silence threshold and have been for at least SilenceTimeout.
AudioFrequency Audio sample-rate.
Compression Target compression method.
DeviceName Name of the input device.
IsActive True if the microphone is active and sending data.
IsSender True when object is possessed by local user and is recording. False when object acts as receiver.
LocalInputController Get the local input controller. The recording device is set to the default microphone.
Microphone Audio input method.
PeakVolume Highest volume recorded this frame.

Methods

AssembleData
(Overrides SynchronizableAssembleData(Writer, SerializeInfo))
AvailableInputDevices Get the list of available input devices.
ClearDevice Clear the microphone device and stop recording.
ClearDeviceLocal Clear the microphone device and stop recording.
DisassembleData
(Overrides SynchronizableDisassembleData(Reader, UnserializeInfo))
OnDestroy
(Overrides CommunicationBridgeUIDOnDestroy)
Possessed
(Overrides CommunicationBridgePossessed(Boolean, User))
Reset
(Overrides SynchronizableReset)
SetDevice Set the default microphone as the recording device.
SetDevice(Int32) Set the microphone device by index.
SetDevice(String) Set the microphone device by name.

Fields

CurrentSavedFromCompressionPer100Sampels 
PackageLossBuffer Maximum number of unordered pending packages. When the buffer count been met, a package is considered lost and will be skipped. Will increase RAM usage.
PlaybackSource Source for playback.
SendFrequency How often to send data from the buffer. Lower values will decrease latency but increase bandwidth.
SilenceCutoff Silence threshold. Values below this cutoff are considered silence.
SilenceTimeout Time in seconds to record after the silence threshold is reached.
StatisticsPeekSavedFromCompressionPer100Sampels 
StatisticsTotalSaved 
StatisticsTotalWritten 
Volume Playback volume.

See Also