blob: 2919a1f29906c7c7e2acf8fb8dcec6dd7f39841a (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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>
|