-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTrial.m
29 lines (27 loc) · 940 Bytes
/
runTrial.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function [t,y,visStim] = runTrial(inputChannel,outputChannelLeft,outputChannelRight,duration,Fs,trialType,auralStim)
%command function that sets up daq and buffers data for each trial
%author: sstucker 11/28/18
global t;
global y;
global visStim;
global bufferNo;
%--------------------------------------------------------------------------
%daq housekeeping and setup
daq.reset;
s = daq.createSession('ni');
s.DurationInSeconds = duration;
s.Rate = Fs;
s.IsContinuous = false;
input = addAnalogInputChannel(s,'Dev1',inputChannel,'Voltage');
outputR = addAnalogOutputChannel(s,'Dev1',outputChannelRight,'Voltage');
outputL = addAnalogOutputChannel(s,'Dev1',outputChannelLeft,'Voltage');
queueOutputData(s,auralStim);
lh = addlistener(s,'DataAvailable',trialType);
%--------------------------------------------------------------------------
%containers for global buffers
y = [];
t = [];
visStim = [];
bufferNo = 0;
startForeground(s);
end