Devices#

Read-only descriptors for the audio devices visible to the engine, plus the owned DeviceSetup builder passed to System.openDevice().

Fill the list with System.refreshDevices() (no stream is opened, and it works before init() and on an offline session) or as a side effect of System.init(). A refresh replaces the list, so descriptors and setups built from the old one are invalid afterwards: match devices by Device.name and Device.hostName, never by index. openDevice throws YseException when no stream opens. Sessions and devices covers device selection, sample rates and auto-reconnect end to end.

Upstream: YSE::device.

Device#

class Device

Read-only descriptor of an audio device on the host system.

Enumerated by the engine — only valid instances are those handed out by [System.devices]. Inspect [name], [hostName], the channel-name lists, supported sample rates, and buffer sizes; then build a [DeviceSetup] from one and pass it to [System.openDevice].

The getters are bound-checked by the engine: the indexed lists stop at the counts the device reports, and the scalar getters always return a defined value (0 for an unreported size or latency, -1 for [id]).

Constructors#

factory Device.borrowed(Pointer<YseDevice> handle)

Internal: wrap a borrowed pointer returned by yse_system_get_device.

Properties#

Pointer<YseDevice> get handle

Internal: native handle (for cross-wrapper plumbing).

String get name

Device name as reported by the host.

String get hostName

Host (driver) name: ASIO, WASAPI, ALSA, JACK, …

List<String> get outputChannelNames

Output channel names.

List<String> get inputChannelNames

Input channel names.

List<double> get sampleRates

All sample rates this device reports as supported.

List<int> get bufferSizes

All buffer sizes this device reports as supported.

int get defaultBufferSize

Default buffer size for this device, in frames.

0 means “the host does not advertise one”, not “zero frames”; passed on to [DeviceSetup.bufferSize] it asks the backend to choose. The PortAudio enumerator (desktop) reports 0 for every device, so read the negotiated size back from [System.activeBufferSize] once the device is open.

int get outputLatency

Reported output latency in samples.

int get inputLatency

Reported input latency in samples.

int get id

Host-assigned device ID, or -1 when this descriptor refers to no device.

Every device in [System.devices] carries a real, non-negative index. [System.openDevice] refuses a setup whose output device reads -1.

Methods#

String toString()

DeviceSetup#

class DeviceSetup implements Finalizable

Configuration passed to [System.openDevice].

Build one by selecting an output [Device], optionally an input [Device], and (also optionally) a buffer size. The engine falls back to the device’s defaults for fields you don’t set. A setup with no output device is refused by [System.openDevice].

Constructors#

factory DeviceSetup()

Construct an empty setup. Configure with the [input], [output], [sampleRate], and [bufferSize] setters before passing to [System.openDevice].

Properties#

Pointer<YseDeviceSetup> get handle

Internal: native handle (used by System.openDevice).

set input(Device value)

Select the input device.

set output(Device value)

Select the output device.

set sampleRate(double value)

Sample rate in Hz to open the device at; 0 (the default) means no request.

This does not change a running session’s rate. The session rate is fixed from [System.init] / [System.initOffline] until [System.close]: when this value differs from [System.sessionSampleRate], [System.openDevice] logs a warning and opens the stream at the session rate anyway (and throws if the device refuses that rate). To run at a given rate, set [System.requestedSampleRate] before init instead.

set bufferSize(int value)

Device buffer size in frames per callback. 0 lets the backend choose.

int get outputChannels

Output channel count of the device selected with [output] — the count [System.openDevice] opens the stream with. 0 before an output device is set.

Methods#

void dispose()

Destroy the underlying native setup and detach the finalizer.