|
1 | | -function [onset, duration] = doAudMot(cfg, thisEvent) |
| 1 | +function [onset, duration] = doAuditoryMotion(cfg, thisEvent) |
2 | 2 |
|
3 | 3 | % Play the auditopry stimulation of moving in 4 directions or static noise bursts |
4 | 4 | % |
|
11 | 11 | % - thisEvent: structure that the parameters regarding the event to present |
12 | 12 | % |
13 | 13 | % Output: |
14 | | - % - |
| 14 | + % - onset in machine time |
| 15 | + % - duration in seconds |
15 | 16 | % |
16 | 17 |
|
17 | 18 | %% Get parameters |
18 | 19 |
|
19 | | - sound = []; |
20 | | - |
21 | 20 | direction = thisEvent.direction(1); |
22 | 21 | isTarget = thisEvent.target(1); |
23 | 22 | targetDuration = cfg.target.duration; |
24 | 23 |
|
25 | 24 | soundData = cfg.soundData; |
26 | 25 |
|
27 | | - % if isTarget == 0 |
| 26 | + switch direction |
| 27 | + case -1 |
| 28 | + fieldName = 'S'; |
| 29 | + case 90 |
| 30 | + fieldName = 'U'; |
| 31 | + case 270 |
| 32 | + fieldName = 'D'; |
| 33 | + case 0 |
| 34 | + fieldName = 'R'; |
| 35 | + case 180 |
| 36 | + fieldName = 'L'; |
| 37 | + end |
28 | 38 |
|
29 | | - if direction == -1 |
30 | | - sound = soundData.S; |
31 | | - elseif direction == 90 |
32 | | - sound = soundData.U; |
33 | | - elseif direction == 270 |
34 | | - sound = soundData.D; |
35 | | - elseif direction == 0 |
36 | | - sound = soundData.R; |
37 | | - elseif direction == 180 |
38 | | - sound = soundData.L; |
| 39 | + if isTarget == 1 |
| 40 | + fieldName = [fieldName '_T']; |
39 | 41 | end |
40 | 42 |
|
41 | | - % elseif isTarget == 1 |
42 | | - % |
43 | | - % if direction == -1 |
44 | | - % sound = soundData.S_T; |
45 | | - % elseif direction == 90 |
46 | | - % sound = soundData.U_T; |
47 | | - % elseif direction == 270 |
48 | | - % sound = soundData.D_T; |
49 | | - % elseif direction == 0 |
50 | | - % sound = soundData.R_T; |
51 | | - % elseif direction == 180 |
52 | | - % sound = soundData.L_T; |
53 | | - % end |
54 | | - % |
55 | | - % end |
| 43 | + sound = soundData.(fieldName); |
56 | 44 |
|
57 | 45 | % Start the sound presentation |
58 | 46 | PsychPortAudio('FillBuffer', cfg.audio.pahandle, sound); |
|
0 commit comments