Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a79ec7db authored by MONSEIGNE Thibaut's avatar MONSEIGNE Thibaut
Browse files

:hammer: Update LSL Binding

parent 0d11e79f
Branches
No related tags found
No related merge requests found
Pipeline #339087 passed
...@@ -19,15 +19,15 @@ public class LSLShowStreamsWindow : EditorWindow ...@@ -19,15 +19,15 @@ public class LSLShowStreamsWindow : EditorWindow
private Vector2 scrollVector; private Vector2 scrollVector;
private string streamLookUpResult; private string streamLookUpResult;
private liblsl.ContinuousResolver resolver; private ContinuousResolver resolver;
private string lslVersionInfos; private string lslVersionInfos;
public void Init() public void Init()
{ {
resolver = new liblsl.ContinuousResolver(); resolver = new ContinuousResolver();
int libVersion = liblsl.LibraryVersion(); int libVersion = LSL.LibraryVersion();
int protocolVersion = liblsl.ProtocolVersion(); int protocolVersion = LSL.ProtocolVersion();
int libMajor = libVersion / 100; int libMajor = libVersion / 100;
int libMinor = libVersion % 100; int libMinor = libVersion % 100;
...@@ -39,7 +39,7 @@ public class LSLShowStreamsWindow : EditorWindow ...@@ -39,7 +39,7 @@ public class LSLShowStreamsWindow : EditorWindow
titleContent = new GUIContent("LSL Utility"); titleContent = new GUIContent("LSL Utility");
} }
private liblsl.StreamInfo[] streamInfos = null; private StreamInfo[] streamInfos = null;
private void OnGUI() private void OnGUI()
{ {
...@@ -101,7 +101,7 @@ public class LSLShowStreamsWindow : EditorWindow ...@@ -101,7 +101,7 @@ public class LSLShowStreamsWindow : EditorWindow
if (streamInfos.Length == 0) { streamLookUpResult = NO_STREAMS_FOUND; } if (streamInfos.Length == 0) { streamLookUpResult = NO_STREAMS_FOUND; }
else else
{ {
foreach (liblsl.StreamInfo item in streamInfos) { namesOfStreams.Add($"{item.Name()} {item.Type()} {item.Hostname()} {item.Sampling()}"); } foreach (StreamInfo item in streamInfos) { namesOfStreams.Add($"{item.Name()} {item.Type()} {item.Hostname()} {item.Sampling()}"); }
streamLookUpResult = namesOfStreams.Count + N_STREAMS_FOUND; streamLookUpResult = namesOfStreams.Count + N_STREAMS_FOUND;
} }
} }
......
This diff is collapsed.
...@@ -17,8 +17,8 @@ public abstract class OVInlet<T> : MonoBehaviour ...@@ -17,8 +17,8 @@ public abstract class OVInlet<T> : MonoBehaviour
public string StreamName => streamName; public string StreamName => streamName;
public int ChannelCount => expectedChannels; public int ChannelCount => expectedChannels;
protected liblsl.StreamInlet inlet; protected StreamInlet inlet;
private liblsl.ContinuousResolver resolver; private ContinuousResolver resolver;
private bool readyToResolve = true; private bool readyToResolve = true;
protected int expectedChannels = 0; protected int expectedChannels = 0;
...@@ -38,7 +38,7 @@ public abstract class OVInlet<T> : MonoBehaviour ...@@ -38,7 +38,7 @@ public abstract class OVInlet<T> : MonoBehaviour
} }
Debug.Log("Creating LSL resolver for stream " + streamName); Debug.Log("Creating LSL resolver for stream " + streamName);
resolver = new liblsl.ContinuousResolver("name", streamName); resolver = new ContinuousResolver("name", streamName);
ResolveStream(); ResolveStream();
} }
...@@ -69,10 +69,10 @@ public abstract class OVInlet<T> : MonoBehaviour ...@@ -69,10 +69,10 @@ public abstract class OVInlet<T> : MonoBehaviour
public void PopSamples() { samples = null; } public void PopSamples() { samples = null; }
private void CreateInlet(liblsl.StreamInfo result) private void CreateInlet(StreamInfo result)
{ {
Debug.Log($"Resolving Stream : Name = {streamName}, Steam Info Name = {result.Name()}, Stream Info Type = ({result.Type()}"); //Debug.Log($"Resolving Stream : Name = {streamName}, Steam Info Name = {result.Name()}, Stream Info Type = ({result.Type()}");
inlet = new liblsl.StreamInlet(result); inlet = new StreamInlet(result);
expectedChannels = inlet.Info().ChannelCount(); expectedChannels = inlet.Info().ChannelCount();
} }
...@@ -84,7 +84,7 @@ public abstract class OVInlet<T> : MonoBehaviour ...@@ -84,7 +84,7 @@ public abstract class OVInlet<T> : MonoBehaviour
yield return new WaitUntil(() => readyToResolve); // False mutex to wait Found Stream before search an other yield return new WaitUntil(() => readyToResolve); // False mutex to wait Found Stream before search an other
readyToResolve = false; // Avoïd double resolver readyToResolve = false; // Avoïd double resolver
liblsl.StreamInfo[] results = resolver.Results(); StreamInfo[] results = resolver.Results();
if (waitStream) { yield return new WaitUntil(() => results.Length > 0); } if (waitStream) { yield return new WaitUntil(() => results.Length > 0); }
if (results.Length > 0) { CreateInlet(results[0]); } if (results.Length > 0) { CreateInlet(results[0]); }
readyToResolve = true; readyToResolve = true;
......
...@@ -21,8 +21,8 @@ public abstract class OVOutlet<T> : MonoBehaviour ...@@ -21,8 +21,8 @@ public abstract class OVOutlet<T> : MonoBehaviour
public string StreamName => streamName; public string StreamName => streamName;
public int ChannelCount => channelCount; public int ChannelCount => channelCount;
protected liblsl.StreamOutlet outlet; protected StreamOutlet outlet;
protected liblsl.StreamInfo info; protected StreamInfo info;
protected T[] samples; protected T[] samples;
protected StreamTypes streamType = StreamTypes.Int; protected StreamTypes streamType = StreamTypes.Int;
...@@ -40,13 +40,13 @@ public abstract class OVOutlet<T> : MonoBehaviour ...@@ -40,13 +40,13 @@ public abstract class OVOutlet<T> : MonoBehaviour
} }
} }
private liblsl.channel_format_t GetFormat() private ChannelFormat GetFormat()
{ {
switch (streamType) switch (streamType)
{ {
case StreamTypes.Double: return liblsl.channel_format_t.cf_double64; case StreamTypes.Double: return ChannelFormat.Double64;
case StreamTypes.Float: return liblsl.channel_format_t.cf_float32; case StreamTypes.Float: return ChannelFormat.Float32;
case StreamTypes.Int: return liblsl.channel_format_t.cf_int32; case StreamTypes.Int: return ChannelFormat.Int32;
default: throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException();
} }
} }
...@@ -56,8 +56,8 @@ public abstract class OVOutlet<T> : MonoBehaviour ...@@ -56,8 +56,8 @@ public abstract class OVOutlet<T> : MonoBehaviour
private void Start() private void Start()
{ {
samples = new T[channelCount]; samples = new T[channelCount];
info = new liblsl.StreamInfo(streamName, GetType(), channelCount, liblsl.IRREGULAR_RATE, GetFormat()); info = new StreamInfo(streamName, GetType(), channelCount, LSL.IRREGULAR_RATE, GetFormat());
outlet = new liblsl.StreamOutlet(info); outlet = new StreamOutlet(info);
Debug.Log($"Creating Stream : Name = {info.Name()}, Type = {info.Type()}, Channel Count = {info.ChannelCount()}, Format = {info.ChannelFormat()}"); Debug.Log($"Creating Stream : Name = {info.Name()}, Type = {info.Type()}, Channel Count = {info.ChannelCount()}, Format = {info.ChannelFormat()}");
} }
......
...@@ -11,12 +11,12 @@ public class LSLMarkerStream : MonoBehaviour ...@@ -11,12 +11,12 @@ public class LSLMarkerStream : MonoBehaviour
private const string UNIQUE_SOURCE_ID = "D3F83BB699EB49AB94A9FA44B88882AB"; private const string UNIQUE_SOURCE_ID = "D3F83BB699EB49AB94A9FA44B88882AB";
private const int LSL_CHANNEL_COUNT = 1; private const int LSL_CHANNEL_COUNT = 1;
private const double NOMINAL_SRATE = liblsl.IRREGULAR_RATE; private const double NOMINAL_SRATE = LSL.IRREGULAR_RATE;
private const liblsl.channel_format_t LSL_CHANNEL_FORMAT = liblsl.channel_format_t.cf_string; private const ChannelFormat LSL_CHANNEL_FORMAT = ChannelFormat.Str;
private liblsl.StreamInfo info; private StreamInfo info;
private liblsl.StreamOutlet outlet; private StreamOutlet outlet;
//Assuming that markers are never send in regular intervalls //Assuming that markers are never send in regular intervalls
private string[] sample; private string[] sample;
...@@ -24,8 +24,8 @@ public class LSLMarkerStream : MonoBehaviour ...@@ -24,8 +24,8 @@ public class LSLMarkerStream : MonoBehaviour
private void Awake() private void Awake()
{ {
sample = new string[LSL_CHANNEL_COUNT]; sample = new string[LSL_CHANNEL_COUNT];
info = new liblsl.StreamInfo(streamName, streamType, LSL_CHANNEL_COUNT, NOMINAL_SRATE, LSL_CHANNEL_FORMAT, UNIQUE_SOURCE_ID); info = new StreamInfo(streamName, streamType, LSL_CHANNEL_COUNT, NOMINAL_SRATE, LSL_CHANNEL_FORMAT, UNIQUE_SOURCE_ID);
outlet = new liblsl.StreamOutlet(info); outlet = new StreamOutlet(info);
} }
public void Write(string marker, double timeStamp = 0) public void Write(string marker, double timeStamp = 0)
......
...@@ -7,8 +7,8 @@ public enum MomentForSampling { Update, FixedUpdate, LateUpdate } ...@@ -7,8 +7,8 @@ public enum MomentForSampling { Update, FixedUpdate, LateUpdate }
public class LSLOutlet : MonoBehaviour public class LSLOutlet : MonoBehaviour
{ {
private liblsl.StreamOutlet outlet; private StreamOutlet outlet;
private liblsl.StreamInfo info; private StreamInfo info;
private float[] sample; private float[] sample;
public string streamName = "Unity.ExampleStream"; public string streamName = "Unity.ExampleStream";
...@@ -24,8 +24,8 @@ public class LSLOutlet : MonoBehaviour ...@@ -24,8 +24,8 @@ public class LSLOutlet : MonoBehaviour
watch.Start(); watch.Start();
sample = new float[channelCount]; sample = new float[channelCount];
info = new liblsl.StreamInfo(streamName, streamType, channelCount, Time.fixedDeltaTime * 1000); info = new StreamInfo(streamName, streamType, channelCount, Time.fixedDeltaTime * 1000);
outlet = new liblsl.StreamOutlet(info); outlet = new StreamOutlet(info);
} }
public void FixedUpdate() public void FixedUpdate()
......
...@@ -16,8 +16,8 @@ namespace LSL4Unity ...@@ -16,8 +16,8 @@ namespace LSL4Unity
public double LateUpdateTimeStamp { get; private set; } public double LateUpdateTimeStamp { get; private set; }
private void Awake() { Instance = this; } private void Awake() { Instance = this; }
private void FixedUpdate() { FixedUpdateTimeStamp = liblsl.LocalClock(); } private void FixedUpdate() { FixedUpdateTimeStamp = LSL.LocalClock(); }
private void Update() { UpdateTimeStamp = liblsl.LocalClock(); } private void Update() { UpdateTimeStamp = LSL.LocalClock(); }
private void LateUpdate() { LateUpdateTimeStamp = liblsl.LocalClock(); } private void LateUpdate() { LateUpdateTimeStamp = LSL.LocalClock(); }
} }
} }
...@@ -11,8 +11,8 @@ public class LSLTransformOutlet : MonoBehaviour ...@@ -11,8 +11,8 @@ public class LSLTransformOutlet : MonoBehaviour
private string uniqueSourceId; private string uniqueSourceId;
private int channelCount = 0; private int channelCount = 0;
private liblsl.StreamOutlet outlet; private StreamOutlet outlet;
private liblsl.StreamInfo streamInfo; private StreamInfo streamInfo;
/// <summary> Use a array to reduce allocation costs and reuse it for each sampling call. </summary> /// <summary> Use a array to reduce allocation costs and reuse it for each sampling call. </summary>
private float[] sample; private float[] sample;
...@@ -26,7 +26,7 @@ public class LSLTransformOutlet : MonoBehaviour ...@@ -26,7 +26,7 @@ public class LSLTransformOutlet : MonoBehaviour
public Transform sampleSource; public Transform sampleSource;
/// <summary> Due to an instable framerate we assume a irregular data rate. </summary> /// <summary> Due to an instable framerate we assume a irregular data rate. </summary>
private const double DATA_RATE = liblsl.IRREGULAR_RATE; private const double DATA_RATE = LSL.IRREGULAR_RATE;
private void Awake() private void Awake()
{ {
...@@ -41,7 +41,7 @@ public class LSLTransformOutlet : MonoBehaviour ...@@ -41,7 +41,7 @@ public class LSLTransformOutlet : MonoBehaviour
// initialize the array once // initialize the array once
channelCount = channelDefinitions.Count; channelCount = channelDefinitions.Count;
sample = new float[channelCount]; sample = new float[channelCount];
streamInfo = new liblsl.StreamInfo(streamName, streamType, channelCount, DATA_RATE, liblsl.channel_format_t.cf_float32, uniqueSourceId); streamInfo = new StreamInfo(streamName, streamType, channelCount, DATA_RATE, ChannelFormat.Float32, uniqueSourceId);
// it's not possible to create a XMLElement before and append it. // it's not possible to create a XMLElement before and append it.
var chns = streamInfo.Desc().AppendChild("channels"); var chns = streamInfo.Desc().AppendChild("channels");
...@@ -51,7 +51,7 @@ public class LSLTransformOutlet : MonoBehaviour ...@@ -51,7 +51,7 @@ public class LSLTransformOutlet : MonoBehaviour
chns.AppendChild("channel").AppendChildValue("label", def.label).AppendChildValue("unit", def.unit).AppendChildValue("type", def.type); chns.AppendChild("channel").AppendChildValue("label", def.label).AppendChildValue("unit", def.unit).AppendChildValue("type", def.type);
} }
outlet = new liblsl.StreamOutlet(streamInfo); outlet = new StreamOutlet(streamInfo);
} }
/// <summary> /// <summary>
...@@ -93,7 +93,7 @@ public class LSLTransformOutlet : MonoBehaviour ...@@ -93,7 +93,7 @@ public class LSLTransformOutlet : MonoBehaviour
sample[++offset] = pos.z; sample[++offset] = pos.z;
} }
outlet.PushSample(sample, liblsl.LocalClock()); outlet.PushSample(sample, LSL.LocalClock());
} }
......
...@@ -16,12 +16,12 @@ public class Resolver : MonoBehaviour, IEventSystemHandler ...@@ -16,12 +16,12 @@ public class Resolver : MonoBehaviour, IEventSystemHandler
public float forgetStreamAfter = 1.0f; public float forgetStreamAfter = 1.0f;
public List<LSLStreamInfoWrapper> streams; public List<LSLStreamInfoWrapper> streams;
private liblsl.ContinuousResolver resolver; private ContinuousResolver resolver;
/// <summary> Use this for initialization. </summary> /// <summary> Use this for initialization. </summary>
private void Start() private void Start()
{ {
resolver = new liblsl.ContinuousResolver(forgetStreamAfter); resolver = new ContinuousResolver(forgetStreamAfter);
StartCoroutine(ResolveContinuously()); StartCoroutine(ResolveContinuously());
} }
...@@ -79,7 +79,7 @@ public class Resolver : MonoBehaviour, IEventSystemHandler ...@@ -79,7 +79,7 @@ public class Resolver : MonoBehaviour, IEventSystemHandler
public string name; public string name;
public string type; public string type;
public liblsl.StreamInfo Item { get; } public StreamInfo Item { get; }
public string StreamUid { get; } public string StreamUid { get; }
public int ChannelCount { get; } public int ChannelCount { get; }
...@@ -89,7 +89,7 @@ public class Resolver : MonoBehaviour, IEventSystemHandler ...@@ -89,7 +89,7 @@ public class Resolver : MonoBehaviour, IEventSystemHandler
public double DataRate { get; } public double DataRate { get; }
public int StreamVersion { get; } public int StreamVersion { get; }
public LSLStreamInfoWrapper(liblsl.StreamInfo item) public LSLStreamInfoWrapper(StreamInfo item)
{ {
Item = item; Item = item;
name = item.Name(); name = item.Name();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment