Cabbage Logo
Back to Cabbage Site

CsoundUnity - Quest Build - Process Clip Audio - Crashes

Hello everyone,

Thank you for all the work put into CsoundUnity 3.0!

Me and a couple colleagues from Berklee College of Music are trying to design Csound based interactive systems for the Quest.

The “Process Clip Audio” feature in CsoundUnity is amazing and works really well in the editor by playing a sample from the audiosource and getting the audio into Csound with the inch opcode.

But when we build the game for Android and activate the GameObject that contains the CsoundUnity component with the “Process Clip Audio” turned on inside the Quest, the game crashes. Are we missing anything? Is there any available solution to this issue?

All the other functionalities we are using of CsoundUnity work great in the Quest though!
We could definitely use some of the great audiofile player opcodes in Csound but the capacity of processing samples from Unity`s audio source makes Csound catalog much more accessible for folks that are just starting with Unity and/or Csound.

I have seem a similar thread in the Forum but I think it is addressing a different issue.

Please let me know.

Hi!

I’ve never tested the Process Clip Audio feature on the Quest. I will do a test possibly tomorrow.

What is the crash log?
You can log the Quest output writing the following in the terminal:

adb logcat -s Unity

It assumes adb is in your system path.
If you don’t want to keep the Oculus always connected your computer, you can use this commands to connect adb to it wirelessly (start with the usb connected)

adb tcpip 5555
adb connect <Quest IP address>

Until the crash is addressed you can try another way of loading files using tables, have a look at the AudioClipReader sample in the PackageManager.

I tried on my Quest, and I can confirm the crash, caused by a null pointer dereference.
This happens when using inch.
It is triggered by PerformKsmps in the CsoundUnityBridge constructor, but if I remove that line, the crash is triggered by the first SetInputSample.
If you’re curious, have a look at the logs:

PerformKsmps

11-01 12:26:01.355 3821 3843 E CRASH : Version ‘2019.4.18f1 (3310a4d4f880)’, Build type ‘Release’, Scripting Backend ‘il2cpp’, CPU ‘arm64-v8a’
11-01 12:26:01.355 3821 3843 E CRASH : Build fingerprint: ‘oculus/vr_monterey/monterey:10/QQ3A.200805.001/19130100301000000:user/release-keys’
11-01 12:26:01.355 3821 3843 E CRASH : Revision: ‘0’
11-01 12:26:01.355 3821 3843 E CRASH : ABI: ‘arm64’
11-01 12:26:01.355 3821 3843 E CRASH : Timestamp: 2021-11-01 12:26:01+0100
11-01 12:26:01.355 3821 3843 E CRASH : pid: 3821, tid: 3843, name: UnityMain >>> com.Csound.Test<<<
11-01 12:26:01.355 3821 3843 E CRASH : uid: 10006
11-01 12:26:01.355 3821 3843 E CRASH : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
11-01 12:26:01.355 3821 3843 E CRASH : Cause: null pointer dereference
11-01 12:26:01.355 3821 3843 E CRASH : x0 0000000000000000 x1 0000000000000000 x2 0000000000000050 x3 0000000000000001
11-01 12:26:01.355 3821 3843 E CRASH : x4 0000000000000050 x5 0000000000000000 x6 0000000080808080 x7 fefefeff6d686066
11-01 12:26:01.355 3821 3843 E CRASH : x8 0000000000000014 x9 0000000000000000 x10 00000000ffffffff x11 0000000000010129
11-01 12:26:01.355 3821 3843 E CRASH : x12 0000000000174876 x13 0000000000174876 x14 00000000e0000000 x15 0000000000000010
11-01 12:26:01.355 3821 3843 E CRASH : x16 0000007b66418b18 x17 0000007d29cfe180 x18 0000000000000001 x19 0000007b389690c0
11-01 12:26:01.355 3821 3843 E CRASH : x20 0000007b8fdb5750 x21 0000007b389764d8 x22 000000000000000a x23 0000007b8fdaa828
11-01 12:26:01.355 3821 3843 E CRASH : x24 0000007b8fdab860 x25 0000007b8fdb5ec8 x26 0000007b8fdae140 x27 0000007b8fdaefc8
11-01 12:26:01.355 3821 3843 E CRASH : x28 0000007b8fda8668 x29 0000007c448c9690
11-01 12:26:01.355 3821 3843 E CRASH : sp 0000007c448c9610 lr 0000007b6622b020 pc 0000007d29cfe1d4
11-01 12:26:01.355 3821 3843 E CRASH :
11-01 12:26:01.355 3821 3843 E CRASH : backtrace:
11-01 12:26:01.356 3821 3843 E CRASH : #00 pc 000000000007d1d4 /apex/com.android.runtime/lib64/bionic/libc.so (je_malloc_tsd_boot1+336) (BuildId: a6e0ca3a9989715134d1d1e2126e0f7a)
11-01 12:26:01.356 3821 3843 E CRASH : #01 pc 000000000026c7bc /data/app/com.Csound.Test-N86vTFVgHa9UJOcD1vItQA==/lib/arm64/libcsoundandroid.so (csoundPerformKsmps+88) (BuildId: 14bbe369e9bc5e6498d049a0e144a3372a150e22)
11-01 12:26:01.356 3821 3843 E CRASH : #02 pc 0000000000f578f8 /data/app/com.Csound.Test-N86vTFVgHa9UJOcD1vItQA==/lib/arm64/libil2cpp.so (NativeMethods_csoundPerformKsmps_mD19614A8754F1561434A9B9F42B93B92D398B671+228) (BuildId: 833d3d822ca9d2fe3f258b9df16b9b931b4ebf4d)
11-01 12:26:01.356 3821 3843 E CRASH : #03 pc 0000000000f4bbb0 /data/app/com.Csound.Test-N86vTFVgHa9UJOcD1vItQA==/lib/arm64/libil2cpp.so (CsoundUnityBridge_PerformKsmps_mBD5CFEF9AFA5F5F8152A0DCDD7BD472CD1EA5A1C+48) (BuildId: 833d3d822ca9d2fe3f258b9df16b9b931b4ebf4d)
11-01 12:26:01.356 3821 3843 E CRASH : #04 pc 0000000000f4b1c0 /data/app/com.Csound.Test-N86vTFVgHa9UJOcD1vItQA==/lib/arm64/libil2cpp.so (CsoundUnityBridge__ctor_m98477FFDFF745467E19C515BCEF02BD119328B30+1516) (BuildId: 833d3d822ca9d2fe3f258b9df16b9b931b4ebf4d)
11-01 12:26:01.356 3821 3843 E CRASH : #05 pc 0000000000f4a288 /data/app/com.Csound.Test-N86vTFVgHa9UJOcD1vItQA==/lib/arm64/libil2cpp.so (CsoundUnity_Awake_m84B0F06B369253CF05643D3F1CB264E76B1FB76C+1668) (BuildId: 833d3d822ca9d2fe3f258b9df16b9b931b4ebf4d)

SetInputSample

11-01 15:05:45.333 6493 6560 E CRASH : Version ‘2019.4.18f1 (3310a4d4f880)’, Build type ‘Release’, Scripting Backend ‘il2cpp’, CPU ‘arm64-v8a’
11-01 15:05:45.333 6493 6560 E CRASH : Build fingerprint: ‘oculus/vr_monterey/monterey:10/QQ3A.200805.001/19130100301000000:user/release-keys’
11-01 15:05:45.333 6493 6560 E CRASH : Revision: ‘0’
11-01 15:05:45.333 6493 6560 E CRASH : ABI: ‘arm64’
11-01 15:05:45.333 6493 6560 E CRASH : Timestamp: 2021-11-01 15:05:45+0100
11-01 15:05:45.333 6493 6560 E CRASH : pid: 6493, tid: 6560, name: FMOD mixer thre >>> com.Csound.Test<<<
11-01 15:05:45.333 6493 6560 E CRASH : uid: 10006
11-01 15:05:45.333 6493 6560 E CRASH : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
11-01 15:05:45.333 6493 6560 E CRASH : Cause: null pointer dereference
11-01 15:05:45.333 6493 6560 E CRASH : x0 0000007b39c5c400 x1 0000000000000000 x2 0000000000000000 x3 0000007b39ddf6a0
11-01 15:05:45.333 6493 6560 E CRASH : x4 0000000000000000 x5 051f0e3c00000000 x6 000000803c0e1f05 x7 60756048ff646b6f
11-01 15:05:45.333 6493 6560 E CRASH : x8 0000000000000000 x9 0000000000000000 x10 0000000000000000 x11 0000000000000000
11-01 15:05:45.333 6493 6560 E CRASH : x12 ffffffffffff8000 x13 0000000000000001 x14 fffffffffc000000 x15 ffffffffffffc000
11-01 15:05:45.333 6493 6560 E CRASH : x16 0000007d29d61110 x17 0000007d29d567b4 x18 0000000000000001 x19 0000007b60578d70
11-01 15:05:45.333 6493 6560 E CRASH : x20 0000007c91601e40 x21 0000007c95f17940 x22 0000007b605794a0 x23 0000000000000002
11-01 15:05:45.333 6493 6560 E CRASH : x24 0000000000000000 x25 0000000000002000 x26 0000007b80027ba0 x27 0000007be0088bd0
11-01 15:05:45.333 6493 6560 E CRASH : x28 0000007bc07797d0 x29 0000007b60578cb0
11-01 15:05:45.333 6493 6560 E CRASH : sp 0000007b60578c50 lr 0000007c41b7524c pc 0000007b6742dcc8
11-01 15:05:45.333 6493 6560 E CRASH :
11-01 15:05:45.333 6493 6560 E CRASH : backtrace:
11-01 15:05:45.333 6493 6560 E CRASH : #00 pc 000000000026ccc8 /data/app/com.Csound.Test-lo4PgJjjAfsUeMgE44Hvug==/lib/arm64/libcsoundandroid.so (csoundSetSpinSample+12) (BuildId: 14bbe369e9bc5e6498d049a0e144a3372a150e22)
11-01 15:05:45.333 6493 6560 E CRASH : #01 pc 0000000000fe8248 /data/app/com.Csound.Test-lo4PgJjjAfsUeMgE44Hvug==/lib/arm64/libil2cpp.so (NativeMethods_csoundSetSpinSample_mF7A89FFC10454CF7F2D0BE05694253C484D78268+252) (BuildId: 2ff3326a81e4d22fe3bded84ccbbdc4144919a24)
11-01 15:05:45.333 6493 6560 E CRASH : #02 pc 0000000000fdc540 /data/app/com.Csound.Test-lo4PgJjjAfsUeMgE44Hvug==/lib/arm64/libil2cpp.so (CsoundUnityBridge_SetSpinSample_mD4AF12A794A5BA0194CB9C9E5CC62C5344DF7F6B+96) (BuildId: 2ff3326a81e4d22fe3bded84ccbbdc4144919a24)
11-01 15:05:45.333 6493 6560 E CRASH : #03 pc 0000000000fdc4d0 /data/app/com.Csound.Test-lo4PgJjjAfsUeMgE44Hvug==/lib/arm64/libil2cpp.so (CsoundUnity_SetInputSample_mC4187BF5A5B0A3F7C3BEA0595A6BA7E976D8F00E+104) (BuildId: 2ff3326a81e4d22fe3bded84ccbbdc4144919a24)
11-01 15:05:45.333 6493 6560 E CRASH : #04 pc 0000000000fe26d0 /data/app/com.Csound.Test-lo4PgJjjAfsUeMgE44Hvug==/lib/arm64/libil2cpp.so (CsoundUnity_ProcessBlock_m0493C335537E17342199F175DC5E5F2BF5E47007+1968) (BuildId: 2ff3326a81e4d22fe3bded84ccbbdc4144919a24)
11-01 15:05:45.333 6493 6560 E CRASH : #05 pc 0000000000fe1f10 /data/app/com.Csound.Test-lo4PgJjjAfsUeMgE44Hvug==/lib/arm64/libil2cpp.so (CsoundUnity_OnAudioFilterRead_m9D443FB12057838CBCDAC8BE372ED64A0E1B54DB+112) (BuildId: 2ff3326a81e4d22fe3bded84ccbbdc4144919a24)

@rorywalsh what do you think?
@PedroSodre I will investigate further and let you know when we find a solution.

Hi @giovannibedetti, this looks like an issue with the csoundGetSpout() and csoundGetSpin(). Haven’t we come across this before?

Yes, but it looks like a different situation.
Steven suggested to check the number of channels, indeed I was trying to read a MONO file as a STEREO file.
But after changing the csd to this:

<Cabbage> bounds(0, 0, 0, 0)
form caption("Process Clip") size(400, 300)
rslider bounds(0, 0, 77, 87) channel("gain") range(0, 2, 1, 1, 0.001)  valueTextBox(1) text("gain") 
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d 
</CsOptions>
<CsInstruments>
nchnls = 2
nchnls_i = 1
0dbfs = 1

instr 1
ain inch 1
kGain chnget "gain"
outs ain*kGain, ain*kGain
endin
</CsInstruments>
<CsScore>
f0 z
i1 0 [24*60*60]
</CsScore>
</CsoundSynthesizer>

I still have the crash. What I noticed in the crash log is this line, returned after calling csound start:

calloc(18446744065726316560, 1) failed: returning null pointer

Could it be something wrong inside the inch opcode?

Try in?

1 Like

Awesome!
in made the trick!
We should write a warning in the docs… :thinking:
@PedroSodre use in instead of inch

This is a working example with a MONO file in input

<Cabbage> bounds(0, 0, 0, 0)
form caption("Process Clip") size(400, 300)
rslider bounds(0, 0, 77, 87) channel("gain") range(0, 2, 1, 1, 0.001)  valueTextBox(1) text("gain") 
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d 
</CsOptions>
<CsInstruments>
nchnls = 2
nchnls_i = 1
0dbfs = 1

instr 1
ain in 1
kGain chnget "gain"
outs ain*kGain, ain*kGain
endin
</CsInstruments>
<CsScore>
f0 z
i1 0 [24*60*60]
</CsScore>
</CsoundSynthesizer>

:rofl: We got lucky this time!!

1 Like