jdxi_editor.midi.utils.usb_recorder
USBRecorder
Records an input with sounddevice and writes a 16-bit WAV. sounddevice’s wheels carry PortAudio, so this does not use PyAudio.
Attributes
Classes
A sounddevice input whose |
|
A convenient class for recording audio from a USB input device. |
Functions
The sounddevice module, or None when it did not import. |
|
sounddevice's device list, or None when it cannot be queried. |
|
|
sounddevice's host APIs, or |
Module Contents
- jdxi_editor.midi.utils.usb_recorder._sounddevice()[source]
The sounddevice module, or None when it did not import.
- jdxi_editor.midi.utils.usb_recorder._query_devices()[source]
sounddevice’s device list, or None when it cannot be queried.
- jdxi_editor.midi.utils.usb_recorder._query_hostapis() list[source]
sounddevice’s host APIs, or
[].Windows lists one device once per host API under an identical name, so the API is what tells those entries apart. An empty list is tolerated: the labelling falls back to the position.
- Returns:
list
- class jdxi_editor.midi.utils.usb_recorder._PcmStream(stream)[source]
A sounddevice input whose
readreturns PCM bytes.
- class jdxi_editor.midi.utils.usb_recorder.USBRecorder(input_device_index: int = None, channels: int = 2, rate: int = 44100, frames_per_buffer: int = 1024)[source]
A convenient class for recording audio from a USB input device.
- list_devices()[source]
Logs every PortAudio entry, and returns the lines.
This one is for diagnosing a report, not for choosing from, so it keeps the position and names the host API: the same device appears once per API on Windows, and which one was picked matters.
- list_input_devices() List[Tuple[str, int]][source]
Input-capable devices as (display label, PortAudio index).
Output-only entries are omitted so the UI cannot pick a device that cannot capture (a common cause of silent WAVs).
The label is the device’s name, told apart by host API when Windows lists it more than once, and the input-channel count. It used to lead with the PortAudio index, which was the only thing distinguishing three identical Windows entries and meant nothing to anyone reading the menu; the index is still what is selected with, in the combo’s item data.
- input_info(index: int) dict[source]
Name, input-channel count and default sample rate of device index.
- Parameters:
index – int sounddevice device index
- Returns:
dict
- open_input() _PcmStream[source]
Open the selected input as 16-bit PCM.
Tries stereo first when the device reports at least two inputs, then falls back to mono — matching InputDeviceSource in the Audio Monitor.
- Returns:
_PcmStream