#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