pyquist.device¶
Sounddevice integration — persistent default-device selection,
play(), and record().
Sounddevice integration: device selection, play, and record.
The user’s chosen input/output devices are persisted as JSON under
CACHE_DIR / "device_defaults.json" and applied to sounddevice.default
once at module import time.
- pyquist.device.set_input_device(device_id_or_name=None, *, update_default=False)[source]¶
Selects the input device for the current Python session.
- Parameters:
device_id_or_name (
Union[int,str,None]) – Device index, or a substring of the device name. IfNone, prompts the user interactively.update_default (
bool) – IfFalse(default), the change applies only to this Python session. IfTrue, the choice is also persisted to the cache and reapplied next time pyquist is imported. Thepyquist devicesCLI command is the usual way to update the persistent default.
- Return type:
- pyquist.device.set_output_device(device_id_or_name=None, *, update_default=False)[source]¶
Selects the output device for the current Python session.
- Parameters:
device_id_or_name (
Union[int,str,None]) – Device index, or a substring of the device name. IfNone, prompts the user interactively.update_default (
bool) – IfFalse(default), the change applies only to this Python session. IfTrue, the choice is also persisted to the cache and reapplied next time pyquist is imported. Thepyquist devicesCLI command is the usual way to update the persistent default.
- Return type:
- pyquist.device.play(audio, *, safe=True, normalize=False, force_sounddevice=False)[source]¶
Plays an Audio.
In a Jupyter / IPython notebook this renders an inline player widget via
IPython.display.Audio. Outside a notebook (or whenforce_sounddevice=True) it plays through the default output device viasounddevice.- Parameters:
audio (
Audio) – The audio to play. Must have asample_rate.safe (
bool) – If True (default), attenuates the audio to -18 dBFS before playback to protect ears against accidentally hot signals.normalize (
bool) – If True, normalizes the audio to 0 dBFS before playback.force_sounddevice (
bool) – If True, always use sounddevice playback, even when called from a notebook. Useful when you want the audio played through the OS audio output rather than as an inline player widget.
- Return type: