Gorilla.Audio.STT.Capture Unit Reference
Overview
The Gorilla.Audio.STT.Capture unit provides backend independent access to a
recording device. It defines IGorillaAudioCapture, the shared base class
TGorillaAudioCaptureBase, and three implementations: OpenAL, FMOD and a null
device used when nothing else works.
The typical lifecycle is Open() — Start() — Read() in a loop — Stop() —
Close(). Read() never blocks; it returns whatever the device has ready.
Class Hierarchy
TInterfacedObject
└── TGorillaAudioCaptureBase (IGorillaAudioCapture)
├── TGorillaOpenALCapture — name "OpenAL"
├── TGorillaFMODCapture — name "FMOD"
└── TGorillaNullCapture — name "None"
IGorillaAudioCapture
Device Handling
| Method | Description |
|---|---|
GetName() |
Human readable name of the backend |
GetDevices() |
Names of all recording devices the backend offers |
Open(ADevice, ASampleRate, AChannels) |
Opens a device without starting the recording. ADevice empty opens the system default |
Start() |
Begins filling the capture buffer |
Stop() |
Stops filling it, the device stays open |
Close() |
Stops the recording and releases the device |
The device may not be able to deliver the requested format. Query
GetSampleRate() and GetChannels() afterwards to learn what was actually
granted, and resample accordingly.
Reading
| Method | Description |
|---|---|
Read(var ABuffer) |
Reads everything the device has ready; returns the number of SmallInt entries written, which is the number of sample frames multiplied by GetChannels(). The buffer is grown as needed and may stay larger than the returned count |
GetAvailable() |
Number of sample frames waiting to be read |
State
| Method | Description |
|---|---|
IsCapturing() |
True between Start() and Stop() |
IsOpen() |
True while a device is open |
GetSampleRate() |
Rate the device was actually opened with |
GetChannels() |
Channel count the device was actually opened with |
GetDeviceName() |
Name of the device currently open |
GetLastError() |
Reason of the last failed operation |
Health Data
| Method | Description |
|---|---|
GetCapturedFrames() |
Sample frames handed out since Start() |
GetThroughput() |
Share of real time the device delivers once it runs; 1.0 = healthy. Measured from the first sample actually received, not from Start() |
GetStartupLatency() |
Time the device needed to wake up |
A driver that silently drops samples is the most confusing failure of the whole subsystem: recording "works", the level meter moves, and the recognizer returns nonsense because it is fed audio with holes in it. Log the throughput during development.
Startup latency is reported separately on purpose — mixing the two would blame a slow-starting device for dropping samples it never lost.
Implementations
| Class | Name | Notes |
|---|---|---|
TGorillaOpenALCapture |
OpenAL |
Uses the OpenAL capture extension |
TGorillaFMODCapture |
FMOD |
Uses the FMOD record API; constructed with the manager, GetNativeSampleRate() reports the driver rate, ResolveDriver() maps a device name onto an FMOD driver index |
TGorillaNullCapture |
None |
Placeholder whose Open() fails with an explanatory message |
Each implements IsSupported() as a class function.
Protected Methods (for implementers)
DoOpen(), DoClose(), DoStart(), DoStop(), DoRead(),
DoGetAvailable() — the base class handles state tracking, error reporting and
the health statistics around them.
Global Functions
| Function | Description |
|---|---|
GorillaCreateAudioCapture(AManager) |
Creates the capture implementation matching an audio manager: an FMOD manager selects the FMOD backend, an OpenAL manager the OpenAL backend, nil picks the first backend available. Never returns nil — when no backend works, a TGorillaNullCapture is returned whose Open() fails with an explanatory message |
GorillaCaptureDevices(AManager) |
Lists the recording devices of the backend belonging to a manager |
GorillaCaptureSupported() |
True when any capture backend works on this platform |
Companion Unit: Gorilla.Audio.STT.Utils
| Name | Description |
|---|---|
TGorillaSampleBuffer |
Growable ring buffer of float samples |
GorillaInt16ToFloat() / GorillaFloatToInt16() |
Sample format conversion |
GorillaDownmixToMono() |
Stereo to mono |
GorillaResampleMono() |
Resampling to the recognition rate |
GorillaLowPassMono() |
Anti-alias filtering before downsampling |
GorillaPrepareForRecognition() |
Downmix, resample and convert in one call |
GorillaComputeRMS(), GorillaComputePeak(), GorillaComputeZeroCrossingRate() |
Level and noise metrics used by the detector |
GorillaRemoveDCOffset(), GorillaNormalizeSamples() |
Signal clean-up |
GorillaSamplesToWave(), GorillaSaveSamplesToWave(), GorillaWaveToSamples() |
Wave file helpers |
GorillaNormalizeSpokenText() |
Normalizes recognized text before command matching |
GORILLA_STT_SAMPLERATE |
16000 — the rate the recognizers work on |
See Also
- Speech-to-Text UserGuide — Practical usage guide
- Gorilla.Audio.STT.Listener — Creates and drives the capture backend
- Gorilla.Audio.STT.VAD — Consumes the captured samples
- Gorilla.Audio.OpenAL — The OpenAL driver
- Gorilla.Audio.FMOD — The FMOD driver