From 4a2d04c8cd3b4640084b41ca65a54a6615625ce9 Mon Sep 17 00:00:00 2001 From: Richard Knight Date: Sun, 31 Oct 2021 04:35:16 +0000 Subject: beta completion of BUG3 --- BUG3/oprepare.udo | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 BUG3/oprepare.udo (limited to 'BUG3/oprepare.udo') diff --git a/BUG3/oprepare.udo b/BUG3/oprepare.udo new file mode 100644 index 0000000..6350600 --- /dev/null +++ b/BUG3/oprepare.udo @@ -0,0 +1,92 @@ +#ifndef UDO_OPREPARE +#define UDO_OPREPARE ## +/* + Debugger - Unfixed Bugs : BUG #3 + + Offline preparation system: record a sound in one k-cycle to a ftable for future use + To be used where online playback would be too CPU heavy + In the case of BUG3, it is used for the 909 hi-hat + + Instruments to be prepared should be prepended with src_ +*/ + + +/* + Internal preparation instrument: loop through gSoprepare + p4 index of gSoprepare to process + p5 instrument name to schedule when all sounds have been prepared +*/ +gSoprepare[] init 1 ; filled by oprepare opcode: input instrument names without src_ prepended +giopreparedfns[] init 1 ; filled by oprepare opcode: output ftable numbers corresponding to above +instr _oprepare + iprepareindex = p4 + SonComplete = p5 + if (iprepareindex >= lenarray(gSoprepare)) then + event_i "i", SonComplete, 0, 3600 + turnoff + else + Sprepareinstr = gSoprepare[iprepareindex] + Srcinstr = sprintf("src_%s", Sprepareinstr) + ilen = 0.3 + p3 = ilen + ifn ftgen 0, 0, sr*ilen, 7, 0 + giopreparedfns[iprepareindex] = ifn + ktimek timeinstk + if (ktimek == 1) then + kcycles = ilen * kr + kcount init 0 +loop: + apos phasor (1/(ftlen(ifn)/sr)) + aproc subinstr Srcinstr, 1, 0.1 + tabw aproc, apos, ifn, 1 + loop_lt kcount, 1, kcycles, loop + elseif (ktimek == 5) then + scoreline_i sprintf("i\"_oprepare\" 0 1 %d \"%s\"", iprepareindex+1, SonComplete) + turnoff + endif + endif + +endin + + +/* + Start the offline preparation + + oprepare Snames[], SonComplete + + Snames[] list of instruments to process (instrument name without src_ prepended) + SonComplete instrument to be scheduled when preparation process has completed +*/ +opcode oprepare, 0, S[]S + Snames[], SonComplete xin + gSoprepare = Snames + giopreparedfns[] init lenarray(Snames) + scoreline_i sprintf("i\"_oprepare\" 0 1 0 \"%s\"", SonComplete) +endop + + +/* + Get the ftable number of a specified instrument name as originally passed to oprepare + + ifn oprepare_getfn Sname + + ifn the ftable + Sname name of offline-prepared instrument +*/ +opcode oprepare_getfn, i, S + Sname xin + ifn = -1 + index = 0 + while (index < lenarray(gSoprepare)) do + if (strcmp(gSoprepare[index], Sname) == 0) then + ifn = giopreparedfns[index] + endif + index += 1 + od +complete: + xout ifn +endop + + +#end + -- cgit v1.2.3