Cabbage Logo
Back to Cabbage Site

CsoundUnity csd editor

With the new CsoundUnity object (3.0), it is possible to edit .csd files from within Unity, but I seem to have lost the option of editing the same file with Cabbage. If I make a change to the loaded csd file within Cabbage the file changes don’t get updated in Unity (i.e. Unity is still using the old files) until I reload the csd file by clicking on the little target to the left of the csd asset field. There is probably a simple workaround for this but I am not sure what I am doing wrong. I much prefer to edit in Cabbage than in the little window in unity.

Running on a Power Mac (10.14.6) 3-GB * 8 core 128GB RAM
Unity 2019.9.4f1 Cabbage 2.5.28 CsoundUnity 3.0

I think you have to enable FILEWATCHER somewhere, @giovannibedetti, what say you?

Yes this is expected, since the csd is saved as a string when you drag it into the CsdAsset inspector field.
Previously it was treated like an ‘external’ asset (it needed to reside inside the StreamingAssets folder, ans so it had an absolute path), and Unity was handling its updates. But we had issues with the editor, that wasn’t able to serialise it properly after the update.
Now the csd is treated like a real asset, so it can be placed in any folder inside the project.
So we added a file watcher to listen to the changes and update our internal string, the audio and control channels.

To enable the FileWatcher:

  • Open the Other Settings panel of the Player settings and navigate to the Scripting Define Symbols text box.

Report any issue on Github, this is considered an experimental feature, since it has been tested on a limited set of devices.

This design choice was made also to ensure that the csd is not accessible in the final build.
But I understand that in some cases it could be required to be able to update the csd(s) after the build is exported.
We can think of adding this feature indeed.

The FILEWATCHER_ON setting works some of the time, but it is pretty finicky. When working on a project, I would expect that most people would want to be altering the csd code while they are building their project, but maybe that is just me. The Edit Csnd Section is not easy to work with - Cabbage is much easier.

  1. with FILEWATCHER_ON set, I make a change in Cabbage, save it and run Unity - the change works
  2. I have the Edit Csd Section tab down so the text is visible, I make a change in Cabbage, save it and run Unity - the change isn’t made
  3. Close the Edit Csd Section tab, make a change in Cabbage, save it and run Unity - the change still is not made
  4. Quit Unity and load it again, make a change in Cabbage, save it and run Unity - the change works
  5. Make another change, save it and run Unity - the change isn’t working.

The FileWatcher only seems to work occasionally. It seems safer to just click on the asset target and reload the script before running Unity.

Thanks for your test. I’ll have a look asap!

I had a look.
Indeed it coudn’t detect changes on a csd when opening the project, and also it was listening to changes while in playmode, which is not correct.

But it was working in all other scenarios: if you see the csd text area is not updated, try to scroll its content or click in the inspector, you will see it updated! That’s because Unity updates the TextArea when it gets focused.
Btw I pushed an update to the master branch: to load the new version, go to the Package Manager, click + and paste again:
Let me know how it goes!