Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions examples/play_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
4 changes: 2 additions & 2 deletions examples/play_long_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
4 changes: 2 additions & 2 deletions examples/play_long_file_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
4 changes: 2 additions & 2 deletions examples/play_sine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
10 changes: 5 additions & 5 deletions examples/play_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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))
2 changes: 1 addition & 1 deletion examples/plot_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
1 change: 0 additions & 1 deletion examples/rec_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"""
import contextlib
import queue
import sys
import tempfile
import threading
import tkinter as tk
Expand Down
2 changes: 1 addition & 1 deletion examples/rec_unlimited.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
4 changes: 2 additions & 2 deletions examples/spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
4 changes: 2 additions & 2 deletions examples/wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
20 changes: 9 additions & 11 deletions sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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`."""
Expand All @@ -2164,7 +2162,7 @@ class default:

See Also
--------
`query_devices()`
`default`, `query_devices()`

"""
blocksize = _lib.paFramesPerBufferUnspecified
Expand Down