Cabbage Logo
Back to Cabbage Site

Timer/Timeout in Sound


I have a variable, that gets set by an incoming osc message. If there is no incoming osc message for a certain time, I want to set it to 0. Is there a more elegant solution than the following code?

instr 1
    kvar init 0
    kcount init 1000
    kk OSClisten gihandle, "/adress", "f", kvar
    if (kk == 0) goto ex
        print 0, kvar
        kcount = 1000
        kgoto nxtmsg
    kcount = count - 1
    if (kcount == 0) then
          kvar = 0

    outletk "outlet", kvar

This approach seems fine to me. You could also trigger a dummy instrument with an event opcode, and then check when it’s finished using the active opcode, but all roads lead the same way. :slight_smile: