Implement realtime signal processing in Python - how to capture audio continuously?
问题 I'm planning to implement a "DSP-like" signal processor in Python. It should capture small fragments of audio via ALSA, process them, then play them back via ALSA. To get things started, I wrote the following (very simple) code. import alsaaudio inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL) inp.setchannels(1) inp.setrate(96000) inp.setformat(alsaaudio.PCM_FORMAT_U32_LE) inp.setperiodsize(1920) outp = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL) outp