コード例 #1
0
volfactor = 0.05
key = None
while not key == 'space':
	# get new key
	key, presstime = kb.get_key(timeout=20)
	# new volume
	volume += volfactor
	# correct volume
	if volume < 0:
		volume = 0
		volfactor *= -1
	elif volume > 1:
		volume = 1
		volfactor *= -1
	# apply volume
	snd.set_volume(volume)
snd.stop()


# # # # #
# test timing module

scr.clear()
scr.draw_text("We're now going to test the time module. Press Space to start!")
disp.fill(scr)
t1 = disp.show()
log.write(["Time", t1])
kb.get_key()

#time.get_time()
scr.clear()
コード例 #2
0
# Create a new Display instance.
disp = Display()

# Create a new Keyboard instance.
kb = Keyboard()

# Create a new Logfile instance.
log = Logfile()
log.write(["trialnr", "trial_type", "stimulus", \
    "fix_onset", "stim_onset", "response", "RT", \
    "correct"])

# Create a BAD sound.
bad_sound = Sound(osc="whitenoise", length=200)
bad_sound.set_volume(1)
good_sound = Sound(osc="sine", freq=440, length=200)
good_sound.set_volume(0.5)

# Create a new Screen instance.
scr = Screen()
scr.draw_text("Welcome!", fontsize=100, \
    colour=(255,100,100))

# Pass the screen to the display.
disp.fill(scr)
disp.show()
timer.pause(3000)

# Create a list of all trials.
trials = []