#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