From 7aa6f51ef062d1f192785f2fcea06e76daa68795 Mon Sep 17 00:00:00 2001 From: dev-jam Date: Thu, 2 Jun 2022 16:11:43 +0200 Subject: [PATCH] pyaudio fix --- .../audio_low_latency_play/audio_low_latency_play.py | 8 -------- .../audio_low_latency_play_init.py | 1 + .../audio_low_latency_play_start.py | 8 -------- .../audio_low_latency_record/audio_low_latency_record.py | 4 ---- .../audio_low_latency_record_init.py | 1 + .../audio_low_latency_record_start.py | 4 ---- 6 files changed, 2 insertions(+), 24 deletions(-) diff --git a/opensesame_plugins/audio_low_latency_play/audio_low_latency_play.py b/opensesame_plugins/audio_low_latency_play/audio_low_latency_play.py index 75fbeba..91af37d 100644 --- a/opensesame_plugins/audio_low_latency_play/audio_low_latency_play.py +++ b/opensesame_plugins/audio_low_latency_play/audio_low_latency_play.py @@ -241,8 +241,6 @@ def play_file(self, stream, wav_file, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.start() - elif self.module == self.experiment.pyaudio_module_name: - stream.start_stream() start_time = self.set_stimulus_onset() @@ -279,8 +277,6 @@ def play_file(self, stream, wav_file, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.stop() - elif self.module == self.experiment.pyaudio_module_name: - stream.stop_stream() self.set_stimulus_offset() @@ -299,8 +295,6 @@ def play_data(self, stream, wav_data, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.start() - elif self.module == self.experiment.pyaudio_module_name: - stream.start_stream() start_time = self.set_stimulus_onset() @@ -334,8 +328,6 @@ def play_data(self, stream, wav_data, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.stop() - elif self.module == self.experiment.pyaudio_module_name: - stream.stop_stream() self.set_stimulus_offset() diff --git a/opensesame_plugins/audio_low_latency_play_init/audio_low_latency_play_init.py b/opensesame_plugins/audio_low_latency_play_init/audio_low_latency_play_init.py index f846dad..a24e274 100644 --- a/opensesame_plugins/audio_low_latency_play_init/audio_low_latency_play_init.py +++ b/opensesame_plugins/audio_low_latency_play_init/audio_low_latency_play_init.py @@ -394,6 +394,7 @@ def close(self): self.show_message(u"Closing audio device") self.device.close() if self.module == self.pyaudio_module_name: + self.device.stop_stream() self.device.close() self.device_init.terminate() self.device = None diff --git a/opensesame_plugins/audio_low_latency_play_start/audio_low_latency_play_start.py b/opensesame_plugins/audio_low_latency_play_start/audio_low_latency_play_start.py index 89230b7..ea700d6 100644 --- a/opensesame_plugins/audio_low_latency_play_start/audio_low_latency_play_start.py +++ b/opensesame_plugins/audio_low_latency_play_start/audio_low_latency_play_start.py @@ -253,8 +253,6 @@ def play_file(self, stream, wav_file, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.start() - elif self.module == self.experiment.pyaudio_module_name: - stream.start_stream() start_time = self.set_stimulus_onset() @@ -285,8 +283,6 @@ def play_file(self, stream, wav_file, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.stop() - elif self.module == self.experiment.pyaudio_module_name: - stream.stop_stream() self.set_stimulus_offset() @@ -308,8 +304,6 @@ def play_data(self, stream, wav_data, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.start() - elif self.module == self.experiment.pyaudio_module_name: - stream.start_stream() start_time = self.set_stimulus_onset() @@ -337,8 +331,6 @@ def play_data(self, stream, wav_data, chunk, delay): if self.module == self.experiment.sounddevice_module_name: stream.stop() - elif self.module == self.experiment.pyaudio_module_name: - stream.stop_stream() self.set_stimulus_offset() diff --git a/opensesame_plugins/audio_low_latency_record/audio_low_latency_record.py b/opensesame_plugins/audio_low_latency_record/audio_low_latency_record.py index ca664b0..8f3a51d 100644 --- a/opensesame_plugins/audio_low_latency_record/audio_low_latency_record.py +++ b/opensesame_plugins/audio_low_latency_record/audio_low_latency_record.py @@ -233,8 +233,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop): if self.module == self.experiment.sounddevice_module_name: stream.start() - elif self.module == self.experiment.pyaudio_module_name: - stream.start_stream() start_time = self.set_stimulus_onset() @@ -271,8 +269,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop): if self.module == self.experiment.sounddevice_module_name: stream.stop() - elif self.module == self.experiment.pyaudio_module_name: - stream.stop_stream() wav_file.close() diff --git a/opensesame_plugins/audio_low_latency_record_init/audio_low_latency_record_init.py b/opensesame_plugins/audio_low_latency_record_init/audio_low_latency_record_init.py index 15e102d..6f13e1d 100644 --- a/opensesame_plugins/audio_low_latency_record_init/audio_low_latency_record_init.py +++ b/opensesame_plugins/audio_low_latency_record_init/audio_low_latency_record_init.py @@ -393,6 +393,7 @@ def close(self): self.show_message(u"Closing audio device") self.device.close() if self.module == self.pyaudio_module_name: + self.device.stop_stream() self.device.close() self.device_init.terminate() self.device = None diff --git a/opensesame_plugins/audio_low_latency_record_start/audio_low_latency_record_start.py b/opensesame_plugins/audio_low_latency_record_start/audio_low_latency_record_start.py index 888ce7c..4efe891 100644 --- a/opensesame_plugins/audio_low_latency_record_start/audio_low_latency_record_start.py +++ b/opensesame_plugins/audio_low_latency_record_start/audio_low_latency_record_start.py @@ -241,8 +241,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop): if self.module == self.experiment.sounddevice_module_name: stream.start() - elif self.module == self.experiment.pyaudio_module_name: - stream.start_stream() start_time = self.set_stimulus_onset() @@ -279,8 +277,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop): if self.module == self.experiment.sounddevice_module_name: stream.stop() - elif self.module == self.experiment.pyaudio_module_name: - stream.stop_stream() wav_file.close()