From 1a4d02827843cbc54584ca34d99b52bf5e2e2b0c Mon Sep 17 00:00:00 2001 From: Marc Schoenwiesner Date: Wed, 28 Aug 2024 23:22:54 +0200 Subject: [PATCH] amend .play docstring, add undocumented device argument --- slab/sound.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/slab/sound.py b/slab/sound.py index 219e2b2..d187e15 100644 --- a/slab/sound.py +++ b/slab/sound.py @@ -976,18 +976,22 @@ def record(duration=1.0, samplerate=None): out.name = 'recorded' return out - def play(self, blocking=True): + def play(self, blocking=True, device=None): """ Plays the sound through the default device. If the sounddevice module is installed it is used to play the sound. Otherwise the sound is saved as .wav to a temporary directory and is played via the `play_file` method. + + Arguments: + blocking (bool): wait while playing the sound if True, otherwise start playing + and continue program execution. """ if _in_notebook: display(Audio(self.data.T, rate=self.samplerate, autoplay=True)) if blocking: time.sleep(self.duration) # playing in Jupiter/Colab notebook is non_blocking, thus busy-wait for stim duration elif sounddevice is not False: - sounddevice.play(data=self.data, samplerate=self.samplerate, blocking=blocking) + sounddevice.play(data=self.data, samplerate=self.samplerate, blocking=blocking, device=device) else: filename = hashlib.sha256(self.data).hexdigest() + '.wav' # make unique name filename = _tmpdir / filename