summaryrefslogtreecommitdiff
path: root/objects/read-interp-slow.axo
diff options
context:
space:
mode:
Diffstat (limited to 'objects/read-interp-slow.axo')
-rw-r--r--objects/read-interp-slow.axo76
1 files changed, 76 insertions, 0 deletions
diff --git a/objects/read-interp-slow.axo b/objects/read-interp-slow.axo
new file mode 100644
index 0000000..2919a1f
--- /dev/null
+++ b/objects/read-interp-slow.axo
@@ -0,0 +1,76 @@
+<objdefs>
+ <obj.normal id="read interp slow" uuid="2c605953453ac59b4f0c9fb67024ec9e61ee3376" sha="4f975ff0db958aff6c52f01f837ad750a823625c">
+ <sDescription>delay read slow, linear interpolated</sDescription>
+ <author>Johannes Taelman</author>
+ <license>BSD</license>
+ <helpPatch>delay.axh</helpPatch>
+ <inlets>
+ <frac32buffer name="time" description="delay time (fraction of total delayline size)"/>
+ </inlets>
+ <outlets>
+ <frac32buffer name="out" description="wave"/>
+ </outlets>
+ <displays/>
+ <params>
+ <frac32.u.map name="time" noLabel="true"/>
+ </params>
+ <attribs>
+ <objref name="delayname"/>
+ </attribs>
+ <code.srate><![CDATA[
+ // delay
+ // saturate the delay sum to bit 27
+ // max is 0x07FFFFF
+
+//(ash (- (ash 1 23) 1) (* -1 (- 27 15)))
+ uint32_t tmp_d = __USAT(param_time + inlet_time,27);
+
+ // index for delayed input, strictly less than the write position in the delay line.
+ // What happens when writepos is 0? Is the delay line really a circular buffer?
+
+ /* LENGTHPOW =>
+ 256 (5.33ms) = 8
+ 512 (10.66ms) = 9
+ 1024 (21.33ms) = 10
+ 2048 (42.66ms) = 11
+ 4096 (85.33ms) = 12
+ 8192 (170ms) = 13
+ 16384 (341ms) = 14
+ 32768 (682ms) = 15
+(/ 32768.0 48000)
+48000 = 1000ms
+
+ ,*/
+ // Example: set LENGTHPOW to 12
+ // shift tmp_d right by (- 27 12) = 15
+ // This is supposed to give a number of samples in the past, before writepos
+ // As this runs in a loop over the input buffer we have BUFSIZE samples to process.
+ // Hence (- BUFSIZE + buffer_index -1) starts at -BUFSIZE and is the last sample at the end of the srate loop.
+ uint32_t tmp_di = attr_delayname.writepos - (tmp_d>>(27-attr_delayname.LENGTHPOW+1)) - BUFSIZE + buffer_index -1;
+
+ // get delayed value from delay line
+ int32_t tmp_a1 = attr_delayname.array[tmp_di&attr_delayname.LENGTHMASK]<<16;
+ // get next delayed value from delay line
+ int32_t tmp_a2 = attr_delayname.array[(tmp_di+1)&attr_delayname.LENGTHMASK]<<16;
+
+ // ? what does this value represent?
+ // shift tmp_d left by 18, then mask with max value.
+ uint32_t tmp_w1 = (tmp_d<<(attr_delayname.LENGTHPOW+3)) & 0x3FFFFFFF;
+
+ // ? opposite of w1
+ uint32_t tmp_w2 = (1<<30) - tmp_w1;
+
+ // is this what's happening?
+ // out = (tmp_a2 * tmp_w2) + (tmp_a1 * tmp_w1)
+
+ // multiply value with ...?
+ int32_t tmp_r = ___SMMUL(tmp_a1,tmp_w1);
+
+ // ?
+ // multiply the values from tmp_a2 and tmp_w2, then add the value of
+ // tmp_r to the most significant 32 bits of the product
+ tmp_r = ___SMMLA(tmp_a2,tmp_w2,tmp_r);
+ outlet_out= tmp_a1;//tmp_r;
+]]></code.srate>
+ </obj.normal>
+</objdefs>