Module-wide Default Settings
- class sounddevice.default[source]
Get/set defaults for the sounddevice module.
The attributes
device,channels,dtype,latencyandextra_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.Examples
>>> 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
None:>>> sd.default.samplerate = None >>> sd.default.device = None, 4
Use
reset()to reset all attributes:>>> sd.default.reset()
- device = (None, None)
Index or query string of default input/output device.
If not overwritten, this is queried from PortAudio.
See also
default,query_devices(), the device argument ofStream
- channels = (None, None)
Default number of input/output channels.
See also
default,query_devices(), the channels argument ofStream
- dtype = ('float32', 'float32')
Default data type used for input/output samples.
The types
'float32','int32','int16','int8'and'uint8'can be used for all streams and functions. Additionally,play(),rec()andplayrec()support'float64'(for convenience, data is merely converted from/to'float32') andRawInputStream,RawOutputStreamandRawStreamsupport'int24'(packed 24 bit format, which is not supported in NumPy!).See also
default,numpy.dtype, the dtype argument ofStream
- extra_settings = (None, None)
Host-API-specific input/output settings.
See also
- samplerate = None
Sampling frequency in Hertz (= frames per second).
See also
- clip_off = False
Disable clipping.
Set to
Trueto disable default clipping of out of range samples.
- dither_off = False
Disable dithering.
Set to
Trueto disable default dithering.
- never_drop_input = False
Set behavior for input overflow of full-duplex streams.
Set to
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. onlyStreamandRawStreamand only if callback was specified; this includesplayrec()) and only when used in combination withblocksize=0(the default). Using this flag incorrectly results in an error being raised. See also http://www.portaudio.com/docs/proposals/001-UnderflowOverflowHandling.html.
- prime_output_buffers_using_stream_callback = False
How to fill initial output buffers.
Set to
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 (InputStreamandRawInputStream) and blocking read/write streams (i.e. if callback wasn’t specified). See also http://www.portaudio.com/docs/proposals/020-AllowCallbackToPrimeStream.html.
- property hostapi
Index of the default host API (read-only).