aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRichard Knight <q@1bpm.net>2024-04-09 22:58:44 +0100
committerRichard Knight <q@1bpm.net>2024-04-09 22:58:44 +0100
commitd4701791a2d04ff52bea456ebb34f4d79819f97e (patch)
treec582c6b10b271c550c9618cb0d818c5b27a98620 /examples
downloadcsound-curl-d4701791a2d04ff52bea456ebb34f4d79819f97e.tar.gz
csound-curl-d4701791a2d04ff52bea456ebb34f4d79819f97e.tar.bz2
csound-curl-d4701791a2d04ff52bea456ebb34f4d79819f97e.zip
initialHEADmaster
Diffstat (limited to 'examples')
-rw-r--r--examples/get.csd68
-rw-r--r--examples/post.csd46
2 files changed, 114 insertions, 0 deletions
diff --git a/examples/get.csd b/examples/get.csd
new file mode 100644
index 0000000..d373025
--- /dev/null
+++ b/examples/get.csd
@@ -0,0 +1,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>
+
diff --git a/examples/post.csd b/examples/post.csd
new file mode 100644
index 0000000..21535bd
--- /dev/null
+++ b/examples/post.csd
@@ -0,0 +1,46 @@
+<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
+
+
+; issue a POST request at init time and display the output
+instr irate
+ prints "init time post: may cause audio dropout\n\n"
+ ires, Sres curlpost "http://csound.1bpm.net/_curl_plugin_example/post", "Hello from Csound"
+ print ires
+ prints Sres
+ prints "\n"
+ turnoff
+endin
+
+
+; issue a POST request at k-rate and display the output
+instr krate
+ prints "k-rate threaded post: should not affect audio\n\n"
+ kdone, kres, Sres curlpostk "http://csound.1bpm.net/_curl_plugin_example/post", "Hello from Csound"
+ if (kdone == 1) then
+ printf "res %d ; %s\n", kdone, kres, Sres
+ turnoff
+ endif
+endin
+
+</CsInstruments>
+<CsScore>
+i"oscil" 0 5
+i"irate" 1 1
+i"krate" 3 1
+</CsScore>
+</CsoundSynthesizer>
+