Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Audio is separated (sounds like two tones)

Dear forum,

I am using a dual-task in which participants count tones (which appear sometimes) while they respond to visual stimuli with the keyboard.

I had the impression that i sometimes counted wrong because an audio was split which made me count it twice. Actually my code does not allow two tones to appear very quickly after another. However, this happened always when i counted one too much. I though that possible there is a short pause (of the system) because too much information is running which breaks the audio into two. Maybe caused be a very fast keypress?

This is my code:


def DualSeq():

var.Resp=None

while_breaker=[0,0]

while True:

if while_breaker==[1,1]:

break

my_mouse = Mouse(visible=True)

button, (x, y), time = my_mouse.get_click()

if (x,y) in discr1['target'] :

clock.sleep(100)

target_sound.play()

while_breaker[0]=1

elif (x,y) in discr1['distractor'] :

clock.sleep(100)

distractor_sound.play()

while_breaker[1]=1

Create_StimList()

leer.flush() #workaround on mac

leer.get_key()

start_position.show()

leer.get_key()

empty_box.show()

leer.flush() #workaround on mac

clock.sleep(495) #no response fixed timeout




i = 0

var.Correct=1

while i in range(120): #120 at the end

var.Resp_Num = i+1

target.flush()

start_time = SeqX[i].show()

var.Tone_time = Dual_stimlist[i].play() ####This is where the Tone appears!

key, time = target.get_key() #wait for key press

var.Stim_time = start_time

var.Resp_time = time

var.Resp= key

if var.Correct == 1:

var.Start_time = start_time

var.RT = time-var.Start_time

if SeqX[i] in [A,AB,AC,AD]:

var.Stim='A'

elif SeqX[i] in [B,BA,BC,BD]:

var.Stim='B'

elif SeqX[i] in [C,CA,CB,CD]:

var.Stim='C'

elif SeqX[i] in [D,DA,DB,DC]:

var.Stim='D'

if (SeqX[i] in [A,AB,AC,AD] and key in ['d','D']):

var.Correct=1

elif (SeqX[i] in [B,BA,BC,BD] and key in ['f','F']):

var.Correct=1

elif (SeqX[i] in [C,CA,CB,CD] and key in ['j','J']):

var.Correct=1

elif (SeqX[i] in [D,DA,DB,DC] and key in ['k','K']):

var.Correct=1

else:

var.Correct=0

i = i-1




if Dual_stimlist[i]==target_sound:

var.count_TCT +=1

var.StimTone = 'target'

elif Dual_stimlist[i]==distractor_sound:

var.count_distractor +=1

var.StimTone = 'distractor'

elif Dual_stimlist[i]==silence:

var.StimTone = 'silence'

elif Dual_stimlist[i] == silence_x:

var.StimTone = 'silence_x'

log.write_vars() #write in logfile

i = i+1 


Any help is appreciated,

Stephan

Comments

  • Solved it myself. The problem was on wrong responses the sound appeared again. A simple if Correct==1 before sound presentation solved it. 😉


    Sorry for the indentation bug, but the forum made it like this.

Sign In or Register to comment.