简体   繁体   中英

Python module sounddevice intermittently doesn't work (clicks) on OSX and Linux

While working on a morse code play program, I'm finding sounddevice 0.3.7 will work intermittently, one time playing perfectly and then the next just making a bunch of clicking sounds.

I'm playing fairly short segments (a second up to several seconds) using this method:

sd.default.samplrate = 8000.0 # tried other sample rates as well
wav_wave = np.array(self.gain * w, dtype=np.int16)
sd.play(wav_wave, blocking=True)

Where w is an np.array with samples at the correct sample rate and are mostly dits and dahs of a tone. When working, it sounds great, when broken it sounds like a bunch of clicking.

I'm not sure why this is happening.

Well, I found out that upgrading from Ubuntu 16.04 to 17.04 that everything started working. Not that this is the correct solution, but I think it is pointing to some bug in ALSA that my code exposed as easy as it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM