Class SimpleVad
A minimal, adaptive voice activity detector operating on time-domain PCM. Supports float [-1,1] and 16-bit samples, with per-call adaptation to input frequency and channel count. Multi-channel input is downmixed to mono.
Inheritance
Namespace: Adrenak.UniVoice
Assembly: cs.temp.dll.dll
Syntax
public class SimpleVad
Remarks
The detector emits OnVadChanged when the speaking state toggles. Timings (attack, release, gaps) are maintained in milliseconds and remain stable across sample-rate changes.
Constructors
SimpleVad(SimpleVad.Config)
Initializes a new instance of SimpleVad.
Declaration
public SimpleVad(SimpleVad.Config config = null)
Parameters
| Type | Name | Description |
|---|---|---|
| SimpleVad.Config | config | Optional configuration. If null, defaults are used. |
Properties
IsSpeaking
Current speaking state.
Declaration
public bool IsSpeaking { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
Process(Int32, Int32, Int16[])
Convenience overload for processing fully-filled 16-bit buffers.
Declaration
public void Process(int frequency, int channels, short[] samples)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | frequency | Input sample rate in Hz. |
| System.Int32 | channels | Number of interleaved channels. |
| System.Int16[] | samples | Buffer containing interleaved sample data. |
Process(Int32, Int32, Int16[], Int32)
Processes interleaved 16-bit PCM with adaptive handling of frequency and channels. Multi-channel input is downmixed to mono via averaging.
Declaration
public void Process(int frequency, int channels, short[] samples, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | frequency | Input sample rate in Hz. If 0, a default is used. |
| System.Int32 | channels | Number of interleaved channels. If 0, treated as 1. |
| System.Int16[] | samples | Buffer containing interleaved sample data. |
| System.Int32 | count | Number of elements from |
Process(Int32, Int32, Single[])
Convenience overload for processing fully-filled float buffers.
Declaration
public void Process(int frequency, int channels, float[] samples)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | frequency | Input sample rate in Hz. |
| System.Int32 | channels | Number of interleaved channels. |
| System.Single[] | samples | Buffer containing interleaved sample data. |
Process(Int32, Int32, Single[], Int32)
Processes interleaved float PCM in the range [-1, 1] with adaptive handling of frequency and channels. Multi-channel input is downmixed to mono via averaging.
Declaration
public void Process(int frequency, int channels, float[] samples, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | frequency | Input sample rate in Hz. |
| System.Int32 | channels | Number of interleaved channels. If 0, treated as 1 (mono). |
| System.Single[] | samples | Buffer containing interleaved sample data. |
| System.Int32 | count | Number of elements from |
Reset(Boolean)
Resets internal state and timers.
Declaration
public void Reset(bool isSpeaking = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | isSpeaking | Initial speaking state after reset. |
Events
OnVadChanged
Raised when the VAD speaking state changes. The event argument is true when entering the speaking state, and false when exiting.
Declaration
public event Action<bool> OnVadChanged
Event Type
| Type | Description |
|---|---|
| System.Action<System.Boolean> |