Cabbage Logo
Back to Cabbage Site

Scanned/Plugins in Unity

Hello all,

Jumping off on exploring the possibilities that Scanned Synthesis has to offer in Unity. Running into some issues early on here…

In trying to get a Scanned Instrument to run in Unity, it’s come to my attention that in order to do so would require the Csoundunity component to have a global environment folder to seek out it’s necessary “OPCODE6DIR64” pieces. (This is because scanu and scans opcodes come as plugins.) This, as well as folder to the “SFDIR”, which will contain the “.matrixb” file, often used in the scanu opcode.

As of now, I’ve gathered some technique from the EnvironmentVars Scenes from the ~Samples in the Csoundunity GitHub. It seems like the method of doing this is during Start(). The script in the example is used for a Sound Font file. I believe that the same method used in that script can be used to create a place to store Plugins as well? I’ll attach what I’ve been experimenting with for the script. As of now, the "var plugin = Resources.Load(pluginName); " line is returning Null.

I have both the libscansyn.dylib (the plugin for scan) and the .matrixb file in a folder called “Resources”. The Csoundunity component is on an object with both a path for SFDIR and OPCODE6DIR64.

Just wondering all the things that I should be considering with this. I’m excited to get moving with scanu in Unity, and believe that this might just be the main technical hurdle to get past.

Also---- I am on macOS, and am trying to make a build onto the Quest 2, so an Android build will be necessary.

Also Also—This is my first post here, so please let me know anything I could do to improve my writing! Or anything else I can include with this post :).

Initializer_Alternative_Plugins.cs (1.9 KB)

@giovannibedetti will be better able to answer your concerns about where to place the opcode libs, but you can always use the --opcode-lib='..' CsOption to load a plugin opcode without setting the OPCODE6DIR64 env variable. However, are you sure the scanned opcodes are part of the Android package?

1 Like

I just had a look, yes they are in the Csound repo under Android/pluginlibs . But they need to be compiled first.
I’m creating a generic example that loads plugins and additional files, but I’m not sure if copying the libs to a path on Android will be enough or if they need to be placed somewhere specific aka jni folders. We will know soon! :wink:
image

1 Like

Also, this topic is related with this:

1 Like

So this zip works for Windows (and hopefully MacOS, but I won’t have time to test it till late this evening)
It will probably need some other work to be done for Android, but it’s a start!
Load Plugins.zip (43.4 KB)

2 Likes

Load Plugins.zip (58.3 KB)
I had to make some small adjustments to make it work on MacOS

1 Like

This is perfect! Yes, after copying over that resources file, I was able to eventually set my scene up to trigger and hear the scanned instrument. More experimentation to come. Mission accomplished there!

But, as you suspected, a build on the Quest (Android) is still not working. Any ideas on how to get over that hurdle?

So I built the plugins libs for Android, and added the scansyn lib in this zip (and made some minor changes to the code).
This builds correctly, but I will have time to test it on an Android device only tomorrow evening
Load Plugins.zip (70.2 KB)

[EDIT]
I just tried it quickly but I couldn’t make it work, either copying the .so file in the persistent data path or having it in the project or in the StreamingAssets folder.
Will think about it and let you know how to handle this :wink:

1 Like

I’ve tried these a couple times here too but no luck. But as for now I’ve been running scanu and been messed with controlling some krate parameters of the opcode in real time using transform positions. A bit worried about how well the intensity of whats going on is going to translate over to the Quest build, but we will see! I’ll let you know if I figure the build on Android out :slight_smile:

I’ve found that opcodes to be quite CPU intensive in the past. Could be an issue on the quest :grimacing: