Cabbage Logo
Back to Cabbage Site

csoundUnity noob questions

great! I’ve always wanted to test the Ableton Link plugin but I never had the time, please report here any findings!

another noob question, how do i receive String from csound into Unity? GetChannel?

There is a getStringChannel method in the Csound API, but I’m not sure it has been exposed in CsoundUnity? @giovannibedetti?

You’re right!
I was very surprised to discover it has never been implemented in CsoundUnity.
Will try to add it for version 3.5.0, hopefully I can work on that tomorrow

1 Like

seems not, thats why asking))

thats what i`m working on now https://youtu.be/vgOi-vijtuY
Granular mobile toy ( already made VST and AU). with HQ recording and hopefully ableton link sync in future.

That’s cool. Was it much work porting it from a Cabbage instrument? Or did you simply start from scratch in Unity?

i made csd 2 years ago, porting to Unity since 3 weeks now,was not easy to start , new to Unity aswell, my first attempt so its bit slow) hopefully this CSD was made old style (chnget cnhset) and was not necessary to rework everything from gabbageGet Set)

You can just write a wrapper for those functions. hang on, I might have something here…

Just include this file for example, which overrides most of those functions. It provides chnget/chnset versions, and dummy overrides for functions that are not needed.

;override all cabbage opcodes, which are not available in the RPi

opcode cabbageSet, 0,SSS 
  SChannel, SIdent, SValue xin
endop

opcode cabbageSet, 0,kSSk 
  kTrig, SChannel, SIdent, kValue xin
endop

opcode cabbageSet, 0,kSSiiii
  kTrig, SChannel, SIdent, i1, i2, i3, i4 xin
endop

opcode cabbageSet, 0,kSSkkkk
  kTrig, SChannel, SIdent, k1, k2, k3, k4 xin
endop

opcode cabbageSetValue, 0,SSk
  SChannel, SIdent, kTrig xin
  if kTrig == 1 then
    printf "Settgin string channel isn't supported yet", 1
  endif
endop


opcode cabbageSetValue, 0,Skk
  SChannel, kValue, kTrig xin
  if kTrig == 1 then
    chnset kValue, SChannel
  endif
endop

opcode cabbageSetValue, 0,Si
  SChannel, iValue xin
  chnset iValue, SChannel
endop

opcode cabbageSetValue, 0,Sk
  SChannel, kValue xin
  chnset kValue, SChannel
endop


opcode  cabbageGetValue, Sk,S 
  SChannel xin
  kRet init 0
  xout SChannel, kRet
endop


opcode cabbageGetValue, kk, S
  kTrig init 0
  SChannel xin
  kVal chnget SChannel
  xout kVal, (changed:k(kVal) == 1 ? 1 : 0)
endop

opcode cabbageGetValue, k, S
  kTrig init 0
  SChannel xin
  kVal chnget SChannel
  xout kVal
endop
1 Like

I had some spare minutes so I quickly implemented the CsoundGetStringChannel method, you can find it in the 3.5.0 branch!
Let me know if it works ok, I just did a quick test and it seems to work. For example it could go mad with special characters, or very long strings.
Currently allocated string buffer length is 32768, should be enough for very large strings.There’s no quick way of finding the length of the returned string, so I had to create a large buffer. I hope to be wrong though :sweat_smile:

2 Likes

let you know soon

image
working. just not sure how to remove text() prefix here, and show just 1/16 …

ok its sorted) thanx Giovanni!! that was fast

1 Like