-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
3,764 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Binding/SharpLSL.Header.cs text eol=lf | ||
Source/SharpLSL/Interop/*.g.cs text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
// Port of https://github.com/sccn/liblsl/blob/master/testing/lslver.c | ||
using SharpLSL; | ||
using SharpLSL.Interop; | ||
|
||
namespace LSLVer | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine($"LSL version: {LSL.lsl_library_version()}"); | ||
Console.WriteLine(Lsl.GetLibraryInfo()); | ||
Console.WriteLine(Lsl.GetLocalClock()); | ||
Console.WriteLine($"LSL version: {LSL.GetLibraryVersion()}"); | ||
Console.WriteLine(LSL.GetLibraryInfo()); | ||
Console.WriteLine(LSL.GetLocalClock()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using SharpLSL.Interop; | ||
|
||
namespace SharpLSL | ||
{ | ||
/// <summary> | ||
/// Data format of a channel. | ||
/// </summary> | ||
/// <remarks> | ||
/// This enumeration specifies the format of data transmitted for each channel. | ||
/// Each transmitted sample contains an array of channels, and this enum describes | ||
/// the format of the data sent over the wire. | ||
/// </remarks> | ||
/// <seealso cref="StreamInfo.ChannelFormat"/> | ||
public enum ChannelFormat : int | ||
{ | ||
/// <summary> | ||
/// Represents a 32-bit floating-point format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is used for measurements that require up to 24-bit precision, | ||
/// such as physical quantities measured in microvolts. Integers within the | ||
/// range of -16,777,216 to 16,777,216 are represented accurately using this | ||
/// format. | ||
/// </remarks> | ||
Float = lsl_channel_format_t.cft_float32, | ||
|
||
/// <summary> | ||
/// Represents a 64-bit double-precision floating-point format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is used for representing numerical data with high precision | ||
/// for universal numeric data as long as permitted by network & disk budget. | ||
/// The largest representable integer is 53-bit. | ||
/// </remarks> | ||
Double = lsl_channel_format_t.cft_double64, | ||
|
||
/// <summary> | ||
/// Represents variable-length ASCII strings or data blobs. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is suitable for data that cannot be easily represented as | ||
/// numeric values, such as video frames, or complex event descriptions. | ||
/// </remarks> | ||
String = lsl_channel_format_t.cft_string, | ||
|
||
/// <summary> | ||
/// Represents a 32-bit signed integer format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is used for transmitting data that requires 32-bit integer | ||
/// precision. It is suitable for high-rate digitized formats and cases | ||
/// where the data is represented as discrete numeric values, such as | ||
/// application event codes or other coded data. | ||
/// </remarks> | ||
Int32 = lsl_channel_format_t.cft_int32, | ||
|
||
/// <summary> | ||
/// Represents a 16-bit signed integer format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is used for transmitting data with 16-bit integer precision. | ||
/// It is ideal for very high-rate signals (40kHz+) or consumer-grade audio. | ||
/// For professional audio, <see cref="Float"/> is recommended. | ||
/// </remarks> | ||
Int16 = lsl_channel_format_t.cft_int16, | ||
|
||
/// <summary> | ||
/// Represents an 8-bit signed integer format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is used for transmitting data with 8-bit integer precision. | ||
/// It is suitable for binary signals or other coded data. It is not | ||
/// recommended for encoding string data. | ||
/// </remarks> | ||
Int8 = lsl_channel_format_t.cft_int8, | ||
|
||
/// <summary> | ||
/// Represents a 64-bit signed integer format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format is used for transmitting data that requires 64-bit integer | ||
/// precision. Note that support for `Int64` is not yet exposed in all languages. | ||
/// Also, some builds of liblsl will not be able to send or receive data of this type. | ||
/// </remarks> | ||
Int64 = lsl_channel_format_t.cft_int64, | ||
|
||
/// <summary> | ||
/// Represents an undefined or unsupported data format. | ||
/// </summary> | ||
/// <remarks> | ||
/// This format indicates that the data format is either not defined or | ||
/// not supported for transmission. | ||
/// </remarks> | ||
Undefined = lsl_channel_format_t.cft_undefined, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
|
||
using static SharpLSL.Interop.LSL; | ||
using static SharpLSL.LSL; | ||
|
||
namespace SharpLSL | ||
{ | ||
public class ContinuousResolver : LSLObject | ||
{ | ||
public ContinuousResolver(double forgetAfter = 5.0) | ||
: base(lsl_create_continuous_resolver(forgetAfter)) | ||
{ | ||
} | ||
|
||
public ContinuousResolver(string property, string value, double forgetAfter = 5.0) | ||
: base(lsl_create_continuous_resolver_byprop(property, value, forgetAfter)) | ||
{ | ||
} | ||
|
||
public ContinuousResolver(string predicate, double forgetAfter = 5.0) | ||
: base(lsl_create_continuous_resolver_bypred(predicate, forgetAfter)) | ||
{ | ||
} | ||
|
||
public ContinuousResolver(IntPtr handle, bool ownsHandle = true) | ||
: base(handle, ownsHandle) | ||
{ | ||
} | ||
|
||
public StreamInfo[] Resolve(int maxCount = 1024) | ||
{ | ||
var streamInfoPointers = new IntPtr[maxCount]; | ||
|
||
var result = lsl_resolver_results(handle, streamInfoPointers, (uint)streamInfoPointers.Length); | ||
CheckError(result); | ||
|
||
var streamInfos = new StreamInfo[result]; | ||
for (int i = 0; i < result; ++i) | ||
streamInfos[i] = new StreamInfo(streamInfoPointers[i], true); | ||
|
||
return streamInfos; | ||
} | ||
|
||
public StreamInfo[] ResolveAll(int maxCount = 1024, double waitTime = 1.0) | ||
{ | ||
var streamInfoPointers = new IntPtr[maxCount]; | ||
|
||
var result = lsl_resolve_all(streamInfoPointers, (uint)streamInfoPointers.Length, waitTime); | ||
CheckError(result); | ||
|
||
var streamInfos = new StreamInfo[result]; | ||
for (int i = 0; i < result; ++i) | ||
streamInfos[i] = new StreamInfo(streamInfoPointers[i], true); | ||
|
||
return streamInfos; | ||
} | ||
|
||
public StreamInfo[] Resolve(string property, string value, int minCount, int maxCount = 1024, double timeout = Forever) | ||
{ | ||
var streamInfoPointers = new IntPtr[maxCount]; | ||
|
||
var result = lsl_resolve_byprop(streamInfoPointers, (uint)streamInfoPointers.Length, property, value, minCount, timeout); | ||
CheckError(result); | ||
|
||
var streamInfos = new StreamInfo[result]; | ||
for (int i = 0; i < result; ++i) | ||
streamInfos[i] = new StreamInfo(streamInfoPointers[i], true); | ||
|
||
return streamInfos; | ||
} | ||
|
||
public StreamInfo[] Resolve(string predicate, int minCount, int maxCount = 1024, double timeout = Forever) | ||
{ | ||
var streamInfoPointers = new IntPtr[maxCount]; | ||
|
||
var result = lsl_resolve_bypred(streamInfoPointers, (uint)streamInfoPointers.Length, predicate, minCount, timeout); | ||
CheckError(result); | ||
|
||
var streamInfos = new StreamInfo[result]; | ||
for (int i = 0; i < result; ++i) | ||
streamInfos[i] = new StreamInfo(streamInfoPointers[i], true); | ||
|
||
return streamInfos; | ||
} | ||
|
||
protected override void DestroyLSLObject() | ||
{ | ||
lsl_destroy_continuous_resolver(handle); | ||
} | ||
} | ||
} |
Oops, something went wrong.