I am trying to use sounddevice OutputStream within my PyQt application to play sound.
I want something like
import sounddevice as sd
def callback(...):
#stuff that works with a "with" statement
class MyApp(QtWidgets.QMainWindow):
def __init__(self):
#stuff and buttons
def startSound(self):
#called by a button
self.streamInstance = sd.OutputStream(settings)
def stopSound(self):
#called by another button
self.streamInstance.close()
Now this does not work but if I set to have:
with sd.OutputStream(settings):
#a loop
It works but I then cannot stop the stream from another function and the app stops running.
If anyone has an idea for a workaround or a fix, it would be greatly appreciated