Cabbage Logo
Back to Cabbage Site

CsoundUnity 3.0, "sfload: cannot open SoundFont file"

First of all, want to say how very excited I am about CsoundUnity 3.0, and so many thanks for this release.

I’m just starting out testing, and have one question up front with an error code "sfload: cannot open SoundFont file sf_GMbank.sf2

This had been working well in previous versions of CsoundUnity where the Resources/StreamingAssets directory was used. I was able to use the FluidSynth sf opcodes: sfload, sfilist, and sfinstr by manually copying the SoundFont file into StreamingAssets.

Is there a similar workaround that you can suggest in CsoundUnity 3.0?

PS: I was able to successfully run CsoundUnity 3.0 on Windows with another .csd file that did not use FluidSynth/SoundFont

Thanks again, I’m so excited about this new release

This sounds like a path issue, @giovannibedetti, have you any ideas?

I’m currently away from a pc, but I’d say it should be enough to set the SFDIR path to the desired folder with SetEnv, now we’re not setting it anymore.
Let me know!

Thanks very much for getting back. I will experiment with solutions (probably over the next week or so) and get back to you. Some things I’m thinking about.

  • which directory to put the sf2 file in that would be available at runtime for at least Android and PC builds. In the previous CsoundUnity version, PC and Mac standalone builds didn’t find StreamingAssets at runtime, so I had to do workarounds (copying files by hand). (Hector’s Android version didn’t have this problem).

  • setting env variables and execution sequencing: The csd file is being compiled in CsoundUnity.Awake(), and, as you know, one can’t control the order of Unity Awake() invocations, so the environment variable would need to be set before Unity execution starts. If this is the solution, perhaps it might be better to have a way to set the PATH in code (as a CsoundUnity public variable?) rather than having to surround the Unity program with some script that sets environment variables?

Thanks again, and if this triggers any thoughts on your end, please let me know

Sorry for the late reply, I’m on holiday with poor connection.
I think you’re right. You can try to uncomment those lines in the CsoundUnityBridge constructor:

I don’t know if you’ll need to copy things on Android. Just be aware that the csd is saved as soon as you drag it in the inspector so there is no need to have it in the persistent folder.

Happy that you are experimenting with CsoundUnity again!
Any feedback is super welcome, let’s try and build something that is useful to many!

Thanks very much for getting back with this suggestion. I will try that over the next few days.