labstreaminglayer / liblsl-Csharp

C# bindings for liblsl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unity Readme Example Fixes

markgrossnickle opened this issue · comments

The readme examples for Unity has a couple issues as far as I can tell:
https://github.com/labstreaminglayer/liblsl-Csharp/blob/master/README-Unity.md

I am using Unity 2020.3.10f1

  1. LSLInput calls LSL.resolve_stream around line 19 but it can not find it. It should be LSL.LSL.resolve_stream as Unity seems to be getting confused with the namespace and class being the same (which probably should changed).

  2. LSLOutput references liblsl.channel_format_t.cf_float32 but it can not find it. If you remove liblsl from the start then it works.

  3. This is more of a best practices than an actual error but LSLOutput calls FixedUpdate and has a comment that says it is called once per frame. This is not true. FixedUpdate gets called at a fixed interval regardless of framerate. Typically 0.02ms. Perhaps that is ideal as framerate can fluctuate, but it is also dangerous as it could make the framerate behavior erratically if too much processing is put within FixedUpdate. Most likely this should be changed to Update or if it is intentional then the comment should be updated to reflect FixedUpdate's behavior.

LSLInput calls LSL.resolve_stream around line 19 but it can not find it. It should be LSL.LSL.resolve_stream as Unity seems to be getting confused with the namespace and class being the same (which probably should changed).

Yes, the namespace changed at some point from the poorly named LSL to the even more poorly named LSL.LSL. This didn't get reflected in this README.

LSLOutput references liblsl.channel_format_t.cf_float32 but it can not find it. If you remove liblsl from the start then it works.

I don't know how the liblsl namespace ever got in there.

This is more of a best practices than an actual error but LSLOutput calls FixedUpdate and has a comment that says it is called once per frame. This is not true. FixedUpdate gets called at a fixed interval regardless of framerate. Typically 0.02ms. Perhaps that is ideal as framerate can fluctuate, but it is also dangerous as it could make the framerate behavior erratically if too much processing is put within FixedUpdate. Most likely this should be changed to Update or if it is intentional then the comment should be updated to reflect FixedUpdate's behavior.

Thank you for this insight.

I will take this opportunity to once again express my concern that this C# wrapper is not meeting proper standards for style and technique according to Microsoft's guidelines. I am currently (and slowly) developing a new wrapper(https://github.com/Diademics-Pty-Ltd/LSL-dotnet) which I believe is more idiomatic, takes advantage of the latest C# advancements, adheres to Microsoft's naming and style conventions, and has way better names for the static method namespaces. If you care to take a look, I'd be interested in your feedback.

I will take this opportunity to once again express my concern that this C# wrapper is not meeting proper standards for style and technique according to Microsoft's guidelines.

PRs welcome!

The discussion in #18 seemed like it was going somewhere.

I don't mind drastically changing the API of liblsl-Csharp. We can increment the major version. I think Unity users will be the only ones who are annoyed (little benefit to them compared to native C# users).

My main motivation is that I don't want to spend eternity answering questions about namespace issues, so if there's a better long-lasting API then I'm all for it.
Just note that it shouldn't be targeting "only windows". It also has to work in e.g. Unity on iOS and other Mono targets.

Looks like there is a PR sitting there since June to fix this issue: #18

Yes. I never merged this because I wanted to re-write the wrapper (which I did) but then I never got any feedback on it. @cboulay, I will prepare a PR for my version. Maybe that is a better way to get some comments than what I did. Also, just to assuage any doubts, the wrapper I wrote will work on any OS with .NET provided it has the right version of lsl.dll to work with.

I still need to make example programs for this so it might take me a bit of time. In the meantime I guess it is fine to merge #18.

#18 is now merged. However, the OP's comment about FixedUpdate has not been attended to.

I updated the comment string around FixedUpdate and Update.
The original comment was correct in that it was talking about Update and not FixedUpdate, it just had no business being immediately above the FixedUpdate definition.

Closing, with the understanding that a better solution is coming.