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
|
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 64
nchnls = 2
0dbfs = 1
seed 0
#include "sequencing_melodic_persistence.udo"
opcode jsio_sendraw, 0, S
Smessage xin
prints "CBDT "
prints Smessage
prints "\n"
endop
gijsio_collections[][] init 20, 300
opcode jsio_getcollection
Scollection, SonComplete xin
endop
instr jsio_loadcollection
Sdata = strget(p4)
endin
gSjsioBuffer[] init 16
gijsioBufferMax = 0
gijsioBufferLock = 0
instr jsio_bufferadd
icbid = p4
Sstatus = strget(p5)
Sdetails = strget(p6)
if (gijsioBufferLock == 1) then
schedule(p1, 0.1, 1, icbid, Sstatus, Sdetails)
else
gijsioBufferLock = 1
Sitem = sprintf("{\"cbid\":%d", icbid)
if (strcmp(Sstatus, "") != 0) then
Sitem = strcat(Sitem, sprintf(",\"status\":\"%s\"", Sstatus))
endif
if (strcmp(Sdetails, "") != 0) then
Sitem = strcat(Sitem, sprintf(",\"details\":\"%s\"", Sdetails))
endif
gSjsioBuffer[gijsioBufferMax] = strcat(Sitem, "}")
gijsioBufferMax += 1
gijsioBufferLock = 0
endif
turnoff
endin
instr jsio_bufferflush
Schannel = strget(p4)
if (gijsioBufferLock == 1) then
schedule(p1, 0.1, 1, Schannel)
else
gijsioBufferLock = 1
if (gijsioBufferMax == 0) then
chnset "", Schannel
gijsioBufferLock = 0
else
index = 0
Soutput = "["
while (index < gijsioBufferMax) do
if (index > 0) then
Soutput = strcat(Soutput, ",")
endif
Soutput = strcat(Soutput, gSjsioBuffer[index])
index += 1
od
Soutput = strcat(Soutput, "]")
chnset Soutput, Schannel
gijsioBufferMax = 0
gijsioBufferLock = 0
endif
endif
turnoff
endin
</CsInstruments>
<CsScore>
i "jsio_bufferadd" 0 1
</CsScore>
</CsoundSynthesizer>
|