flip_bit = 1 #this is just to flip the sign of width change #------------------------------- # SETUP SOUND STIMS freq_factor = 2*np.pi*np.linspace(0,0.5,22050) freqL = 440 freqR = 440 soundL = np.sin(freq_factor*freqL) soundR = np.sin(freq_factor*freqR) s_out = Sound(np.array([soundL,soundR]).T,secs=10) # #------------------------------- t=1 while not kb_events: s_out.stop() if t==1: s_out.play() t=0 # soundL = np.sin(freq_factor*(freqL+10)) # soundR = np.sin(freq_factor*freqR) # s_out.setSound = np.array([soundL,soundR]).T # Get the current mouse position # posDelta is the change in position * since the last call * position, posDelta = mouse.getPositionAndDelta() mouse_dX, mouse_dY = posDelta # Get the current state of each of the Mouse Buttons left_button, middle_button, right_button = mouse.getCurrentButtonStates()
# preparing time for next window flip, to precisely co-ordinate window flip and beep nextflip = window.getFutureFlipTime(clock='ptb') beep.play(when=nextflip) # display stimulus gendecisionint(subjects, trials.thisTrial['condition']) window.flip() # we decided to reset the clock after flipping (redrawing) the window responsetime.reset() # fetch button press response = fetchbuttonpress(subjects, responsetime) print(response) # need to explicity call stop() to go back to the beginning of the track # we reset after collecting a response, otherwise the beep is stopped too early beep.stop() # display inter trial interval genintertrial(subjects) window.flip() # inter trial interval is 2s core.wait(2) # state switch updatestate() # save data trials.addData('response', response) exphandler.nextEntry() # decide between continuing with next block, take a break genendscreen()