aboutsummaryrefslogtreecommitdiff
path: root/examples/example3.csd
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2022-09-04 00:32:56 +0100
committerRichard <q@1bpm.net>2022-09-04 00:32:56 +0100
commit1d055261b4144dbf86b2658437015b15d4dd9bff (patch)
tree6049b19d1bf953a650383de1a5e438b8b82679f6 /examples/example3.csd
downloadcsound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.tar.gz
csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.tar.bz2
csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.zip
initial
Diffstat (limited to 'examples/example3.csd')
-rw-r--r--examples/example3.csd54
1 files changed, 54 insertions, 0 deletions
diff --git a/examples/example3.csd b/examples/example3.csd
new file mode 100644
index 0000000..7d02ea4
--- /dev/null
+++ b/examples/example3.csd
@@ -0,0 +1,54 @@
+/*
+ csound-json example 3
+
+ add values to an object at k-rate and print them after
+
+*/
+<CsoundSynthesizer>
+<CsLicence>
+ Released into the public domain under the Unlicense license
+ http://unlicense.org/
+</CsLicence>
+<CsOptions>
+-d
+-m0
+</CsOptions>
+<CsInstruments>
+sr = 44100
+ksmps = 64
+nchnls = 2
+0dbfs = 1
+
+
+instr write_values
+
+ ; create empty object
+ iJson jsoninit
+
+ ; insert some values to the object four times a second
+ kmetro metro 4
+ kindex init 1
+ if (kmetro == 1) then
+ jsoninsertvalk iJson, sprintfk("key%03d", kindex), kindex*random:k(1, 10)
+ kindex += 1
+ endif
+
+ ; print what has been inserted at the end
+ schedule "print_values", p3, 1, iJson
+endin
+
+
+instr print_values
+ iJson = p4
+
+ ; dump JSON and print
+ prints sprintf("%s\n\n", jsondumps(iJson))
+endin
+
+
+</CsInstruments>
+<CsScore>
+f0 11
+i"write_values" 0 10
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file