JulietD:
However, now that I can see the general conceptual way to get the 2 loops to play simultaneously without waiting for each other to finish, as long as I can stop the delay caused by the clicking, fitting everything else in should (hopefully) not be too difficult!
Great! Thanks for the detailed description - I think it should all work OK.
JulietD:
The only issue I am having is that when it registers a mouseclick it slows the whole program down and pauses before playing the next tone, sometimes to the point that it freezes everything and gives a ‘not responding’ message for a couple of seconds. That might just be to do with the speed of my machine though. I should be able to test on a different computer on Monday.
It prints the “Mouse click registered” repeatedly until something else happens, so this must be registering the fact that the mouse was clicked in every loop before the next tone is played, rather than registering a click once and starting the next loop with a blank slate. This is happening even with a click reset added at the beginning of the loop. If I could change this I’m sure that would sort out the speed issue, I will see if I can do this and let you know.
I would also need to amend it so it could register whether a click was single or double, and so it associated the tone and the click (as in, have a record of which clicks were made in response to which tones) so it could mark the click responses as correct or incorrect.
I suspect the slowness issue is caused by lots and lots of print
statements, because it was printing a new statement every time it registered that the mouse button was in a down state (not just the action of pressing it). You might be able to resolve both it and the double-click issue by putting some code like this outside of the trial loop:
m_known_down = any(mouse.getPressed())
last_click = -1.0
double_click_range = 0.3
and then replace the mouse handling code with something like:
if any(mouse.getPressed()):
if not m_known_down:
m_known_down = True
m_click_time = clock.getTime()
if (m_click_time - last_click) < double_click_range:
print "Double click registered"
else:
print "Mouse click registered"
last_click = m_click_time
else:
m_known_down = False