-
Notifications
You must be signed in to change notification settings - Fork 133
Tutorial 4 b: Process Data streams in MATLAB
mgbleichner edited this page Sep 11, 2018
·
2 revisions
This is the second part of Tutorial 4. You should do Tutorial 4 a: Receive data streams in MATLAB before you start with this.
In this tutorial, you will learn how to directly process an incoming data stream after some marker event.
For this tutorial you need
- A Windows Computer with a microphone (For this tutorial you should reduce the sampling frequency of your audio interface. )
- MATLAB
- The LSL AudioCaptureWin App (for streaming the microphone input)
- The LSL Keyboard App (for streaming key presses and releases)
- The LSL Mouse App (for streaming mouse button presses and releases and mouse positions) You could use the LabRecorder for saving all data streams for an offline analysis of the data.
The LSL App can be downloaded from the ftp as .zip files.
% instantiate the library
disp('Loading the library...');
lib = lsl_loadlib();
% resolve a data stream...
disp('Resolving a Data stream...');
result = {};
while isempty(result)
result = lsl_resolve_byprop(lib,'name','AudioCaptureWin'); end
% create a new data inlet
disp('Opening a data inlet...');
data_inlet = lsl_inlet(result{1});
% resolve a marker stream...
disp('Resolving a marker stream...');
result = {};
while isempty(result)
result = lsl_resolve_byprop(lib,'name','MouseButtons'); end
% create a new marker inlet
disp('Opening a marker inlet...');
marker_inlet = lsl_inlet(result{1});
disp('Now receiving data...');
while true
% get data from the inlet
[pos,ts] = inlet.pull_sample();
% and display it
fprintf('%.2f\t',pos);
fprintf('%.5f\n',ts);
end