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
13 changes: 11 additions & 2 deletions sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@ def __init__(self, channel_map=None, change_device_parameters=False,

class WasapiSettings:

def __init__(self, exclusive=False, auto_convert=False):
def __init__(self, exclusive=False, auto_convert=False, explicit_sample_format=False):
"""WASAPI-specific input/output settings.

Objects of this class can be used as *extra_settings* argument
Expand All @@ -2470,6 +2470,13 @@ def __init__(self, exclusive=False, auto_convert=False):
system mixer sample rate. This only applies in *shared
mode* and has no effect when *exclusive* is set to ``True``.

explicit_sample_format : bool
Force explicit sample format and do not allow PortAudio to
select suitable working format. API will fail if provided
sample format is not supported by audio hardware in Exclusive
mode or system mixer in Shared mode. This is required for
accurate native format detection.

Examples
--------
Setting exclusive mode when calling `play()`:
Expand All @@ -2487,8 +2494,10 @@ def __init__(self, exclusive=False, auto_convert=False):
flags = 0x0
if exclusive:
flags |= _lib.paWinWasapiExclusive
elif auto_convert:
if auto_convert:
flags |= _lib.paWinWasapiAutoConvert
if explicit_sample_format:
flags |= _lib.paWinWasapiExplicitSampleFormat
self._streaminfo = _ffi.new('PaWasapiStreamInfo*', dict(
size=_ffi.sizeof('PaWasapiStreamInfo'),
hostApiType=_lib.paWASAPI,
Expand Down
1 change: 1 addition & 0 deletions sounddevice_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
paWinWasapiUseChannelMask = 4,
paWinWasapiPolling = 8,
paWinWasapiThreadPriority = 16,
paWinWasapiExplicitSampleFormat = 32,
paWinWasapiAutoConvert = 64
} PaWasapiFlags;

Expand Down
Loading