Cabbage Logo
Back to Cabbage Site

Adding a set of standard Csound-based DSP Components to the next version of Csound Unitynts to

@giovannibedetti can’t wait for new updates, thank you so much for working on this! One thing I just noticed is that button widgets don’t seem to be represented in the presets assets? They show up on the CsoundUnity component but the presets I’m creating doesn’t seem to contemplate channels associated with buttons.

EDIT: the issue I’ve been having with that is that for some instruments I’m using a button widget paired with a changed opcode to start/stop a continuous sound and it turns out that by changing the preset it unintentionally triggers/untriggers the instrument.

Ah yes that makes sense, since I set all the channels values!
let me add an exception for the buttons.
I will probably push an update to the branch today :wink:

EDIT: I pushed an update, not really tested, but it looks good!
Let me know how it goes

1 Like

Just got a chance to test it, the button exception is working beautifully! Also thanks so much for adding a path to save the preset files!

I just pushed an update to the presets branch, I think we’re getting there!
Now you can choose the save/load folder, and also json presets are listed to be loaded from the editor!
It needs some serious testing, let me know if you find any issue :wink:
Unfortunately I cannot add the support for Cabbage snaps easily, because Unity json deserialisation is very basic and it doesn’t work with the snaps json format where the keys are the name of the channels.
I have to parse the snaps :nerd_face:

That’s a shame. Is it worth looking into using a third party JSON package? Maybe not if you have already written a parser yourself?

I’m having a look but I’d like to avoid adding dependencies. I haven’t tried to write the parser yet, hopefully it won’t be too hard!

1 Like

Just sneaked some time to check this out - the option to select which folder to load form is super useful!

EDIT: Everything seems to be working fine with the ScriptableObject presets but the ones I saved as a JSON file don’t seem to serialize in the inspector under the Assignable Presets area.

JSONs are meant to be placed in folders that Unity doesn’t compile when built, so I am not checking for JSONs that are under the Assets folder. The exception is the StreamingAssets folder, that Unity doesn’t compile.
Have a look at https://github.com/rorywalsh/CsoundUnity/blob/6d7465dd3f2d941b6202c45e01a25b4051c028bd/Editor/CsoundUnityEditor.cs#L771
Does it make sense?
If not we can try and think of a solution, for sure there is still some work to be done, for example I haven’t tried with a “Resources” folder, that could require a custom loading (Resources.Load() => https://docs.unity3d.com/ScriptReference/Resources.Load.html)

Hi Giovanni, sorry for the delay! Ah gotcha - I don’t have much experience with JSON files so wasn’t aware of that, thanks for the explanation! I can see how using a “Resources” folder could be useful to streamline preset management by potentially allowing scriptable objects and JSON presets to live in the same path maybe?

Also, is there a way that JSON presets could be converted into scriptable object presets and vice-versa? Migrating SO between projects has always been messy in my experience, but with a JSON preset I can simply copy the file to another Unity project and it works right away (which would allow me to make a “preset pack” for an instrument and carry it from project to project). At the same time, SO offer more flexibility to edit them through the inspector and to load them with scripting (since I only need to call CsoundUnity.SetPreset() and pass in a SO as the argument), so it would be useful to convert the presets to SO after importing the JSON files. Not sure if this is too convoluted or if there’s a simpler solution to this conundrum tho

Hey!
So the latest push I made should allow placing SO and JSONs everywhere, it’s on the same preset branch!
To convert the JSON into a SO you could load the JSON first and then save it as a SO for now, but I will add a method to allow that (maybe a separate Editor Window, since there’s no point in doing this at runtime, also I think it could make the current CsoundUnity editor more confusing)
Hopefully I will have some time next week to look into this :wink:

1 Like

So it was very quick to add this since all the methods were there already :wink:
I decided to add a button for each preset to convert it to JSON or SO.
Not sure what it does to Global presets, but it’s a start :sweat_smile:
Same branch: https://github.com/rorywalsh/CsoundUnity.git#feature/presets
image

1 Like

I think it’s time I read up on Scriptable Objects. C# is becoming a distant memory to me :rofl:

:joy: Nothing scary, think of them as data containers that are saved as assets in the project. This allows us to create a custom editor for them:

That looks nice. I won’t be teaching Sound Design with Unity this semester :frowning: I would have liked to have got into this a little deeper.

Oh that’s a pity! We need new CsoundUnity devs!! :joy:
Btw don’t worry, since this is mostly Editor tooling, I can handle it alone.
For sure I will need some help for the topic of this thread though, I tried investigating a bit on the Native Audio Plugin and I’m kinda lost at the beginning, which is importing Csound in this existing project :sweat_smile:
But in general I think we should keep the existing implementation alongside the native Csound based DSP effects, so it will be an addition, and not a major rework.
Well, TBD after some thinking all together in November during the Csound Conference!

This is very nice. Thanks, Giovanni.

1 Like

@giovannibedetti thanks for the update!

One issue I just encountered with presets: it seems that CsoundUnity reads an absolute path for saving and loading presets - this is causing Unity to log errors in the console when a collaborator opens the project in another machine, making it so we have to reset the save and load paths every time a commit is made.

Would it be possible to make CsoundUnity set a relative path within the Unity project for saving and loading presets?

Thanks so much again for your work on this, this has been super useful!

Ok yes, it makes sense.
I tried an hotfix, let me know how it goes. Will have a closer look tomorrow evening!
Cheers :wink:

Just pushed a better fix for the paths in the presets branch, let me know!