Cabbage Logo
Back to Cabbage Site

CsoundUnity Crashing

Hello!
I’m trying out CsoundUnity for the first time mostly following the following video: https://www.youtube.com/watch?v=C9vFZTRVfSg. Everything works on the Cabbage side and my sliders and buttons are coming up in the Unity editor but when I try to run the scene and test out the controller channel buttons to test the sound in game, it crashes every time. I have tried running it in 2022.3.18f1 and 2021.3.19f1 and both have been crashing. I am running on an i7 Mac. I was wondering if there was a suggested best version of unity to run CsoundUnity in?
Thanks,
Gibran

Hi @Gibran_Mobarak and welcome to the forum.
How are you importing CsoundUnity in the project? Which version are you using?

Hi @giovannibedetti
I imported CsoundUnity through the package manager using the GitHub url. The version I am using is 3.4.2

I have tried running my project with both the CsoundUnity component disarmed as well as armed with no csd file and it still crashes both ways. If I delete the component completely my project runs.

This is very strange. Do you have Csound installed? It shouldn’t matter but it’s worth checking. In CsoundUnity we are using Csound 6.18, if you have older versions they could cause conflicts
Edit: note you shouldn’t need to install Csound to work with CsoundUnity
Can you retrieve the log of the crash?

I have Csound 6.18 and a few versions of Cabbage installed. I have attached my project below.

Unity Project

Have you tried one of the samples included in the package? Does the Basic test crash too?
Later I’ll have a look at your project and let you know what I discover

I have tried a couple of the samples in the package and the basic test is also crashing. I greatly appreciate your help.

I tried your project, I had to redownload CsoundUnity again from the package manager otherwise it was complaining about not being able to open the Csound bundle for security reasons.
The project runs, if I press the trigger button in the inspector I hear a couple of clicks, so I guess something is happening. No crash though!
Tested on a macOS Catalina (10.15.7), Intel Core i7, on Unity 2021.3.19f1.
Now downloading Unity 2021.3.37f1 and 2022.3.26f1. I’ll let you know!

In the meantime, can you try this in the terminal?

csound --version

mine says

--Csound version 6.18 (double samples) Oct 20 2022

[commit: f0bea4d87b49da2be7e9f1fc77826a7327cbc391]

I will try to update it, there is a more recent version.

Edit:
All good with Unity 2022.3.26f1
All good with Unity 2021.3.37f1

but!

after updating Csound to the latest version 6.18.1 I have the crash in both Unity versions!

This is the log of the crash:

CsoundUnity:Awake () (at Library/PackageCache/com.csound.csoundunity@5b0d56f59f/Runtime/CsoundUnity.cs:473)

(Filename: Library/PackageCache/com.csound.csoundunity@5b0d56f59f/Runtime/CsoundUnity.cs Line: 473)

Obtained 5 stack frames.
#0  0x007fff6c37f8aa in _platform_memmove$VARIANT$Nehalem
#1  0x0000017ec85b01 in csoundLoadExternal
#2  0x0000017ec8547b in csoundLoadModules
#3  0x0000017eaec172 in csoundReset
#4  0x0000017eaebe7a in csoundCreate 

@rorywalsh do you think it’s the same behaviour we had on Windows? I could try the same approach :wink:

Ok I can confirm I have the fix for the crash! Simply I need to call

Csound6.NativeMethods.csoundSetOpcodedir("."); 

for every desktop platform (mobile shouldn’t be affected).
Will draft a new version 3.4.3 soon (it was there already with other little fixes)

Thanks @giovannibedetti, looks good to me :+1:

CsoundUnity v3.4.3 is out!

THANK YOU SO MUCH! Your help means so much will definitely be trying this out when I have a moment!!!

It works!!! thank you!!!

2 Likes