Skip to content

Commit

Permalink
fixed sounddevice
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-jam committed Jun 2, 2022
1 parent 7aa6f51 commit 74ec45f
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ def play_file(self, stream, wav_file, chunk, delay):
self.clock.sleep(delay)
self.show_message(u'Delay done')

if self.module == self.experiment.sounddevice_module_name:
stream.start()

start_time = self.set_stimulus_onset()

self.show_message(u'Starting audio playback')
Expand Down Expand Up @@ -275,9 +272,6 @@ def play_file(self, stream, wav_file, chunk, delay):
self.show_message(u'Audio stopped, duration exceeded')
break

if self.module == self.experiment.sounddevice_module_name:
stream.stop()

self.set_stimulus_offset()

wav_file.close()
Expand All @@ -293,9 +287,6 @@ def play_data(self, stream, wav_data, chunk, delay):
self.clock.sleep(delay)
self.show_message(u'Delay done')

if self.module == self.experiment.sounddevice_module_name:
stream.start()

start_time = self.set_stimulus_onset()

self.show_message(u'Starting audio playback')
Expand Down Expand Up @@ -326,9 +317,6 @@ def play_data(self, stream, wav_data, chunk, delay):
self.show_message(u'Audio stopped, duration exceeded')
break

if self.module == self.experiment.sounddevice_module_name:
stream.stop()

self.set_stimulus_offset()

self.show_message(u'Finished audio playback')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ def prepare(self):
raise osexception(
u'Could not start audio device', exception=e)

self.device.start()

elif self.module == self.experiment.oss4_module_name:
import ossaudiodev
self.device = ossaudiodev.open('w')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ def play_file(self, stream, wav_file, chunk, delay):
self.clock.sleep(delay)
self.show_message(u'Delay done')

if self.module == self.experiment.sounddevice_module_name:
stream.start()

start_time = self.set_stimulus_onset()

self.show_message(u'Starting audio playback')
Expand Down Expand Up @@ -281,9 +278,6 @@ def play_file(self, stream, wav_file, chunk, delay):
self.show_message(u'Audio playback stopped, duration exceeded')
break

if self.module == self.experiment.sounddevice_module_name:
stream.stop()

self.set_stimulus_offset()

wav_file.close()
Expand All @@ -302,9 +296,6 @@ def play_data(self, stream, wav_data, chunk, delay):
self.clock.sleep(delay)
self.show_message(u'Delay done')

if self.module == self.experiment.sounddevice_module_name:
stream.start()

start_time = self.set_stimulus_onset()

self.show_message(u'Starting audio playback')
Expand All @@ -329,9 +320,6 @@ def play_data(self, stream, wav_data, chunk, delay):
self.show_message(u'Audio stopped, duration exceeded')
break

if self.module == self.experiment.sounddevice_module_name:
stream.stop()

self.set_stimulus_offset()

self.show_message(u'Finished audio playback')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop):
self.clock.sleep(delay_start)
self.show_message(u'Delay done')

if self.module == self.experiment.sounddevice_module_name:
stream.start()

start_time = self.set_stimulus_onset()

while True:
Expand Down Expand Up @@ -267,9 +264,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop):
if self.ram_cache == u'yes':
wav_file.writeframes(b''.join(frames))

if self.module == self.experiment.sounddevice_module_name:
stream.stop()

wav_file.close()

self.show_message(u'Finished audio recording')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ def prepare(self):
raise osexception(
u'Could not start audio device', exception=e)

self.device.start()

elif self.module == self.experiment.oss4_module_name:
import ossaudiodev
self.device = ossaudiodev.open('r')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop):
self.clock.sleep(delay_start)
self.show_message(u'Delay done')

if self.module == self.experiment.sounddevice_module_name:
stream.start()

start_time = self.set_stimulus_onset()

while True:
Expand Down Expand Up @@ -275,9 +272,6 @@ def record(self, stream, wav_file, chunk, delay_start, delay_stop):
if self.ram_cache == u'yes':
wav_file.writeframes(b''.join(frames))

if self.module == self.experiment.sounddevice_module_name:
stream.stop()

wav_file.close()

self.show_message(u'Finished audio recording')
Expand Down

0 comments on commit 74ec45f

Please sign in to comment.