Cabbage Logo
Back to Cabbage Site

[CsoundUnity] Loading Midi files

I’m trying to load a midi file in CsoundUnity, but the Unity editor crashes with this stack:

0x00007FFD3E7C541E (csound64) csoundGetRandomSeedFromTime
0x00007FFD3E7C7B97 (csound64) csoundPerformKsmps
0x00000203B8C6AA1A (Mono JIT Code) (wrapper managed-to-native) Csound.Unity.CsoundCSharp.Csound6/NativeMethods:csoundPerformKsmps (intptr)
0x00000203B8C6A63B (Mono JIT Code) [CsoundUnity\Runtime\CsoundUnityBridge.cs:247] Csound.Unity.CsoundUnityBridge:PerformKsmps () 
0x00000203B8C69E53 (Mono JIT Code) [CsoundUnity\Runtime\CsoundUnity.cs:750] Csound.Unity.CsoundUnity:PerformKsmps () 
0x00000203B8C64CDB (Mono JIT Code) [CsoundUnity\Runtime\CsoundUnity.cs:2206] Csound.Unity.CsoundUnity:ProcessBlock (single[],int) 
0x00000203B8C629F3 (Mono JIT Code) [CsoundUnity\Runtime\CsoundUnity.cs:2177] Csound.Unity.CsoundUnity:OnAudioFilterRead (single[],int) 

I’m simply using the -F option, after copying the midi file in the PersistentDataPath, and adding the environment setting to point to that folder.

Could I miss a midi library maybe?

I tried calling the csoundGetRandomSeedFromTime method and it returns correctly a value like:

time: 2835645027

It would be nice adding some support for Midi on Unity. Any idea?

Is midi handled by portmidi? Perhaps that library is not being found? TBH, I’m not sure it’s worth the effort. Reading MIDI files in Csound sucks.