Cabbage Logo
Back to Cabbage Site

Csound and Unity on Android

Hi Rory,

I was wondering if you have tried anything recently to get CsoundUnity working on Android. I spent a long time today trying to find the source of the crash but without any errors in the logs it’s hard to figure out. I’m trying to figure out ways of debugging it (already trying with Android Studio). It is odd that it seems that CsoundUnityBridge is successfully instantiated (so the native CsoundCreate is also successful) and it also is successful compiling the CSD file but then Unity seems to crash after the initialization pass. I disabled audio processing (OnAudioFilterRead) but still the crash happens. I’ve also tried with the latest, libc++ and libsndfile from GitHub but it doesn’t make a difference.



I’m afraid I haven’t gone near it since. How you been able to confirm that the recent Csound Android libraries work Ok? I’m not sure how many people are using them, and I’ve seen reports on the mailing list about issues. I think we’d need to create an vanilla android app using the current Csound libraries just to make sure they work Ok.

I’ve more of less moved away from Unity/Unreal in favour of web based game engines such as BabylonJS and Phaser3. I use them with the csound-wasm build and they work fine and I can run them on any platform that supports a browser.

I was speaking with Steven Yi yesterday and he was talking about producing a more game engine friendly version of the Csound Android package, but I’m not sure what kind of time frame he was talking about.

Thanks Rory,

A game engine friendly version of Csound sounds great! I think it will fill a gap in that area since so far there are no mobile procedural audio synthesis and processing plugins that are publicly available, maintained and easy to integrate into Unity or Unreal. I’m mostly interested in my students using it for mobile interactive projects (including AR/VR) and for my own personal artistic work.

I’m going to try the AAR library package route now. I’ll first test the package with a vanilla Android app and then try to integrate it into a Unity project. After some more debugging with Android Studio I suspect what is happening is that the native allocation of the csound object is clashing with Unity and corrupting the memory. This might explain why the crashes often happen at different places each time without any error messages and they are all invalid access related. Hopefully doing it from an AAR library using the Java API will solve this.



Let me know how it works out for you. The lack of support on Android for Csound with Unity is one of the reasons I’ve stopped using Unity.

Some bad news. I built an AAR and just by instantiating Csound() from the Java API caused Unity to crash. It didn’t crash right away but about half minute it always crashes with the same illegal access error. There most be some low level clashes going on.

That’s too bad. There must be a conflict somewhere. Steven Yi is pretty good with android stuff. Might be worth reaching out to him?

Yes, I just posted on the Csound list asking him and anyone else for any ideas. We’ll see!

Hi, I am going to take a look at this myself, with the target of Android/Unity/Oculus Go or Quest, and I had a few questions for both of you if you don’t mind

  1. What version of csound are you using?
  2. What csound binaries and headers are you using? Files that are downloaded, ie Csound6.apk? or are you building your own?
  3. If you’re building your own csound binaries, are you doing it on mac, Linux, windows, Linux-on-windows?
  4. Same question for the CsoundUnity binary libraries: mac, Linux, windows, Linux-on-windows, etc?

Thanks very much for your work so far

PS: I am looking at a csound6.12.0-Android directory that is mentioned in the FLOSS manual with documentation dated 10/24/2018.

As far as I know @virtualHC he’s this working. Hopefully he can advise on how best to get going with it. Or perhaps provide some packages :+1:

1 Like

That would be awesome on either count.