From 9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 13 Apr 2025 18:48:02 +0100 Subject: initial --- site/udo/soundxdb_extract.udo | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 site/udo/soundxdb_extract.udo (limited to 'site/udo/soundxdb_extract.udo') diff --git a/site/udo/soundxdb_extract.udo b/site/udo/soundxdb_extract.udo new file mode 100755 index 0000000..64899c8 --- /dev/null +++ b/site/udo/soundxdb_extract.udo @@ -0,0 +1,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 -- cgit v1.2.3