#ifndef UDO_ELASTICLIPSEQUENCER #define UDO_ELASTICLIPSEQUENCER ## ;#include "scss/mixer/base.udo" #include "scss/elasticlip.udo" #include "interop.udo" giecpseq_maxclipindex = 0 giecpseq_fn ftgen 0, 0, 5000, 7, 0 opcode ecpseq_getnewindex, i, 0 index = giecpseq_maxclipindex giecpseq_maxclipindex += 1 xout index endop opcode ecpseq_pack, i, iii ichannel, iclipindex, itime xin xout (ichannel * 100000) + iclipindex + (itime / 100) endop opcode ecpseq_unpack, iii, i iencoded xin ichannel = int(iencoded / 100000) iencoded = iencoded - ichannel * 100000 iclipindex = int(iencoded) itime = frac(iencoded) * 100 xout ichannel, iclipindex, itime endop opcode ecpseq_get, iii, i iseqindex xin ichannel, iclipindex, itime ecpseq_unpack tab_i(iseqindex, giecpseq_fn) xout ichannel, iclipindex, itime endop opcode ecpseq_set, 0, iiii iseqindex, ichannel, iclipindex, itime xin ipacked ecpseq_pack ichannel, iclipindex, itime tabw_i ipacked, iseqindex, giecpseq_fn endop instr ecpseq_alterclip iseqindex = p4 ichannel = p5 iclipindex = p6 itime = p7 ecpseq_set iseqindex, ichannel, iclipindex, itime endin instr ecpseq_rmclip iseqindex = p4 tabw_i 0, iseqindex, giecpseq_fn endin instr _ecpseq_notify icbid = p4 istate = p5 if (istate == 1) then Sstate = "playing" elseif (istate == 0) then Sstate = "stopped" endif io_sendstring("callback", sprintf("{\"cbid\":%d,\"state\":\"%s\"}", icbid, Sstate)) turnoff endin giecpseq_playbackcbid = -1 instr osctest a1 oscil 1, 440 a1 *= linseg(1, p3, 0) outs a1, a1 endin instr ecpseq_playclip icbid = p4 iclipid = p5 ival tab_i iclipid, giecpseq_fn ichannel, iclipindex, itime ecpseq_unpack ival schedule("ecp_playback", 0, 1, icbid, iclipindex) ;, sprintf("mxchan%d", ichannel)) turnoff endin instr ecpseq_play icbid = p4 istartbeat = p5 ibeattime = i(gkseq_beattime) imaxbeat = istartbeat index = 0 while (index < ftlen(giecpseq_fn)) do ival = tab_i(index, giecpseq_fn) if (ival > 0) then ichannel, iclipindex, itime ecpseq_unpack ival if (itime >= istartbeat) then irunbeat = itime - istartbeat if (irunbeat > imaxbeat) then imaxbeat = irunbeat endif schedule("ecp_playback", irunbeat * ibeattime, 1, -1, iclipindex) ;, sprintf("mxchan%d", ichannel)) endif endif index += 1 od schedule("_ecpseq_notify", 0, 1, icbid, 1) giecpseq_playbackcbid = icbid imaxtime = imaxbeat * ibeattime ktimek timeinsts if (ktimek > imaxtime) then schedulek("_ecpseq_notify", 0, 1, icbid, 0) turnoff endif endin instr ecpseq_stop icbid = giecpseq_playbackcbid turnoff2 "ecp_playback", 0, 1 turnoff3 "ecp_playback" schedule("_ecpseq_notify", 0, 1, icbid, 0) turnoff endin #end