Conversation
|
Hi @subspecs, thanks for putting this together. I do like where this is going. The overall idea makes sense to me, having a native API for other languages, being able to reuse loaded model/tokenizer/codec state across runs, supporting precomputed reference codes, and returning audio buffers directly instead of only writing files. Those are all useful additions. The C# wrapper direction also looks genuinely useful. I can see the value there, especially for people who want to use this from Unity or other .NET environments. Before merging, though, there are a few implementation details I’d like to revisit so we don’t lock in ABI / ownership issues too early.
None of that changes the fact that I think the feature direction is good. I’d just like to rework those pieces a bit before merging so the native API lands on a more stable base. If you’re up for another pass in that shape, I think this could be in good shape for merge pretty quickly. On the C# wrapper, i’m positive on the idea, but I’d prefer to hold off on adding it to the README or calling it official until the native API is stable upstream. Once the native layer is settled, I’d be happy to revisit that right after. |
@rodrigomatta
So as we talked I created a minimal, but very versatile export functions for use in other libraries.
I only concentrated doing as minimal changes to the original code as possible, only changing 1/2 parameters here:
And as we also talked about proper logging, I didn't have time to implement one, but I created a 'config' header:|
Which allows to suppress non-essential cout's/prints so that the s2 project can be used as an library.
It does NOT suppress any errors/exceptions/etc. like that, those will still be triggered. (You can find all affected references by searching for the 'SuppressNonEssentialVerbosity' variable:
With that out of the way, now we can talk about the exported function/library design:
I created a single .cpp and .h for the exported functions only.
I ONLY copied the minimal amount of code needed to run this, mostly this is as a 'wrapper' around the classes as you wanted.
I went a little extensive with the functions, so we'd gain a whole lot of control over generation, even in other languages.
What features we gained:
Sample: Working S2 code in C#
Also, I couldn't resist on creating an official PROPER modular C# wrapper for this thing. (https://github.com/subspecs/FishS2Sharp)
This library targets netstandard 2.1 so it will work in places like the Unity game engine and then S2 can be used for game development as well.
It's tested and works. (Binary in releases)
You should add it to the README here so people can find it since this is what most people are waiting for lol.