Class AudioDevice
java.lang.Object
uno.anahata.asi.toolkit.audio.AudioDevice
Represents a stable, model-agnostic descriptor for an audio device.
This class is the authoritative way to identify and interact with hardware mixers. It provides static discovery and instance-level hardware binding (opening lines) to ensure consistency across the model and UI.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing the direction of the audio data. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AudioFormatDefault format for recording (16kHz, 16-bit, Mono) - Optimized for speech.private booleanWhether this device is the system's default line.private StringA detailed description of the device.private StringThe unique identifier for the device, derived from hardware metadata.private StringThe human-readable name of the device.static final AudioFormatDefault format for playback (44.1kHz, 16-bit, Stereo) - CD Quality.private AudioDevice.TypeThe type of device (INPUT or OUTPUT).private StringThe vendor of the device. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AudioDevicefindDevice(AudioDevice.Type type, String id) Finds a specific audio device by its unique ID and type.static AudioDevicefromMixerInfo(Mixer.Info info, AudioDevice.Type type) Factory method to create an AudioDevice from a Mixer.Info and a type.static StringgenerateStableId(Mixer.Info info) Generates a stable, hash-based ID for a mixer.getInputLine(AudioFormat format) Resolves an input line (TargetDataLine) for this device and a format.Resolves this descriptor back to a live JRE Mixer.Info.getOutputLine(AudioFormat format) Resolves an output line (SourceDataLine) for this device and a format.static List<AudioDevice> Lists all available audio devices that support data lines (Source/Target).static List<AudioDevice> Lists available audio devices of a specific type.Returns a rich Markdown representation of the device for the AI model.toString()Returns the human-friendly name for UI components.
-
Field Details
-
DEFAULT_FORMAT
Default format for recording (16kHz, 16-bit, Mono) - Optimized for speech. -
PLAYBACK_FORMAT
Default format for playback (44.1kHz, 16-bit, Stereo) - CD Quality. -
id
The unique identifier for the device, derived from hardware metadata. -
name
The human-readable name of the device. -
vendor
The vendor of the device. -
description
A detailed description of the device. -
type
The type of device (INPUT or OUTPUT). -
defaultLine
private boolean defaultLineWhether this device is the system's default line.
-
-
Constructor Details
-
AudioDevice
public AudioDevice()
-
-
Method Details
-
fromMixerInfo
Factory method to create an AudioDevice from a Mixer.Info and a type.- Parameters:
info- The mixer info.type- The device type.- Returns:
- A new AudioDevice instance.
-
generateStableId
Generates a stable, hash-based ID for a mixer.- Parameters:
info- The mixer info.- Returns:
- A stable ID string.
-
listAvailableDevices
Lists all available audio devices that support data lines (Source/Target).- Returns:
- A list of
AudioDevicedescriptors.
-
listAvailableDevices
Lists available audio devices of a specific type.- Parameters:
type- The desired device type.- Returns:
- A filtered list of
AudioDevicedescriptors.
-
findDevice
Finds a specific audio device by its unique ID and type.- Parameters:
type- The device type.id- The device identifier.- Returns:
- The AudioDevice, or null if not found.
-
getOutputLine
Resolves an output line (SourceDataLine) for this device and a format.- Parameters:
format- The desired audio format.- Returns:
- A SourceDataLine instance.
- Throws:
LineUnavailableException- if the line is already in use.
-
getInputLine
Resolves an input line (TargetDataLine) for this device and a format.If the configured device mixer is unavailable or disconnected, automatically falls back to the system default input line.
- Parameters:
format- The desired audio format.- Returns:
- A TargetDataLine instance.
- Throws:
LineUnavailableException- if no audio line is available.
-
getMixerInfo
Resolves this descriptor back to a live JRE Mixer.Info.- Returns:
- The Mixer.Info, or null if the device is no longer present.
-
toMarkdown
Returns a rich Markdown representation of the device for the AI model.- Returns:
- The markdown string.
-
toString
-

