jdxi_editor.audio.audio_source
An input device, copied into the ring and nothing else.
Opening the device is the only place PortAudio is touched. The callback copies into storage the source already owns.
Classes
Captures one input device into a |
Functions
The sounddevice module, or None when the extra is not installed. |
|
|
Copy one callback buffer into the ring. |
|
A message for the status line when no rate or channel count opened. |
Module Contents
- jdxi_editor.audio.audio_source._sounddevice()[source]
The sounddevice module, or None when the extra is not installed.
- jdxi_editor.audio.audio_source.copy_input(indata: numpy.ndarray, scratch: numpy.ndarray, ring: jdxi_editor.audio.audio_buffer.SampleRing) None[source]
Copy one callback buffer into the ring.
A mono buffer is written to both channels. Nothing is allocated: the scratch array belongs to the source and is reused on every callback.
- Parameters:
indata – np.ndarray
(frames, channels)from the devicescratch – np.ndarray stereo scratch, at least as long as a block
ring – SampleRing
- Returns:
None
- jdxi_editor.audio.audio_source.describe_open_error(error: Exception | None) str[source]
A message for the status line when no rate or channel count opened.
PortAudio reports a device that PipeWire or PulseAudio already holds as “Device unavailable” (-9985); that is the usual failure for a raw ALSA
hw:device on a desktop Linux, and the fix is to choose thepipewire,defaultor PulseAudio input instead.- Parameters:
error – Optional[Exception] the last failure
- Returns:
str
- class jdxi_editor.audio.audio_source.InputDeviceSource(ring: jdxi_editor.audio.audio_buffer.SampleRing, sample_rate: int = SAMPLE_RATE, block: int = BLOCK_SIZE)[source]
Captures one input device into a
SampleRing.- start(device: int | None = None) int[source]
Open the input and start copying.
The monitor’s own rate is tried first, then the device’s default rate: a raw ALSA
hw:device does no rate conversion, and the JD-Xi’s USB audio input refuses 48 kHz. At each rate stereo is tried first; a mono device is opened with one channel and duplicated in the callback.sample_rateis set to the rate that opened.- Parameters:
device – Optional[int] sounddevice index; None is the default
- Returns:
int the sample rate the stream opened at, Hz