#ifndef UDO_AUTORECORD #define UDO_AUTORECORD ## /* Automatic sound file recorder using the monitor opcode This file is part of the SONICS UDO collection by Richard Knight 2021, 2024 License: GPL-2.0-or-later http://1bpm.net */ #include "host_tools.udo" #ifndef AUTORECORD_PATH if (gihost_type == 0) then gSautorecordPath = "d:/temp" else gSautorecordPath = "/tmp" endif #else gSautorecordPath = "$AUTORECORD_PATH" #end /* Auto file recorder usage - either in score: i"udo_autorecord" 0 5 or in instr globals: autorecord 5 */ #define MONTHIF(MS'MI) # isame strcmp "$MS", Smonth if (isame == 0) then Smonth = $MI goto monthdone endif # opcode autorecord, 0, aap aL, aR, istereo xin itim date Stim dates itim Sday strsub Stim, 8, 10 Shour strsub Stim, 11, 13 Smin strsub Stim, 14, 16 Ssec strsub Stim, 17, 19 Syear strsub Stim, 20, 24 Smonth strsub Stim, 4, 7 ichr strchar Sday if (ichr == 32) then Sday2 strsub Sday, 1, 2 Sday strcat "0", Sday2 endif $MONTHIF(Jan'"01") $MONTHIF(Feb'"02") $MONTHIF(Mar'"03") $MONTHIF(Apr'"04") $MONTHIF(May'"05") $MONTHIF(Jun'"06") $MONTHIF(Jul'"07") $MONTHIF(Aug'"08") $MONTHIF(Sep'"09") $MONTHIF(Oct'"10") $MONTHIF(Nov'"11") $MONTHIF(Dec'"12") monthdone: /* Smkdir = "mkdir -p " if (gihost_type != 0) then Smkdir = strcat(Smkdir, "-p ") endif ; make day dir Sdir sprintf "/%s%s%s", Syear, Smonth, Sday prints Sdir Sdaydir strcat Sbasedir, Sdir Scmd strcat Smkdir, Sdaydir ires system_i 1, Scmd Sfile sprintf "/%s%s%s.wav", Shour, Smin, Ssec Spath strcat Sdaydir, Sfile */ Spath sprintf "%s/%s-%s-%s.%s-%s-%s.wav", gSautorecordPath, Syear, Smonth, Sday, Shour, Smin, Ssec prints sprintf("\n----------------------------------------------------------------------------------------------------------\n Autorecording to %s\n----------------------------------------------------------------------------------------------------------\n", Spath) if (istereo == 1) then fout Spath, 14, aL, aR else fout Spath, 14, aL endif endop opcode autorecord, 0, a ain xin autorecord ain, ain, 0 endop instr autorecord aL, aR monitor autorecord aL, aR endin #end