aboutsummaryrefslogtreecommitdiff
path: root/examples/1-sqlite-basic.csd
blob: 8177d4a2990887a70bdd088ecca939b097c4f06a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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>