bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
689 stars 70 forks source link

interruptible play() #59

Closed cyberic99 closed 5 years ago

cyberic99 commented 5 years ago

Hi

I'd like to be able to interrupt a play() at any time. I have a dirty hack to do it, but would you be interested in having this feature, @bastibe?

The idea is just to break the while loop, when a specific flag is set.

Thx

bastibe commented 5 years ago

Use a player with a short block length in a loop. Then you can interrupt it whenever you feel like it (at every block boundary).

cyberic99 commented 5 years ago

Ha yes you're right, all the needed functions were already there, tanks!

By the way, what is the use of this line?

https://github.com/bastibe/SoundCard/blob/e43f002a706056639239bf11f01eff290e1d4b0a/soundcard/pulseaudio.py#L659

bastibe commented 5 years ago

Good catch! That line seems to be unused! It's probably a remnant of an earlier version that I forgot to clean up. In fact, line 202, which declares this function, seems to be redundant as well.

Would you like to create a pull request that removes these lines?

cyberic99 commented 5 years ago

Here is the pull request:

https://github.com/bastibe/SoundCard/pull/60

bastibe commented 5 years ago

Thank you very much for your help!