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
|
#ifndef UDO_SOUNDDB_XPORT
#define UDO_SOUNDDB_XPORT ##
/*
SQL database extraction to be used with soundxdb.udo
This file is part of the SONICS UDO collection by Richard Knight 2022
License: GPL-2.0-or-later
http://1bpm.net
*/
#include "pgdb.udo"
/*
Extract UDO definition from database for specified collection(s), to be used with soundxdb.udo.
Permits using functionality of sounddb.udo without database connectivity.
The file output includes an include of soundxdb.udo, so only the resulting file needs to be included.
soundxdb_extract Sfile, Scollections [, iminnote=0]
Sfile file path to extract to
Scollections collection name, or multiple comma-separated (no whitespace) collection names
iminnote the minimum MIDI note number to extract (higher can save output space/text usage; lower notes (eg < 25) are not usually used)
*/
opcode soundxdb_extract, 0, SSo
Sfile, Scollections, iminnote xin
Sclause = ""
if (strindex(Scollections, ",") > 0) then
index = 1
Stemp = Scollections
while (index > 0) do
index strindex Stemp, ","
if (index > 0) then
Sclause strcat Sclause, sprintf("'%s',", strsub(Stemp, 0, index))
Stemp strsub Stemp, index+1
else
Sclause strcat Sclause, sprintf("'%s'", Stemp)
endif
od
else
Sclause = sprintf("'%s'", Scollections)
endif
Squery = sprintf("SELECT f_xdb_export(%d, %s)", iminnote, Sclause)
iwritelines = 50
Scache = ""
Sres[][] dbarray gidb, Squery
index = 0
while (index < lenarray(Sres)) do
Scache strcat Scache, Sres[index][0]
Scache strcat Scache, "\n"
if (index % iwritelines == 0) then
fprints Sfile, Scache
Scache = ""
endif
index += 1
od
fprints Sfile, Scache
Scache = ""
endop
#end
|