@@ -102,7 +102,7 @@ int32_t __not_in_flash_func(buffer_read)(buffer *db, uint16_t tapId, uint16_t t)
102102 return db -> buffer [(t + db -> readOffset [tapId ]) & db -> mask ];
103103}
104104
105-
105+ typedef int32_t multiplier_type ;
106106
107107// Allpass filter
108108int32_t __not_in_flash_func (allpass_process )(buffer * db , uint16_t t , int32_t gain , int32_t in )
@@ -113,11 +113,11 @@ int32_t __not_in_flash_func(allpass_process)(buffer *db, uint16_t t, int32_t gai
113113 gain >>= 4 ;
114114
115115 int32_t delayed = buffer_read (db , TAP_MAIN , t );
116- in += ((delayed * - gain ) >> 12 );
116+ in += ((delayed * - gain + 2048 ) >> 12 );
117117 // in = clamp(in, -16383, 16383);
118118
119119 buffer_write (db , t , in );
120- return delayed + ((in * gain ) >> 12 );
120+ return delayed + ((in * gain + 2048 ) >> 12 );
121121}
122122
123123
@@ -131,14 +131,14 @@ where f_s is the sample rate
131131*/
132132int32_t __not_in_flash_func (lowpass_process )(int32_t * out , int32_t b , int32_t in )
133133{
134- * out += (((in - * out ) * b ) >> 16 );
134+ * out += (((in - * out ) * b + 32768 ) >> 16 );
135135 return * out ;
136136}
137137
138138// Highpass, as above
139139int32_t __not_in_flash_func (highpass_process )(int32_t * out , int32_t b , int32_t in )
140140{
141- * out += (((in - * out ) * b ) >> 16 );
141+ * out += (((in - * out ) * b + 32768 ) >> 16 );
142142 return in - * out ;
143143}
144144
@@ -357,16 +357,18 @@ void __not_in_flash_func(reverb_process)(reverb *v, int32_t in)
357357 // This almost certainly doesn't eliminate wrapping entirely, but helps avoid it
358358 for (int i = 0 ; i < 2 ; i ++ )
359359 {
360- // ~23Hz input HPF, to cancel any input DC offset
361- if (i == 0 )
362- x1 = highpass_process (& v -> acCouplingHPF , 200 , x );
363- else
364- x1 = x ;
365360
366361 // Add cross feedback
367- x1 = x1 + ((buffer_read (& v -> postDampingDelay [1 - i ], TAP_MAIN , v -> t ) * v -> decayAmount ) >> 16 );
362+ x1 = x + ((buffer_read (& v -> postDampingDelay [1 - i ], TAP_MAIN , v -> t ) * v -> decayAmount ) >> 16 );
368363 x1 = clamp (x1 , -16383 , 16383 );
369364
365+ // 11 Hz DC-blocking HPF once within figure-of-eight
366+ if (i == 0 )
367+ {
368+ x1 = highpass_process (& v -> acCouplingHPF , 100 , x1 );
369+ x1 = clamp (x1 , -16383 , 16383 );
370+ }
371+
370372 // Process single half of the tank
371373 x1 = allpass_process (& v -> decayDiffusion1 [i ], v -> t , - v -> decayDiffusion1Amount , x1 );
372374 // x1 = clamp(x1, -16383, 16383);
0 commit comments