python-sounddevice
python-sounddevice copied to clipboard
Enable platform-specific features from PortAudio
See https://github.com/bastibe/PySoundCard/issues/16.
One possible feature would be the "exclusive mode" of WASAPI, see http://stackoverflow.com/questions/31306010/how-to-enable-wasapi-exclusive-mode-in-pyaudio
PaAlsa_EnableRealtimeScheduling
might be interesting for ALSA: http://portaudio.com/docs/v19-doxydocs-dev/pa__linux__alsa_8h.html#accc41e7fd89dc0a6163d54a4f25fb242
It would be interesting to be able to select arbitrary channels for input and output. On Windows this is needed with ASIO. If you currently want to send data to output channels 9 and 10, you have to send data to all channels below 11. This means that sharing the soundcard with other applications becomes impossible.
The hostapis WDM-KS, MME, Directsound, normally only present 2 channels so it is not a problem there.
@raecke I created an experimental implementation in #34. Can you please check if it works for you and leave a comment there?
There is also PaAlsa_SetNumPeriods
, which is by default set to 4
, which seems random:
By default the number of periods is 4, this is the lowest number of periods that works well on the author's soundcard.
http://portaudio.com/docs/v19-doxydocs-dev/pa__linux__alsa_8h.html#a76f60d6f1ba6a298c038a9f3a6dccc53
It looks like this has to be called before opening a stream.
OK, I'm trying to make an exhaustive list of the current host-API-specific settings, let's see if that works:
hostApiSpecificStreamInfo
to be specified separately for the input and output device when creating a stream:
-
PaAlsaStreamInfo::deviceString, only works if device index is set to
paUseHostApiSpecificDeviceSpecification
(a.k.a.-2
) -
PaAsioStreamInfo::channelSelectors, needs
PaAsioStreamInfo::flags
to containpaAsioUseChannelSelectors
-
PaMacCoreStreamInfo::channelMap, can be set with
PaMacCore_SetupChannelMap
-
PaMacCoreStreamInfo::flags,
paMacCoreChangeDeviceParameters
,paMacCoreFailIfConversionRequired
,paMacCoreConversionQuality*
, ... -
PaWinDirectSoundStreamInfo::channelMask, needs
paWinDirectSoundUseChannelMask
flag -
PaWinDirectSoundStreamInfo::framesPerBuffer, needs
paWinDirectSoundUseLowLevelLatencyParameters
flag -
PaWasapiStreamInfo::channelMask, needs
paWinWasapiUseChannelMask
flag -
PaWasapiStreamInfo::flags,
paWinWasapiExclusive
,paWinWasapiPolling
-
PaWasapiStreamInfo::hostProcessorOutput, needs
paWinWasapiRedirectHostProcessor
flag, separate callback instead of "normal" audio callback? - PaWasapiStreamInfo::hostProcessorInput
-
PaWasapiStreamInfo::threadPriority, needs
paWinWasapiThreadPriority
flag, cannot be different for input and output! - PaWasapiStreamInfo::streamCategory
- PaWasapiStreamInfo::streamOption
- PaWDMKSSpecificStreamInfo::input ???
- PaWDMKSSpecificStreamInfo::output ???
- PaWinWDMKSInfo::channelMask ???
- PaWinWDMKSInfo::flags ???
- PaWinMmeStreamInfo::framesPerBuffer
- PaWinMmeStreamInfo::bufferCount
-
PaWinMmeStreamInfo::devices, needs
paWinMmeUseMultipleDevices
flag -
PaWinMmeStreamInfo::channelMask, needs
paWinMmeUseChannelMask
flag -
PaWinMmeStreamInfo::flags:
paWinMmeDontThrottleOverloadedProcessingThread
,paWinMmeWaveFormatDolbyAc3Spdif
,paWinMmeWaveFormatWmaSpdif
Functions that are called with a stream pointer:
- PaAlsa_EnableRealtimeScheduling
- PaAlsa_GetStreamInputCard
- PaAlsa_GetStreamOutputCard
- PaAsio_SetStreamSampleRate
- PaMacCore_GetStreamInputDevice
- PaMacCore_GetStreamOutputDevice
-
PaWasapi_GetFramesPerHostBuffer, for use with
PaWasapiHostProcessorCallback
- PaWinMME_GetStreamInputHandle
- PaWinMME_GetStreamOutputHandle
Global functions:
- PaAlsa_SetNumPeriods
- PaAlsa_SetRetriesBusy
- PaAlsa_SetLibraryPathName Does this work with the way we are loading the library?
- PaAsio_GetAvailableBufferSizes, takes the device index
- PaAsio_ShowControlPanel, takes the device index and "the calling application's main window handle", does this work in Python?
- PaAsio_GetInputChannelName, takes the device index
- PaAsio_GetOutputChannelName, takes the device index
-
PaJack_SetClientName, must be called before
Pa_Initialize
! - PaJack_GetClientName
- PaMacCore_GetChannelName, takes device and channel index
- PaMacCore_GetBufferSizeRange, takes device index
- PaWasapi_GetDeviceDefaultFormat, takes device index
- PaWasapi_GetDeviceRole, takes device index
- PaWasapi_ThreadPriorityBoost, for blocking interface only
- PaWasapi_ThreadPriorityRevert
- PaWasapi_GetJackCount, takes device index
- PaWasapi_GetJackDescription, takes device index
-
PaWasapi_IsLoopback
(will be in PortAudio 19.8), takes device index
Would love to be able to fetch PaAsio_GetInputChannelName
and PaAsio_GetOutputChannelName
though it looks like there hasn't been much movement on this feature?
@philipmountifield Can you please create a new issue with your request, including a suggestion how the new API should look like?