Skip to content

Commit a2447f0

Browse files
committed
DOC: move latency docs from default.latency to Stream
1 parent f595986 commit a2447f0

File tree

1 file changed

+36
-46
lines changed

1 file changed

+36
-46
lines changed

sounddevice.py

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,10 @@ def __init__(self, samplerate=None, blocksize=None,
16051605
Device index(es) or query string(s) specifying the device(s)
16061606
to be used. The default value(s) can be changed with
16071607
`default.device`.
1608+
If a string is given, the device is selected which contains
1609+
all space-separated parts in the right order. Each device
1610+
string contains the name of the corresponding host API in
1611+
the end. The string comparison is case-insensitive.
16081612
channels : int or pair of int, optional
16091613
The number of channels of sound to be delivered to the
16101614
stream callback or accessed by `read()` or `write()`. It
@@ -1624,26 +1628,30 @@ def __init__(self, samplerate=None, blocksize=None,
16241628
The packed 24 bit format ``'int24'`` is only supported in
16251629
the "raw" stream classes, see `RawStream`. The default
16261630
value(s) can be changed with `default.dtype`.
1631+
If NumPy is available, the corresponding `numpy.dtype`
1632+
objects can be used as well. The floating point
1633+
representations ``'float32'`` and ``'float64'`` use ``+1.0``
1634+
and ``-1.0`` as the maximum and minimum values,
1635+
respectively. ``'uint8'`` is an unsigned 8 bit format where
1636+
``128`` is considered "ground".
16271637
latency : float or {'low', 'high'} or pair thereof, optional
16281638
The desired latency in seconds. The special values
16291639
``'low'`` and ``'high'`` (latter being the default) select
1630-
the default low and high latency, respectively (see
1631-
`query_devices()`). The default value(s) can be changed
1632-
with `default.latency`.
1633-
Where practical, implementations should configure their
1634-
latency based on this parameter, otherwise they may choose
1635-
the closest viable latency instead. Unless the suggested
1636-
latency is greater than the absolute upper limit for the
1637-
device, implementations should round the *latency* up to the
1638-
next practical value -- i.e. to provide an equal or higher
1639-
latency wherever possible. Actual latency values for an
1640-
open stream may be retrieved using the `latency` attribute.
1641-
1642-
.. note:: Specifying the desired latency as 'high' does
1643-
not guarantee a stable audio stream. For reference, by
1644-
default Audacity specifies a desired latency of 100ms and
1645-
achieves robust performance.
1640+
the device's default low and high latency, respectively (see
1641+
`query_devices()`). ``'high'`` is typically more robust
1642+
(i.e. buffer under-/overflows are less likely),
1643+
but the latency may be too large for interactive applications.
16461644
1645+
.. note:: Specifying the desired latency as ``'high'`` does
1646+
not *guarantee* a stable audio stream. For reference, by
1647+
default Audacity_ specifies a desired latency of ``0.1``
1648+
seconds and typically achieves robust performance.
1649+
1650+
.. _Audacity: https://www.audacityteam.org/
1651+
1652+
The default value(s) can be changed with `default.latency`.
1653+
Actual latency values for an open stream can be retrieved
1654+
using the `latency` attribute.
16471655
extra_settings : settings object or pair thereof, optional
16481656
This can be used for host-API-specific input/output
16491657
settings. See `default.extra_settings`.
@@ -2057,27 +2065,29 @@ class default(object):
20572065
device = None, None
20582066
"""Index or query string of default input/output device.
20592067
2060-
If not overwritten, this is queried from PortAudio.
2068+
See the *device* argument of `Stream`.
20612069
2062-
If a string is given, the device is selected which contains all
2063-
space-separated parts in the right order. Each device string
2064-
contains the name of the corresponding host API in the end.
2065-
The string comparison is case-insensitive.
2070+
If not overwritten, this is queried from PortAudio.
20662071
20672072
See Also
20682073
--------
20692074
:func:`query_devices`
20702075
20712076
"""
20722077
channels = _default_channels = None, None
2073-
"""Number of input/output channels.
2078+
"""Default number of input/output channels.
20742079
2075-
The maximum number of channels for a given device can be found out
2076-
with `query_devices()`.
2080+
See the *channels* argument of `Stream`.
2081+
2082+
See Also
2083+
--------
2084+
:func:`query_devices`
20772085
20782086
"""
20792087
dtype = _default_dtype = 'float32', 'float32'
2080-
"""Data type used for input/output samples.
2088+
"""Default data type used for input/output samples.
2089+
2090+
See the *dtype* argument of `Stream`.
20812091
20822092
The types ``'float32'``, ``'int32'``, ``'int16'``, ``'int8'`` and
20832093
``'uint8'`` can be used for all streams and functions.
@@ -2087,29 +2097,9 @@ class default(object):
20872097
`RawStream` support ``'int24'`` (packed 24 bit format, which is
20882098
*not* supported in NumPy!).
20892099
2090-
If NumPy is available, the corresponding `numpy.dtype` objects can
2091-
be used as well.
2092-
2093-
The floating point representations ``'float32'`` and ``'float64'``
2094-
use +1.0 and -1.0 as the maximum and minimum values, respectively.
2095-
``'uint8'`` is an unsigned 8 bit format where 128 is considered
2096-
"ground".
2097-
20982100
"""
20992101
latency = _default_latency = 'high', 'high'
2100-
"""Suggested input/output latency in seconds.
2101-
2102-
The special values ``'low'`` and ``'high'`` can be used to select
2103-
the default low/high latency of the chosen device.
2104-
``'high'`` is typically more robust (i.e. buffer under-/overflows
2105-
are less likely), but the latency may be too large for interactive
2106-
applications.
2107-
2108-
See Also
2109-
--------
2110-
:func:`query_devices`
2111-
2112-
"""
2102+
"""See the *latency* argument of `Stream`."""
21132103
extra_settings = _default_extra_settings = None, None
21142104
"""Host-API-specific input/output settings.
21152105

0 commit comments

Comments
 (0)