aboutsummaryrefslogtreecommitdiff
path: root/BUG3/oprepare.udo
diff options
context:
space:
mode:
authorRichard Knight <q@1bpm.net>2021-10-31 04:35:16 +0000
committerRichard Knight <q@1bpm.net>2021-10-31 04:35:16 +0000
commit4a2d04c8cd3b4640084b41ca65a54a6615625ce9 (patch)
treede4439781c46e99f52944e0eb586abc6ae30e0ef /BUG3/oprepare.udo
parentff5405cc2fd290d3d6715fb58e1ee5a6569b85e0 (diff)
downloadcsd-unfixedbugs1-4a2d04c8cd3b4640084b41ca65a54a6615625ce9.tar.gz
csd-unfixedbugs1-4a2d04c8cd3b4640084b41ca65a54a6615625ce9.tar.bz2
csd-unfixedbugs1-4a2d04c8cd3b4640084b41ca65a54a6615625ce9.zip
beta completion of BUG3
Diffstat (limited to 'BUG3/oprepare.udo')
-rw-r--r--BUG3/oprepare.udo92
1 files changed, 92 insertions, 0 deletions
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
+