From 2a63fe2caa741a32a7cc32f74bc2c39d2c709c6b Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Wed, 15 Oct 2025 21:11:40 +0200 Subject: [PATCH 1/3] Fix some error reported by Pyright --- examples/play_file.py | 4 ++-- examples/play_long_file.py | 4 ++-- examples/play_long_file_raw.py | 4 ++-- examples/play_sine.py | 4 ++-- examples/play_stream.py | 10 +++++----- examples/plot_input.py | 2 +- examples/rec_gui.py | 1 - examples/rec_unlimited.py | 2 +- examples/spectrogram.py | 4 ++-- examples/wire.py | 4 ++-- sounddevice.py | 4 ++-- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/examples/play_file.py b/examples/play_file.py index 2efefc7..98c37dd 100755 --- a/examples/play_file.py +++ b/examples/play_file.py @@ -80,6 +80,6 @@ def callback(outdata, frames, time, status): with stream: event.wait() # Wait until playback is finished except KeyboardInterrupt: - parser.exit('\nInterrupted by user') + parser.exit(1, '\nInterrupted by user') except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/play_long_file.py b/examples/play_long_file.py index bb975b9..eb42895 100755 --- a/examples/play_long_file.py +++ b/examples/play_long_file.py @@ -101,9 +101,9 @@ def callback(outdata, frames, time, status): q.put(data, timeout=timeout) event.wait() # Wait until playback is finished except KeyboardInterrupt: - parser.exit('\nInterrupted by user') + parser.exit(1, '\nInterrupted by user') except queue.Full: # A timeout occurred, i.e. there was an error in the callback parser.exit(1) except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/play_long_file_raw.py b/examples/play_long_file_raw.py index 720a133..267af24 100755 --- a/examples/play_long_file_raw.py +++ b/examples/play_long_file_raw.py @@ -92,9 +92,9 @@ def callback(outdata, frames, time, status): q.put(data, timeout=timeout) event.wait() # Wait until playback is finished except KeyboardInterrupt: - parser.exit('\nInterrupted by user') + parser.exit(1, '\nInterrupted by user') except queue.Full: # A timeout occurred, i.e. there was an error in the callback parser.exit(1) except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/play_sine.py b/examples/play_sine.py index de1875a..7a60445 100755 --- a/examples/play_sine.py +++ b/examples/play_sine.py @@ -59,6 +59,6 @@ def callback(outdata, frames, time, status): print('#' * 80) input() except KeyboardInterrupt: - parser.exit('') + parser.exit(1, '\nInterrupted by user') except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/play_stream.py b/examples/play_stream.py index 61956f1..78d16c7 100755 --- a/examples/play_stream.py +++ b/examples/play_stream.py @@ -61,16 +61,16 @@ def int_or_str(text): info = ffmpeg.probe(args.url) except ffmpeg.Error as e: sys.stderr.buffer.write(e.stderr) - parser.exit(e) + parser.exit(1, str(e)) streams = info.get('streams', []) if len(streams) != 1: - parser.exit('There must be exactly one stream available') + parser.exit(1, 'There must be exactly one stream available') stream = streams[0] if stream.get('codec_type') != 'audio': - parser.exit('The stream must be an audio stream') + parser.exit(1, 'The stream must be an audio stream') channels = stream['channels'] samplerate = float(stream['sample_rate']) @@ -117,9 +117,9 @@ def callback(outdata, frames, time, status): while True: q.put(process.stdout.read(read_size), timeout=timeout) except KeyboardInterrupt: - parser.exit('\nInterrupted by user') + parser.exit(1, '\nInterrupted by user') except queue.Full: # A timeout occurred, i.e. there was an error in the callback parser.exit(1) except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/plot_input.py b/examples/plot_input.py index 5586038..ac84362 100755 --- a/examples/plot_input.py +++ b/examples/plot_input.py @@ -116,4 +116,4 @@ def update_plot(frame): with stream: plt.show() except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/rec_gui.py b/examples/rec_gui.py index 7135b90..a5b4701 100755 --- a/examples/rec_gui.py +++ b/examples/rec_gui.py @@ -12,7 +12,6 @@ """ import contextlib import queue -import sys import tempfile import threading import tkinter as tk diff --git a/examples/rec_unlimited.py b/examples/rec_unlimited.py index c7cc8f5..d1f8228 100755 --- a/examples/rec_unlimited.py +++ b/examples/rec_unlimited.py @@ -83,4 +83,4 @@ def callback(indata, frames, time, status): print('\nRecording finished: ' + repr(args.filename)) parser.exit(0) except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/spectrogram.py b/examples/spectrogram.py index 0ad6a34..8dc8a65 100755 --- a/examples/spectrogram.py +++ b/examples/spectrogram.py @@ -106,6 +106,6 @@ def callback(indata, frames, time, status): '\x1b[0m', sep='') break except KeyboardInterrupt: - parser.exit('Interrupted by user') + parser.exit(1, '\nInterrupted by user') except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/examples/wire.py b/examples/wire.py index 593b993..cc78a13 100755 --- a/examples/wire.py +++ b/examples/wire.py @@ -63,6 +63,6 @@ def callback(indata, outdata, frames, time, status): print('#' * 80) input() except KeyboardInterrupt: - parser.exit('') + parser.exit(1, '\nInterrupted by user') except Exception as e: - parser.exit(type(e).__name__ + ': ' + str(e)) + parser.exit(1, type(e).__name__ + ': ' + str(e)) diff --git a/sounddevice.py b/sounddevice.py index 15fbd42..d8200ce 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -829,11 +829,11 @@ def __init__(self, kind, samplerate=None, blocksize=None, device=None, extra_settings, samplerate) self._device = parameters.device self._channels = parameters.channelCount + iparameters = _ffi.NULL + oparameters = _ffi.NULL if kind == 'input': iparameters = parameters - oparameters = _ffi.NULL elif kind == 'output': - iparameters = _ffi.NULL oparameters = parameters ffi_callback = _ffi.callback('PaStreamCallback', error=_lib.paAbort) From 82fbe766f8ae1c0ba5520b26ce78bea16c161316 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sun, 18 May 2025 12:21:30 +0200 Subject: [PATCH 2/3] DOC: update "see also" in "default" docstrings --- sounddevice.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sounddevice.py b/sounddevice.py index d8200ce..c7a22b5 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -2116,30 +2116,24 @@ class default: device = None, None """Index or query string of default input/output device. - See the *device* argument of `Stream`. - If not overwritten, this is queried from PortAudio. See Also -------- - `query_devices()` + `default`, `query_devices()`, the *device* argument of `Stream` """ channels = _default_channels = None, None """Default number of input/output channels. - See the *channels* argument of `Stream`. - See Also -------- - `query_devices()` + `default`, `query_devices()`, the *channels* argument of `Stream` """ dtype = _default_dtype = 'float32', 'float32' """Default data type used for input/output samples. - See the *dtype* argument of `Stream`. - The types ``'float32'``, ``'int32'``, ``'int16'``, ``'int8'`` and ``'uint8'`` can be used for all streams and functions. Additionally, `play()`, `rec()` and `playrec()` support @@ -2148,6 +2142,10 @@ class default: `RawStream` support ``'int24'`` (packed 24 bit format, which is *not* supported in NumPy!). + See Also + -------- + `default`, `numpy:numpy.dtype`, the *dtype* argument of `Stream` + """ latency = _default_latency = 'high', 'high' """See the *latency* argument of `Stream`.""" @@ -2164,7 +2162,7 @@ class default: See Also -------- - `query_devices()` + `default`, `query_devices()` """ blocksize = _lib.paFramesPerBufferUnspecified From 3c742d949f3e6871108f35b7eeaeb2e390f7a47e Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Wed, 15 Oct 2025 21:29:16 +0200 Subject: [PATCH 3/3] DOC: fix intersphinx mapping --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 2e3523e..b8850ed 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -35,7 +35,7 @@ intersphinx_mapping = { 'python': ('https://docs.python.org/3/', None), - 'numpy': ('https://docs.scipy.org/doc/numpy/', None), + 'numpy': ('https://numpy.org/doc/stable/', None), } master_doc = 'index'