spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
980 stars 145 forks source link

glitch when record with MME/WDM host API #401

Open bactone opened 2 years ago

bactone commented 2 years ago

how to fix the glitch when record with MME/WDM host API, I compare the recorded signal using MME/WDM api and ASIO api, and the former gets lot of glitch, here bellow are two fig to show the difference: image image the code I use is:

# for MME record
my_recording = sd.playrec(pt_l, device=(3, 14), samplerate=fs, channels=1, blocking=True,
                          input_mapping=[1], output_mapping=[1], dtype='int32')
# for ASIO record
my_recording = sd.playrec(pt_l, device=(44, 44), samplerate=fs, channels=1, blocking=True,
                          input_mapping=[1], output_mapping=[1], dtype='int32')
mgeier commented 2 years ago

It looks like MME has a much coarser quantization, and it is indeed weird.

Do you really need the data type 'int32'? I think its support may not be the best for all host APIs. You should try 'float32' (which is the default), which might be better supported. Does this show the same effect?