Cabbage Logo
Back to Cabbage Site

Exposing csoundGetChannelIist... for presets?

Hi @giovannibedetti. I wonder if you have time might you look at adding an interface to:
If we had that we could very easily write methods to save all the current channel data. Something like this (in psedudo code):

string channels[] = csoundUnity.getAllChannels();
for ( int i = 0 ; i < channels.size() ; i++)
   float current value = csoundUnity.getChannel(channels[i]);
   writeToPresetFIle(file, channel[i], currentValue);

Similar methods could be used to read the data and update all channels accordingly? It would preset a very simple and robust way of saving presets?

1 Like

Yes it seems great!
I started a new branch where I listed all the API methods (also the ones that are not implemented yet), to be aligned with Csound 6.11. I’ll push the CsoundUnityBridge to the develop branch and add those!

I am in the middle of a big rewrite, I was just messing with channels :sweat_smile: and how the editor manages them (maybe to get saved).
I’ll write a new thread where I talk about the status of the new package development.

We definitely don’t need to implement all the API methods. Many of them are pretty useless to us!

Yes of course, but it was just to be visibly aligned with Csound 6.11. I’ll push an update of CsoundCsharp in a minute, take a look! (I also added regions to be more clear)

Btw, we’re currently on Csound 6.14 :laughing:

Too fast!!
I took everything from here,

Slow down!!

But I didn’t implement everything. Most of the methods are commented just for reference!
So It’s easier to follow the Csound API docs!

All joking aside, this is a good idea. At least others can see what has, and what has not been implemented.

1 Like

Ok I got this, but for the test synth we were talking about the native call returns 0 channels!
Then I have a crash. I’ll push it now in the dev, can you test this?
(as always I grabbed code totally from Richard Henninger’s csound6Net)

You can test this like this:

if (Input.GetMouseButtonDown(0)) {
    var list = csound.GetChannelList();
    Debug.Log("list: "+list);
    foreach (var chan in list) {
       Debug.Log(chan.Key+": "+chan.Value.Name+" "+chan.Value.Type+" dir: "+chan.Value.Direction+" "+chan.Value.Hints);

I just tried on Windows and I get a crash as soon as I try calling GetChannelList()?

Yes I think it’s something that gets wrong after the native call. it returns 0 channels:

Hold on, I think I know what’s going on. I think we have to declare our channels first. Yes, that’s right, I think we have to use:

This isn’t so useful for us… we don’t want to have to declare all channels in advance of using them…

Btw now I didn’t get the crash without changing anything. :hushed:
I think the way to go is through serializedProperties in editor, it’s a bit difficult to get a custom class from the property, but I’ll find a way:

Regardless of this, I don’t think you can actually retrieve the channels unless they have been declared with the chn opcodes. Which makes this much less usable I think…

Ok fine!
But that method could be useful in the future :wink:

TBH, it needs further investigation. It might still be possible. I guess if we can get it working with chn declared channels then at least we know it works. After that we can check for channels that Csound creates on the fly…