Module-wide Default Settings¶
||Get/set defaults for the sounddevice module.|
Get/set defaults for the sounddevice module.
extra_settingsaccept single values which specify the given property for both input and output. However, if the property differs between input and output, pairs of values can be used, where the first value specifies the input and the second value specifies the output. All other attributes are always single values.
>>> import sounddevice as sd >>> sd.default.samplerate = 48000 >>> sd.default.dtype ['float32', 'float32']
Different values for input and output:
>>> sd.default.channels = 1, 2
A single value sets both input and output at the same time:
>>> sd.default.device = 5 >>> sd.default.device [5, 5]
An attribute can be set to the “factory default” by assigning
>>> sd.default.samplerate = None >>> sd.default.device = None, 4
reset()to reset all attributes:
device= (None, None)¶
Index or query string of default input/output device.
If not overwritten, this is queried from PortAudio.
If a string is given, the device is selected which contains all space-separated parts in the right order. Each device string contains the name of the corresponding host API in the end. The string comparison is case-insensitive.
channels= (None, None)¶
Number of input/output channels.
The maximum number of channels for a given device can be found out with
dtype= ('float32', 'float32')¶
Data type used for input/output samples.
'uint8'can be used for all streams and functions. Additionally,
'float64'(for convenience, data is merely converted from/to
'int24'(packed 24 bit format, which is not supported in NumPy!).
If NumPy is available, the corresponding
numpy.dtypeobjects can be used as well.
The floating point representations
'float64'use +1.0 and -1.0 as the maximum and minimum values, respectively.
'uint8'is an unsigned 8 bit format where 128 is considered “ground”.
latency= ('high', 'high')¶
Suggested input/output latency in seconds.
The special values
'high'can be used to select the default low/high latency of the chosen device.
'high'is typically more robust (i.e. buffer under-/overflows are less likely), but the latency may be too large for interactive applications.
extra_settings= (None, None)¶
Host-API-specific input/output settings.
Sampling frequency in Hertz (= frames per second).
Trueto disable default clipping of out of range samples.
Trueto disable default dithering.
Set behavior for input overflow of full-duplex streams.
Trueto request that where possible a full duplex stream will not discard overflowed input samples without calling the stream callback. This flag is only valid for full-duplex callback streams (i.e. only
RawStreamand only if callback was specified; this includes
playrec()) and only when used in combination with
blocksize=0(the default). Using this flag incorrectly results in an error being raised. See also http://www.portaudio.com/docs/proposals/001-UnderflowOverflowHandling.html.
How to fill initial output buffers.
Trueto call the stream callback to fill initial output buffers, rather than the default behavior of priming the buffers with zeros (silence). This flag has no effect for input-only (
RawInputStream) and blocking read/write streams (i.e. if callback wasn’t specified). See also http://www.portaudio.com/docs/proposals/020-AllowCallbackToPrimeStream.html.
Index of the default host API (read-only).
Reset all attributes to their “factory default”.