Latent
Latent

Reputation: 596

user input while playing sequence of sounds in a loop [matlab]

I'm writing a task for an experiment , I need a user to hear 400 sound pulse of pure tone and interval of 600 ms in between , but - in 10% of the intervals there are changes in the duration of the interval .

The user needs to push a key each time he recognize a change in the duration (the timing need to be saved in array ..) and if no change - the user won't touch the key.. (so it's 0 for no input , 1 for input)

for i = 1:pulse_number;
    wavplay(amplitude*beep,Sr,'async')
    pause(ISIarray(i)) % array of different interval duration
end

I can't find a way to run the loop and collect the user input (GetChar (psychotoolbox) inside the loop waiting for the user input to proceed)

Thank you !!

Upvotes: 0

Views: 616

Answers (1)

generl
generl

Reputation: 26

Use KbCheck or KbQueueCheck (if using a queue). You won't be able to use pause. Instead, use a while loop:

start_time = GetSecs;  
while GetSecs - start_time < interval_duration(i)  
    [press secs] = KbCheck;  
end  

Upvotes: 1

Related Questions