Esempio n. 1
0
 def test_soundfiles_generator_path_arg(self):
     """Test that soundfiles function constructs the correct path."""
     directory = r'.\sounds'
     soundfile_paths = [
         r'.\sounds\0.wav', r'.\sounds\1.wav', r'.\sounds\2.wav'
     ]
     when(glob).glob(r'.\sounds\*.wav').thenReturn(soundfile_paths)
     when(path).isdir(directory).thenReturn(True)
     gen = soundfiles(directory)
     self.assertEqual(next(gen), soundfile_paths[0])
Esempio n. 2
0
 def test_soundfiles_generator_path_arg(self):
     """Test that soundfiles function constructs the correct path."""
     directory = path.join('.', 'sounds')
     soundfile_paths = [
         path.join(directory, '0.wav'),
         path.join(directory, '1.wav'),
         path.join(directory, '2.wav')
     ]
     when(glob).glob(path.join(directory,
                               '*.wav')).thenReturn(soundfile_paths)
     when(path).isdir(directory).thenReturn(True)
     gen = soundfiles(directory)
     self.assertEqual(next(gen), soundfile_paths[0])
Esempio n. 3
0
    def test_soundfiles_generator(self):
        """Test that soundfiles function returns an cyclic generator."""

        directory = r'.\sounds'
        soundfile_paths = [
            r'.\sounds\0.wav', r'.\sounds\1.wav', r'.\sounds\2.wav'
        ]
        when(glob).glob(r'.\sounds\*.wav').thenReturn(soundfile_paths)
        when(path).isdir(directory).thenReturn(True)

        gen = soundfiles(directory)
        self.assertEqual(next(gen), soundfile_paths[0])
        self.assertEqual(next(gen), soundfile_paths[1])
        self.assertEqual(next(gen), soundfile_paths[2])
        self.assertEqual(next(gen), soundfile_paths[0])
        self.assertEqual(next(gen), soundfile_paths[1])
        for _ in range(10):
            self.assertTrue(next(gen) in soundfile_paths)
    def __init__(self, win, daq, parameters, file_save):
        super(RSVPAlertToneCalibrationTask, self).__init__()
        self._task = RSVPCalibrationTask(win, daq, parameters, file_save)

        # Delay between sound and letter presentation; default is 400 ms.
        # see: Testing the Efficiency and Independence of Attentional Networks
        # by Jin Fan, Bruce D. McCandliss, Tobias Sommer, Amir Raz, and
        # Michael I. Posner
        sound_delay = parameters.get('alert_sound_delay', 0.4)
        alerts = soundfiles(parameters['alert_sounds_path'])

        def play_sound_callback(_sti):
            sound_path = next(alerts)
            if "blank" in sound_path:
                return
            play_sound(sound_path,
                       sound_load_buffer_time=0,
                       sound_post_buffer_time=sound_delay)

        self._task.rsvp.first_stim_callback = play_sound_callback
Esempio n. 5
0
    def test_soundfiles_generator(self):
        """Test that soundfiles function returns an cyclic generator."""

        directory = path.join('.', 'sounds')
        soundfile_paths = [
            path.join(directory, '0.wav'),
            path.join(directory, '1.wav'),
            path.join(directory, '2.wav')
        ]
        when(glob).glob(path.join(directory,
                                  '*.wav')).thenReturn(soundfile_paths)
        when(path).isdir(directory).thenReturn(True)

        gen = soundfiles(directory)
        self.assertEqual(next(gen), soundfile_paths[0])
        self.assertEqual(next(gen), soundfile_paths[1])
        self.assertEqual(next(gen), soundfile_paths[2])
        self.assertEqual(next(gen), soundfile_paths[0])
        self.assertEqual(next(gen), soundfile_paths[1])
        for _ in range(10):
            self.assertTrue(next(gen) in soundfile_paths)