spatialaudio/python-sounddevice

Update device list by reloading portaudio dll

HaujetZhao opened this issue · 1 comments

import sounddevice as sd

print(sd.query_device)

# some device info listed
# then plug some new device

sd._terminate()
sd._initialize()
print(sd.query_device)

# device info list unchanged

sd._terminate()
sd._ffi.dlclose(sd._lib)
sd._lib = sd._ffi.dlopen(sd._libname)
sd._initialize()
print(sd.query_device)

# device info list updated, it works fine


# is it possible to close the dll when sd._terminate()
# and reopen the dll when sd._initialize()
# so that the device_list can be updated by re initialize sounddevice
mgeier commented
# is it possible to close the dll when sd._terminate()
# and reopen the dll when sd._initialize()

Yes, I guess it would be possible, but the idea is that those two functions wrap the PortAudio functions Pa_Terminate() and Pa_Initialize(), respectively.

If additional functionality is desired, additional functions should be created.

But if the sequence of statements you mentioned is working for you, feel free to just use them in your code.


Related: #125, #343, #382.