CsoundUnity Presets compatibility

Im using csoundUnity to sonify interactions.

Recently I found that you can create prefabs in Unity, that save all the settings on a Unity component and later you can load those presets using a script call.
I tried it with csoundUnity, and even though it loads the sliders values based on the preset, it doesn’t update the sound. after loading the preset all the sliders moved but the sound played the same. If I move a slider with the mouse it will update, but only that slider.

To try recreating this issue, move some sliders in csoundUnity, then click on the little slider icon on the top of the component to save the changes as a preset. To call the preset from a script I used :

public Preset _preset01;

void Update()
{
if(Input.GetKeyDown(KeyCode.P))
{
_preset01.ApplyTo(csoundComponent);
}

I confirmed that the preset method works for other things like transform, but I can’t get csoundUnity to update based on the preset settings

Photo for reference:
image

I can confirm this behaviour, the channels are not updated after loading a preset at runtime.
It should work if you load the preset before pressing play.
I’ll have a look in the next days to see if I find an easy fix that doesn’t require complex scripting on the user side.
Also please note that Unity presets are not meant to be used at runtime (they will work in PlayMode on editor for default types but once you build you won’t be able to call ApplyTo), have a look at this thread:
https://forum.unity.com/threads/presets-feature.491263/page-2#post-3552503

That’s super interesting.
Now I understand why it worked perfectly on transform, but not on a more complex system.

Im trying to find a method to saving “preset” (like you would do in a DAW) but in Unity, basically a setup for a synth with specific values, but be able to change the preset based on the object that is generating the sound.

Lets say I tweaked a synth to a sound I really like, and I want to save those settings and use it in Unity, but in the scene I have multiple objects, each one with a different sound generated by the same synth. I want to be able to load presets onto a synth based on the object I interact with. Maybe the solution would be multiple instruments, but I feel like there is a way to optimize something like that.

I have already made some prototype some months ago, I will add a specific “CsoundUnityPreset” class that can be serialized and saved as json in the persistent folder, or as asset in the editor, and loaded also at runtime.
I will notify you as soon as I have something to test, so that we can discuss about it :wink:
Btw it is just a matter of getting the serialized CsoundUnity.channels, save them in the preset, and restoring them when desired.
We could also think about a more complex system that allows for hyper vectorial synthesis, morphing between 2 or more presets (ie snapshots): Hyper Vectorial Synthesis

1 Like

Wow, thank you so much! That would be great!
Please keep me posted on any new development.

Hi!
First draft of presets available on the branch:

Use this link in the package manager:

https://github.com/rorywalsh/CsoundUnity.git#1632e230d95228268226dedec28524384a15f018

or better:

https://github.com/rorywalsh/CsoundUnity.git#feature/presets

Still WIP, not really documented, but I wanted to have some feedback before going on!
Let me know your thoughts!

EDIT: I think there is some issue with combo boxes yet :confused:

EDIT of EDIT: combo boxes should be fixed!

Wow! Thank you so much! I’ll check and report back!