elif data == 2: sph.play_noise() elif data == 3: sph.start_camera_recording() # sph.OSC_CLIENT.send_message("/e", data) # ============================================================================= # CONNECT TO BPOD # ============================================================================= bpod = Bpod() # Loop handler function is used to flush events for the online plotting bpod.loop_handler = bpod_loop_handler # Soft code handler function can run arbitrary code from within state machine bpod.softcode_handler_function = softcode_handler # Rotary Encoder State Machine handler rotary_encoder = [x for x in bpod.modules if x.name == 'RotaryEncoder1'][0] # ROTARY ENCODER SEVENTS # Set RE position to zero 'Z' + eneable all RE thresholds 'E' # re_reset = rotary_encoder.create_resetpositions_trigger() re_reset = 1 bpod.load_serial_message( rotary_encoder, re_reset, [ RotaryEncoder.COM_SETZEROPOS, # ord('Z') RotaryEncoder.COM_ENABLE_ALLTHRESHOLDS ]) # ord('E') # Stop the stim re_stop_stim = re_reset + 1
start = timeit.default_timer() if not camOK: cam.record() camOK = True elif data == 66: soundStream.stopSound() print(':::::::::Time to stop:::::::::', timeit.default_timer() - start) # ------------------------------------------------------------------ START_APP = timeit.default_timer() my_bpod = Bpod() my_bpod.softcode_handler_function = my_softcode_handler nTrials = 2 for i in range(nTrials): # Main loop print('Trial: ', i + 1) sma = StateMachine(my_bpod) soundStream.load(s1) # load the sound <----------------- sma.add_state(state_name='WaitForPort2Poke', state_timer=1, state_change_conditions={Bpod.Events.Tup: 'PlaySound'}, output_actions=[(Bpod.OutputChannels.PWM1, 255)]) sma.add_state(state_name='PlaySound', state_timer=0.5,