diff options
author | Richard <q@1bpm.net> | 2022-09-04 00:32:56 +0100 |
---|---|---|
committer | Richard <q@1bpm.net> | 2022-09-04 00:32:56 +0100 |
commit | 1d055261b4144dbf86b2658437015b15d4dd9bff (patch) | |
tree | 6049b19d1bf953a650383de1a5e438b8b82679f6 /examples/example4.csd | |
download | csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.tar.gz csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.tar.bz2 csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.zip |
initial
Diffstat (limited to 'examples/example4.csd')
-rw-r--r-- | examples/example4.csd | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/examples/example4.csd b/examples/example4.csd new file mode 100644 index 0000000..b6bc78c --- /dev/null +++ b/examples/example4.csd @@ -0,0 +1,57 @@ +/* + csound-json example 4 + + fill JSON object with various data at init time + +*/ +<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 boot + + ; empty object + iJson jsoninit + + ; add key/value combination as "description" object + Skeys[] fillarray "colour", "taste", "smell" + Svalues[] fillarray "blue", "sweet", "vile" + iJsonSub1 jsoninit + jsoninsertval iJsonSub1, Skeys, Svalues + jsoninsert iJson, "description", iJsonSub1 + + ; add key/value combination and additional value to iJsonSub2 + Skeys[] fillarray "height", "width" + ivalues[] fillarray 35.4, 6.41 + iJsonSub2 jsoninit + jsoninsertval iJsonSub2, Skeys, ivalues + jsoninsertval iJsonSub2, "depth", 16.439 + + ; add iJsonSub2 to array along with new specified string objects + iJsonObjects[] fillarray iJsonSub2, jsonloads("{\"not\": \"much\"}"), jsonloads("[1,2,3]") + + ; add all of the above iJsonObjects back into the main object under "measurements" key + jsoninsert iJson, "measurements", iJsonObjects + + ; show the result + prints sprintf("%s\n\n", jsondumps(iJson)) +endin + + +</CsInstruments> +<CsScore> +i"boot" 0 1 +</CsScore> +</CsoundSynthesizer>
\ No newline at end of file |