diff options
author | Richard <q@1bpm.net> | 2025-04-13 18:48:02 +0100 |
---|---|---|
committer | Richard <q@1bpm.net> | 2025-04-13 18:48:02 +0100 |
commit | 9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 (patch) | |
tree | 291bd79ce340e67affa755a8a6b4f6a83cce93ea /site/udo/aodb.udo | |
download | apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.gz apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.bz2 apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.zip |
initial
Diffstat (limited to 'site/udo/aodb.udo')
-rwxr-xr-x | site/udo/aodb.udo | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/site/udo/aodb.udo b/site/udo/aodb.udo new file mode 100755 index 0000000..c81c233 --- /dev/null +++ b/site/udo/aodb.udo @@ -0,0 +1,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
|