1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#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
|