danilobellini / audiolazy

Expressive Digital Signal Processing (DSP) package for Python
GNU General Public License v3.0
689 stars 74 forks source link

ALSA underrun above rate=22000 #14

Closed sethtroisi closed 2 years ago

sethtroisi commented 2 years ago

Hey Danilo love the library. Hoping to make use of the lazy eval to do some DSP for a visual-audio art piece I'm working on.

When I try to run the examples I get static noise and stdout contains errors about ALSA lib pcm.c:8526:(snd_pcm_recover) underrun occurred

I eventually found that lowering rate on AudioIo.play avoids these errors.

sound = WavStream("static/mono.wav")
print(sound.channels, sound.rate)

with AudioIO(True, api="alsa") as player: 
    player.play(sound, rate= int(sound.rate // 3))  # Plays correctly

with AudioIO(True) as player:
    player.play(sound, rate= int(sound.rate // 2))

The first play is slowed down 3x but otherwise plays correctly. During the second play an error is printed about a hundred times to the console and the sound is just strongly static (with a little of the correct signal mixed in) for ~1 second (the clip is 22 seconds long).

Any idea why this might would be happening?

sethtroisi commented 2 years ago

This problem seem to be upstream in pyaudio, sorry to bother you. Hope I get pyaudio fixed and can use your lovely library.