|
54 | 54 | % |
55 | 55 | % end |
56 | 56 |
|
57 | | - thisFixation.fixation = cfg.fixation; |
58 | | - thisFixation.screen = cfg.screen; |
59 | | - drawFixation(thisFixation); |
60 | | - vbl = Screen('Flip', cfg.screen.win); |
61 | | - |
62 | 57 | % Start the sound presentation |
63 | 58 | PsychPortAudio('FillBuffer', cfg.audio.pahandle, sound); |
64 | 59 | PsychPortAudio('Start', cfg.audio.pahandle); |
65 | 60 | onset = GetSecs; |
66 | 61 |
|
67 | | - status = PsychPortAudio('GetStatus', cfg.audio.pahandle); |
| 62 | + % draw first fixation and get a first visual time stamp |
| 63 | + % ideally we would want to synch that first time stamp and the sound start |
| 64 | + thisFixation.fixation = cfg.fixation; |
| 65 | + thisFixation.screen = cfg.screen; |
| 66 | + if isTarget == 1 |
| 67 | + thisFixation.fixation.color = cfg.fixation.colorTarget; |
| 68 | + end |
| 69 | + drawFixation(thisFixation); |
| 70 | + vbl = Screen('Flip', cfg.screen.win); |
68 | 71 |
|
69 | | - while status.Active |
| 72 | + while 1 |
70 | 73 |
|
| 74 | + % set default cross cross color but update if target time is not |
| 75 | + % finished |
71 | 76 | thisFixation.fixation.color = cfg.fixation.color; |
72 | | - |
73 | 77 | if GetSecs < (onset + targetDuration) && isTarget == 1 |
74 | | - thisFixation.fixation.color = cfg.fixation.colorTarget |
| 78 | + thisFixation.fixation.color = cfg.fixation.colorTarget; |
75 | 79 | end |
76 | 80 |
|
77 | 81 | drawFixation(thisFixation); |
78 | | - |
79 | | - Screen('Flip', cfg.screen.win); |
80 | 82 | vbl = Screen('Flip', cfg.screen.win, vbl + cfg.screen.ifi); |
81 | 83 |
|
82 | 84 | status = PsychPortAudio('GetStatus', cfg.audio.pahandle); |
| 85 | + if ~status.Active |
| 86 | + break; |
| 87 | + end |
83 | 88 |
|
84 | 89 | end |
85 | 90 |
|
86 | 91 | % Get the end time |
87 | | - waitForEndOfPlayback = 1; |
| 92 | + waitForEndOfPlayback = 1; % hard coding that will need to be moved out |
88 | 93 | [onset, ~, ~, estStopTime] = PsychPortAudio('Stop', cfg.audio.pahandle, ... |
89 | 94 | waitForEndOfPlayback); |
90 | 95 |
|
|
0 commit comments