# Question!!!

**URL:** <https://psychtoolbox.discourse.group/t/question/694>\
**Category:** Uncategorized\
**Created:** [January 21, 2010, 9:36pm UTC](https://psychtoolbox.discourse.group/t/question/694 "2010-01-21T21:36:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [January 21, 2010, 9:36pm UTC](https://psychtoolbox.discourse.group/t/question/694/1 "2010-01-21T21:36:44Z")

</div>

Hi
My problem is that the I need the code to take care of two processes concurrently:
 
1. create beeps sounds in different frequency

2. saving subject responses (key board presses)  
  

So far i tried pulling the subject responses using kbcheck, 

but kbcheck response is longer then the gap between two beeps....
 
  

%%%%%%%%%

while (k \<= NumBeeps)

PsychPortAudio('Start', pahandle,1,0,0);

beepList = [beepList (GetSecs - start)];

CycleStart = GetSecs;

while ((GetSecs - CycleStart) \< Period)

[keyIsDown,secs,keyCode] = KbCheck;

while ((GetSecs - CycleStart) \< Period)

if keyIsDown

RT = [RT (GetSecs - start)];

while KbCheck && ((GetSecs - CycleStart) \< Period) ; end %%% this part lasts too long, and each key press recorder more then once....

end

end

end

k = k +1;

end

  

%%%%%%%%%%%

and even if ill maximize this, i don't thing it is the ideal way of running concordant processes.
 
I was thinking of using a callback/ interrupt mechanism .

  

but i cant find a way to create an on screen/ window object.

do you have any idea how can I do that?

  

Thank you so much
--   
Lilac Adato  
cell: 734-604-1248

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [January 22, 2010, 8:23am UTC](https://psychtoolbox.discourse.group/t/question/694/2 "2010-01-22T08:23:45Z")

</div>

I would suggest using   
beep1=MakeBeep(frequency1,exposureTime1);  
beep2=MakeBeep(frequency2,exposureTime2);  
  
Then you can insert   
Snd('Play',beep1)  
Snd('Play',beep2)  
  
anywhere you want in the code and then go on with other parts of the code without needing to run a loop.  
  
As for the recording more than once, the demos were very helpful. The code from them looks something along the lines of:  
 wait=1;  
 while wait  
 [keyIsDown, timeSecs, keyCode] = KbCheck;  
 if keyIsDown  
 result = keyCode(keyYouTest);  
 % Wait until all keys on keyboard are released:  
 while KbCheck; WaitSecs(0.1); end;  
 wait=0;  
 end  
 end  
which of course can be amended to include recording of response time as well.  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), lilac Adato \<lilacadato@...\> wrote:  
> \>  
> \> Hi  
> \> My problem is that the I need the code to take care of two processes  
> \> concurrently:  
> \> 1. create beeps sounds in different frequency  
> \> 2. saving subject responses (key board presses)  
> \>   
> \> So far i tried pulling the subject responses using kbcheck,  
> \> but kbcheck response is longer then the gap between two beeps....  
> \>   
> \> %%%%%%%%%  
> \>   
> \> while (k \<= NumBeeps)  
> \>   
> \> PsychPortAudio('Start', pahandle,1,0,0);  
> \>   
> \> beepList = [beepList (GetSecs - start)];  
> \>   
> \> CycleStart = GetSecs;  
> \>   
> \> while ((GetSecs - CycleStart) \< Period)  
> \>   
> \> [keyIsDown,secs,keyCode] = KbCheck;  
> \>   
> \>   
> \>   
> \> while ((GetSecs - CycleStart) \< Period)  
> \>   
> \> if keyIsDown  
> \>   
> \> RT = [RT (GetSecs - start)];  
> \>   
> \> while KbCheck && ((GetSecs - CycleStart) \< Period)  
> \> ; end %%% this part lasts too long, and each key press recorder more then  
> \> once....  
> \>   
> \> end  
> \>   
> \> end  
> \>   
> \> end  
> \>   
> \> k = k +1;  
> \>   
> \> end  
> \>   
> \>   
> \>   
> \> %%%%%%%%%%%  
> \> and even if ill maximize this, i don't thing it is the ideal way of running  
> \> concordant processes.  
> \> I was thinking of using a callback/ interrupt mechanism .  
> \>   
> \> but i cant find a way to create an on screen/ window object.  
> \> do you have any idea how can I do that?  
> \>   
> \> Thank you so much  
> \> --   
> \> Lilac Adato  
> \> cell: 734-604-1248  
> \>
