-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsendmarker.m
More file actions
58 lines (55 loc) · 1.7 KB
/
sendmarker.m
File metadata and controls
58 lines (55 loc) · 1.7 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% add library path to search path
mfilepath=fileparts(which(mfilename));
addpath(fullfile(mfilepath,'./liblsl-Matlab'));
%disp(mfilepath);
% todo: check the below lines code called many times
if ismac
disp('mac detect');
disp(fullfile(mfilepath,'./bin/mac'));
% Code to run on Mac platform
addpath(fullfile(mfilepath,'./bin/mac'));
elseif isunix
% Code to run on Linux platform
addpath(fullfile(mfilepath,'./bin/linux'));
elseif ispc
% Code to run on Windows platform
addpath(fullfile(mfilepath,'./bin/win64'));
else
disp('Platform not supported')
end
%% instantiate the library
disp('Loading library...');
try
lib = lsl_loadlib(env_translatepath('dependencies:/liblsl-Matlab/bin'));
catch
lib = lsl_loadlib();
end
% make a new stream outlet
disp('Creating a new streaminfo...');
info = lsl_streaminfo(lib,'MatlabMarker','Markers', 1, 100,'cf_double64','matlab1234');
chns = info.desc().append_child('channels');
for label = {'MarkerValue'}
ch = chns.append_child('channel');
ch.append_child_value('label',label{1});
ch.append_child_value('unit','interge');
ch.append_child_value('type','Marker');
end
info.desc().append_child_value('manufacturer','Matlab');
disp('Opening an outlet...');
disp(info)
outlet = lsl_outlet(info);
% send data into the outlet, sample by sample
disp('Now send marker data...');
while true
t = datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss Z');
%disp(t);
epocTimeNow = posixtime(t); % convert to epoch time
%sprintf('%16.4f',epocTimeNow);
markerValue = randi(100);
data = [markerValue];
%disp(data);
disp('Send marker has value: ');
disp(markerValue);
outlet.push_sample(data);
pause(1);
end