Module-wide Default Settings§
- class sounddevice.default[source]§
Get/set defaults for the sounddevice module.
The attributes
device
,channels
,dtype
,latency
andextra_settings
accept 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.
See the device argument of
Stream
.If not overwritten, this is queried from PortAudio.
See also
- channels = (None, None)§
Default number of input/output channels.
See the channels argument of
Stream
.See also
- 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()
andplayrec()
support'float64'
(for convenience, data is merely converted from/to'float32'
) andRawInputStream
,RawOutputStream
andRawStream
support'int24'
(packed 24 bit format, which is not supported in NumPy!).
- 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
True
to disable default clipping of out of range samples.
- dither_off = False§
Disable dithering.
Set to
True
to disable default dithering.
- never_drop_input = False§
Set behavior for input overflow of full-duplex streams.
Set to
True
to 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. onlyStream
andRawStream
and 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
True
to 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 (InputStream
andRawInputStream
) 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).