Skip to content

Commit 26b927f

Browse files
rjtokenringdsammaruga
authored andcommitted
Added playback queue clear
1 parent 50bc0c4 commit 26b927f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/arduino/app_bricks/sound_generator/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,3 +549,9 @@ def play_abc(self, abc_string: str, volume: float = None, wait_completion: bool
549549
overall_duration += duration
550550
if wait_completion:
551551
time.sleep(overall_duration)
552+
553+
def clear_playback_queue(self):
554+
"""
555+
Clear the playback queue of the output device.
556+
"""
557+
self._output_device.clear_playback_queue()

src/arduino/app_bricks/sound_generator/examples/1_play_sequence.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
("A4", 1),
4747
]
4848

49+
4950
def user_lp():
5051
for note, duration in fur_elise:
5152
player.play(note, duration)
5253

54+
5355
App.run(user_loop=user_lp)

src/arduino/app_peripherals/speaker/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,3 +504,15 @@ def play(self, data: bytes | np.ndarray, block_on_queue: bool = False):
504504
except queue.Full:
505505
# logger.warning("Playback queue is full, dropping oldest data.")
506506
self._playing_queue.get_nowait()
507+
508+
def is_reproducing(self) -> bool:
509+
"""Check if the speaker is currently reproducing audio.
510+
511+
Returns:
512+
bool: True if reproducing, False otherwise.
513+
"""
514+
return self._is_reproducing.is_set()
515+
516+
def clear_playback_queue(self):
517+
"""Clear the playback queue."""
518+
self._clear_queue()

0 commit comments

Comments
 (0)