aboutsummaryrefslogtreecommitdiff
path: root/site/app/twine/_hOLD/timeline.csd
blob: 72e03ae66a5177d49646eceec3e7b2edffafb342 (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1
seed 0

#include "/scss/elasticlip_sequencer.udo"
;#include "/scss/mixer/base.udo"
#include "/interop.udo"
#include "/bussing.udo"
#include "/table_tools.udo"

opcode ecpweb_getdata, S, iii
	ichannel, iclipindex, itime xin
	Sname = gSecp_clipnames[iclipindex]
	Sresponse = sprintf("{\"-1\":%f,\"-2\":\"%s\",\"-4\":%d", itime, Sname, ichannel)

	index = 2
	while (index < giecp_controlitemnum) do
		ival = tab_i(index, giecp_fnclips[iclipindex])
		Sformat = strcat(",\"%d\":%", (frac(ival) == 0) ? "d" : "f")
		Sresponse = strcat(Sresponse, sprintf(Sformat, index, ival))
		index += 1
	od
	Sresponse = strcat(Sresponse, "}")
	xout Sresponse
endop

opcode ecpweb_getdata, S, i
	iseqindex xin
	ichannel, iclipindex, itime ecpseq_get iseqindex
	Sresponse ecpweb_getdata ichannel, iclipindex, itime
	xout Sresponse
endop

instr ecpweb_getdata
	icbid = p4
	iseqindex = p5
endin

instr ecpweb_tabdestroy
	ifn = p4
	tab_destroy ifn
	turnoff
endin

instr ecpweb_setbpm
	ibpm = p4
	gkseq_tempo init ibpm
	turnoff
endin

instr ecpweb_loadsound
	icbid = p4
	Spath = strget(p5)
	ichannel = p6
	itime = p7
	iforcemono = p8

	iclipindex ecp_loadsound Spath, 4, iforcemono ;beats contentious, analyse and also set warp mode
	iseqindex ecpseq_getnewindex

	ecpseq_set iseqindex, ichannel, iclipindex, itime
	Sdata ecpweb_getdata ichannel, iclipindex, itime

	ifnwave ecp_getwaveform iclipindex

	Sresponse = sprintf("{\"cbid\":%d,\"data\":%s,\"waveform\":%d}", icbid, Sdata, ifnwave)
	io_sendstring("callback", Sresponse)
	turnoff
endin


instr ecpweb_copyclip
	icbid = p4
	iseqindex = p5
	ichannel = p6
	itime = p7

	i_, iclipindex, i_ ecpseq_get iseqindex

	iseqindex ecpseq_getnewindex
	ecpseq_set iseqindex, ichannel, iclipindex, itime
	Sresponse = sprintf("{\"cbid\":%d}", icbid)
	io_sendstring("callback", Sresponse)
endin


instr ecpweb_setdata
	icbid = p4
	iseqindex = p5
	idataindex = p6
	;p7 is value
	ihastwin = p8

	Sresponse = sprintf("{\"cbid\":%d", icbid)
	iapplyupdate = 0
	ichannel, iclipindex, itime ecpseq_get iseqindex

	if (ihastwin == 1 && idataindex != -1) then
		iclipindex ecp_cloneclip iclipindex
		Sresponse = strcat(Sresponse, sprintf(",\"clipindex\":%d", iclipindex))  ; needed?
	endif

	if (idataindex < 0) then
		if (idataindex == -2) then  ;name
			Sname = strget(p7)
			ecp_set_name iclipindex, Sname
			Sresponse = strcat(Sresponse, sprintf(",\"name\":\"%s\"", Sname))
		elseif (idataindex == -1) then  ;position
			itime = p7
			iapplyupdate = 1
		elseif (idataindex == -4) then  ;channel
			ichannel = p7
			iapplyupdate = 1
		endif

	elseif (idataindex >= 2) then
		ivalue = p7
		tabw_i ivalue, idataindex, giecp_fnclips[iclipindex]
	endif

	if (iapplyupdate == 1) then
		ecpseq_set iseqindex, ichannel, iclipindex, itime
	endif

	io_sendstring("callback", strcat(Sresponse, "}"))
	turnoff
endin

instr boot
	schedule("mx_boot", 0, 1)

	aL0, aR0 bus_read "mxchan0"
	aL1, aR1 bus_read "mxchan1"
	aL2, aR2 bus_read "mxchan2"
	aL3, aR3 bus_read "mxchan3"

	aoutL = aL0 + aL1 + aL2 + aL3
	aoutR = aR0 + aR1 + aR2 + aR3
	outs aoutL, aoutR
endin

</CsInstruments>
<CsScore>
i"boot" 0 36000
f0 z
</CsScore>
</CsoundSynthesizer>