blob: d37302517a7ebcf8912a953bd628a7a22e485cc4 (
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
|
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
kr = 4410
nchnls = 2
0dbfs = 1
; basic oscillator to see how audio is affected
instr oscil
a1 oscil 0.1, 440
outs a1, a1
endin
; test the URL encoding opcode by encoding a string and printing
instr urlencode
Sinput = "<&>!>"
Sencoded curlurlencode Sinput
prints sprintf("Encoding '%s' to: ", Sinput)
; output contains % which confuses prints. So loop through and print each character accordingly
index = 0
while (index < strlen(Sencoded)) do
Schar = strsub(Sencoded, index, index + 1)
if (strcmp(Schar, "%") == 0) then
Schar = "%%"
endif
prints Schar
index += 1
od
prints "\n\n"
turnoff
endin
; issue a GET request at init time and display the output
instr irate
prints "init time get: may cause audio dropout\n\n"
ires, Sres curlget "http://csound.1bpm.net/_curl_plugin_example/get"
print ires
prints Sres
prints "\n"
turnoff
endin
; issue a GET request at k-rate and display the output
instr krate
prints "k-rate threaded get: should not affect audio\n\n"
kdone, kres, Sres curlgetk "http://csound.1bpm.net/_curl_plugin_example/get"
if (kdone == 1) then
printf "res %d ; %s\n", kdone, kres, Sres
turnoff
endif
endin
</CsInstruments>
<CsScore>
i"oscil" 0 5
i"urlencode" 0 1
i"irate" 1 1
i"krate" 3 1
</CsScore>
</CsoundSynthesizer>
|