Class liblsl
Namespace: LSL4Unity
Assembly: cs.temp.dll.dll
Syntax
public class liblsl
Fields
DEDUCED_TIMESTAMP
Constant to indicate that a sample has the next successive time stamp.
This is an optional optimization to transmit less data per sample. The stamp is then deduced from the preceding one according to the stream's sampling rate (in the case of an irregular rate, the same time stamp as before will is assumed).
Declaration
public const double DEDUCED_TIMESTAMP = -1
Field Value
Type | Description |
---|---|
Double | Indicate that a sample has the next successive time stamp. |
FOREVER
A very large time duration (> 1 year) for timeout values.
Declaration
public const double FOREVER = 32000000
Field Value
Type | Description |
---|---|
Double | A very large time duration (> 1 year). |
Remarks
Note that significantly larger numbers can cause the timeout to be invalid on some operating systems (e.g., 32-bit UNIX).
IRREGULAR_RATE
Constant to indicate that a stream has variable sampling rate.
Declaration
public const double IRREGULAR_RATE = 0
Field Value
Type | Description |
---|---|
Double | Indicate that a stream has variable sampling rate. |
Methods
CheckError(Int32)
Check an error condition and throw an exception if appropriate.
Declaration
public static void CheckError(int code)
Parameters
Type | Name | Description |
---|---|---|
Int32 | code | The error code. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The operation failed due to a timeout. |
liblsl.LostException | The stream has been lost. |
ArgumentException | An argument was incorrectly specified (e.g., wrong format or wrong length). |
liblsl.InternalException | An internal internal error has occurred. |
Exception | An unknown error has occurred. |
LibraryVersion()
Version of the liblsl library.
The major version is LibraryVersion() / 100; The minor version is LibraryVersion() % 100;
Declaration
public static int LibraryVersion()
Returns
Type | Description |
---|---|
Int32 | The library version. |
LocalClock()
Obtain a local system time stamp in seconds.
The resolution is better than a millisecond.
This reading can be used to assign time stamps to samples as they are being acquired.
If the "age" of a sample is known at a particular time (e.g., from USB transmission delays),
it can be used as an offset to LocalClock() to obtain a better estimate of when a sample was actually captured.
See StreamOutlet::PushSample()
for a use case.
Declaration
public static double LocalClock()
Returns
Type | Description |
---|---|
Double | The local system time stamp in seconds. |
ProtocolVersion()
Version of the lsl protocol.
The major version is ProtocolVersion() / 100; The minor version is ProtocolVersion() % 100; Clients with different minor versions are protocol-compatible with each other while clients with different major versions will refuse to work together.
Declaration
public static int ProtocolVersion()
Returns
Type | Description |
---|---|
Int32 | The protocole version. |
ResolveStream(String, Int32, Double)
Resolve all streams that match a given predicate.
Advanced query that allows to impose more conditions on the retrieved streams; the given string is an XPath 1.0 predicate for the info node (omitting the surrounding []'s).
Declaration
public static liblsl.StreamInfo[] ResolveStream(string pred, int minimum = 1, double timeout = 32000000)
Parameters
Type | Name | Description |
---|---|---|
String | pred | The predicate string, e.g. " |
Int32 | minimum | Optionally return at least this number of streams. |
Double | timeout | Optionally a timeout of the operation, in seconds (default: no timeout). If the timeout expires, less than the desired number of streams (possibly none) will be returned. |
Returns
Type | Description |
---|---|
liblsl.StreamInfo[] | An array of matching stream info objects (excluding their meta-data), any of which can subsequently be used to open an inlet. |
Remarks
See Also : Wikipedia XPath 1.0.
ResolveStream(String, String, Int32, Double)
Resolve all streams with a specific value for a given property.
If the goal is to resolve a specific stream, this method is preferred over resolving all streams and then selecting the desired one.
Declaration
public static liblsl.StreamInfo[] ResolveStream(string prop, string value, int minimum = 1, double timeout = 32000000)
Parameters
Type | Name | Description |
---|---|---|
String | prop | The liblsl.StreamInfo property that should have a specific value (e.g., "name", "type", "SourceId", or "desc/manufaturer"). |
String | value | The string value that the property should have (e.g., "EEG" as the type property). |
Int32 | minimum | Optionally return at least this number of streams. |
Double | timeout | Optionally a timeout of the operation, in seconds (default: no timeout). If the timeout expires, less than the desired number of streams (possibly none) will be returned. |
Returns
Type | Description |
---|---|
liblsl.StreamInfo[] | An array of matching stream info objects (excluding their meta-data), any of which can subsequently be used to open an inlet. |
ResolveStreams(Double)
Resolve all streams on the network.
This function returns all currently available streams from any outlet on the network. The network is usually the subnet specified at the local router, but may also include a multicast group of machines (given that the network supports it), or list of hostnames. These details may optionally be customized by the experimenter in a configuration file (see Network Connectivity in the LSL wiki). This is the default mechanism used by the browsing programs and the recording program.
Declaration
public static liblsl.StreamInfo[] ResolveStreams(double waitTime = 1)
Parameters
Type | Name | Description |
---|---|---|
Double | waitTime | The waiting time for the operation, in seconds, to search for streams. |
Returns
Type | Description |
---|---|
liblsl.StreamInfo[] | An array of stream info objects (excluding their desc field), any of which can subsequently be used to open an inlet. The full info can be retrieve from the inlet. |
Remarks
If [waitTime] is too short (less than 0.5s) only a subset (or none) of the outlets that are present on the network may be returned.