Microphone
classin packageklyn.audio
public class Microphone implements AutoClosable
Microphone
All Implemented Interfaces: 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.

Example

try microphone = Microphone.open(): clip = microphone.read()

Properties
Modifier and Type Member Description
public readonly property capturedFrames
capturedFrames as ULong
Mono frames accepted from the OS since opening, including unread audio.
public readonly property channels
channels as Int = 1
Interleaved channel count.
public readonly property isRecording
isRecording as Boolean
Whether the device is still capturing.
public readonly property level
level as Double
Latest captured block RMS, even when recognition is busy.
public readonly property maximumLevel
maximumLevel as Double
Largest block RMS since opening, retained after stop for diagnosis.
public readonly property sampleRate
sampleRate as Int = 16000
Capture frequency in Hz.
Methods
Modifier and Type Member Description
public override close
close() as Void
Stops, wakes pending reads, discards queued audio and frees ownership.
public static listDevices
listDevices() as ArrayList<AudioInputDevice>
Enumerates the current OS audio inputs without opening a recording stream.
public static open
open(bufferSeconds as Int = 10, device as AudioInputDevice = null) as Microphone
Starts capture only after explicit application/user consent.
public read
read() as AudioClip
Waits for a bounded PCM block; null means stopped and completely drained.
public stop
stop() as Void
Stops capture and preserves queued audio for the consumer to drain.
Inherited Methods
methodInherited Methods from AutoClosable: close