What would you use for string/bang in CsoundUnity?

So I built a simple csound patch for CsoundUnity. Im looking for a way to send a message/string/bang/something that Unity can recognize, that will tell me when its done playing the sound. Im using transeg for the envelope, and ideally something will send a string/number once the envelope is done.

any suggestion what I can use to achieve that?

You can send a trigger signal over a channel and then set up some kind of polling system in Unity that listens for changes to the channel. @g_b just added support for channel callbacks, but it doesn’t look like they will continue to be supported in newer versions of Csound, so perhaps they should be avoided.

Yes the callback system only lives in a branch (GitHub - rorywalsh/CsoundUnity at channelCallbacks, CALLBACKS region here: CsoundUnity/CsoundUnity.cs at a42f659bd473d4d453da8ba9d9e210c87f209f9a · rorywalsh/CsoundUnity · GitHub) but it’s not been merged into master because from Csound 7 they won’t be available anymore, so it didn’t make sense to add them.

@Sh_dev you can try something like this:

// C#
var channelTrigger = CsoundUnity.GetChannel("channelTrigger");
if(channelTrigger == 1)
{
    // reset the trigger
    CsoundUnity.SetChannel("channelTrigger", 0);
    // execute your code
}
; Csound code

instr 1

itim = 3				;set the envelope time

clock: 
   timout 0, itim, trig
   reinit clock

trig:
   chnset 1, "channelTrigger"
   prints "trigger!\n"

endin

(warning, code not tested)