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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#ifndef UDO_AODB
#define UDO_AODB ##
/*
AudioOrganiser SQLite connection and tools
This file is part of the SONICS UDO collection by Richard Knight 2023
License: GPL-2.0-or-later
http://1bpm.net
*/
#include "__config__.udo"
#include "host_tools.udo"
#define USING_AODB ##
if (gihost_type == 0) then
giaodb dbconnect "sqlite", "$AODB_PATH_WIN"
else
giaodb dbconnect "sqlite", "$AODB_PATH_LINUX"
endif
opcode _aodb_formatquery, S, Sip
Slike, irandomorder, inumber xin
xout sprintf("SELECT id, path FROM audiofile WHERE path LIKE 'd:\\Samples\\%%%s%%' %s LIMIT %d", Slike, (irandomorder == 1 ? "ORDER BY RANDOM()" : ""), inumber)
endop
opcode aodb_getsample, iS, Sp
Slike, irandomorder xin
Sres[][] dbarray giaodb, _aodb_formatquery(Slike, irandomorder)
id strtod Sres[0][0]
Spath = Sres[0][1]
xout id, Spath
endop
opcode aodb_getsample, S, Sp
Slike, irandomorder xin
id, Spath aodb_getsample Slike, irandomorder
xout Spath
endop
opcode aodb_loadsample, i, Spp
Slike, irandomorder, imono xin
Spath aodb_getsample Slike, irandomorder
ifn ftgen 0, 0, 0, 1, Spath, 0, 0, imono
xout ifn
endop
opcode aodb_diskinsample, aa, Sp
Slike, irandomorder xin
id, Spath aodb_getsample Slike, irandomorder
ichannels filenchnls Spath
if (ichannels == 1) then
aL diskin Spath, 1
aR = aL
else
aL, aR diskin Spath, 1
endif
xout aL, aR
endop
opcode aodb_getsamples, S[], Sip
Slike, inumber, irandomorder xin
Sout[] init inumber
Sres[][] dbarray giaodb, _aodb_formatquery(Slike, irandomorder, inumber)
index = 0
while (index < lenarray(Sres)) do
Sout[index] = Sres[index][1]
index += 1
od
xout Sout
endop
opcode aodb_getsamplebyid, S, i
id xin
Sres dbscalar giaodb, sprintf("SELECT path FROM audiofile WHERE id = %d", id)
xout Sres
endop
#end
|