Working on bug in leaving

This commit is contained in:
Logan Cusano
2022-02-27 18:44:02 -05:00
parent 706f4a31df
commit 7682d8c72c
2 changed files with 11 additions and 5 deletions

View File

@@ -21,17 +21,23 @@ class PCMStream:
self.stream = sd.RawInputStream(device=_device_id)
# Stops and destroys the current stream
def clean_up(self):
if not self.stream.closed:
self.stream.stop(ignore_errors=True)
self.stream.close(ignore_errors=True)
# Stops the current running stream but does not destroy it
def pause(self):
self.stream.stop(ignore_errors=True)
if self.stream.active:
self.stream.stop(ignore_errors=True)
# Plays the stream
def play(self):
self.stream.start()
if not self.stream.active:
self.stream.start()
# call back read function for the stream
def read(self, num_bytes):
if self.stream.active:
# frame is 4 bytes