aboutsummaryrefslogtreecommitdiff
path: root/examples/1-sqlite-basic.csd
diff options
context:
space:
mode:
Diffstat (limited to 'examples/1-sqlite-basic.csd')
-rw-r--r--examples/1-sqlite-basic.csd41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/1-sqlite-basic.csd b/examples/1-sqlite-basic.csd
new file mode 100644
index 0000000..8177d4a
--- /dev/null
+++ b/examples/1-sqlite-basic.csd
@@ -0,0 +1,41 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac
+</CsOptions>
+<CsInstruments>
+/*
+ EXAMPLE 1
+
+ print some data from a sqlite3 database at i-rate
+
+
+*/
+
+sr = 44100
+kr = 4410
+nchnls = 2
+0dbfs = 1
+seed 0
+
+; sqlite3 takes a file path, or :memory: for a temporary in-memory database
+; gidb dbconnect "sqlite", "/tmp/example.db"
+gidb dbconnect "sqlite", ":memory:"
+
+instr start_example
+
+ ; print a random value
+ ires1 dbscalar gidb, "SELECT RANDOM()"
+ print ires1
+
+ ; print the second column (1) of the first row (0)
+ ires2 dbscalar gidb, "SELECT 99, 98", 0, 1
+ print ires2
+endin
+
+
+</CsInstruments>
+<CsScore>
+i "start_example" 0 1
+
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file