public class Microphone implements AutoClosable
Owned recording from an OS audio input, independent of any AI model. Capture uses mono Float32 PCM at 16000 Hz. No device is opened by importing this class. One consumer reads blocks; stop() is safe from another thread. Queued audio is bounded: an overrun raises IOException rather than losing samples silently. close() discards unread audio and releases the device.
try microphone = Microphone.open(): clip = microphone.read()
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | capturedFramescapturedFrames as ULong |
Mono frames accepted from the OS since opening, including unread audio. |
| public readonly property | channelschannels as Int = 1 |
Interleaved channel count. |
| public readonly property | isRecordingisRecording as Boolean |
Whether the device is still capturing. |
| public readonly property | levellevel as Double |
Latest captured block RMS, even when recognition is busy. |
| public readonly property | maximumLevelmaximumLevel as Double |
Largest block RMS since opening, retained after stop for diagnosis. |
| public readonly property | sampleRatesampleRate as Int = 16000 |
Capture frequency in Hz. |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | closeclose() as Void |
Stops, wakes pending reads, discards queued audio and frees ownership. |
| public static | listDeviceslistDevices() as ArrayList<AudioInputDevice> |
Enumerates the current OS audio inputs without opening a recording stream. |
| public static | openopen(bufferSeconds as Int = 10, device as AudioInputDevice = null) as Microphone |
Starts capture only after explicit application/user consent. |
| public | readread() as AudioClip |
Waits for a bounded PCM block; null means stopped and completely drained. |
| public | stopstop() as Void |
Stops capture and preserves queued audio for the consumer to drain. |