From 1d055261b4144dbf86b2658437015b15d4dd9bff Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 4 Sep 2022 00:32:56 +0100 Subject: initial --- examples/example3.csd | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 examples/example3.csd (limited to 'examples/example3.csd') 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 + +*/ + + + Released into the public domain under the Unlicense license + http://unlicense.org/ + + +-d +-m0 + + +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 + + + + +f0 11 +i"write_values" 0 10 + + \ No newline at end of file -- cgit v1.2.3