31 #ifndef verblib_max_sample_rate_multiplier
32 #define verblib_max_sample_rate_multiplier 4
36 #ifndef verblib_silence_threshold
37 #define verblib_silence_threshold 80.0
58 void verblib_process (
verblib* verb,
const float* input_buffer,
float* output_buffer,
unsigned long frames );
126 #define verblib_numcombs 8
127 #define verblib_numallpasses 4
128 #define verblib_muted 0.0f
129 #define verblib_fixedgain 0.015f
130 #define verblib_scalewet 3.0f
131 #define verblib_scaledry 2.0f
132 #define verblib_scaledamp 0.8f
133 #define verblib_scaleroom 0.28f
134 #define verblib_offsetroom 0.7f
135 #define verblib_initialroom 0.5f
136 #define verblib_initialdamp 0.25f
137 #define verblib_initialwet 1.0f/verblib_scalewet
138 #define verblib_initialdry 0.0f
139 #define verblib_initialwidth 1.0f
140 #define verblib_initialmode 0.0f
141 #define verblib_freezemode 0.5f
142 #define verblib_stereospread 23
148 #define verblib_combtuningL1 1116
149 #define verblib_combtuningR1 (1116+verblib_stereospread)
150 #define verblib_combtuningL2 1188
151 #define verblib_combtuningR2 (1188+verblib_stereospread)
152 #define verblib_combtuningL3 1277
153 #define verblib_combtuningR3 (1277+verblib_stereospread)
154 #define verblib_combtuningL4 1356
155 #define verblib_combtuningR4 (1356+verblib_stereospread)
156 #define verblib_combtuningL5 1422
157 #define verblib_combtuningR5 (1422+verblib_stereospread)
158 #define verblib_combtuningL6 1491
159 #define verblib_combtuningR6 (1491+verblib_stereospread)
160 #define verblib_combtuningL7 1557
161 #define verblib_combtuningR7 (1557+verblib_stereospread)
162 #define verblib_combtuningL8 1617
163 #define verblib_combtuningR8 (1617+verblib_stereospread)
164 #define verblib_allpasstuningL1 556
165 #define verblib_allpasstuningR1 (556+verblib_stereospread)
166 #define verblib_allpasstuningL2 441
167 #define verblib_allpasstuningR2 (441+verblib_stereospread)
168 #define verblib_allpasstuningL3 341
169 #define verblib_allpasstuningR3 (341+verblib_stereospread)
170 #define verblib_allpasstuningL4 225
171 #define verblib_allpasstuningR4 (225+verblib_stereospread)
235 #ifdef VERBLIB_IMPLEMENTATION
241 #define VERBLIB_INLINE __forceinline
244 #define VERBLIB_INLINE inline __attribute__((always_inline))
246 #define VERBLIB_INLINE inline
250 #define undenormalise(sample) sample+=1.0f; sample-=1.0f;
253 static void verblib_allpass_initialize (
verblib_allpass* allpass,
float* buf,
int size )
260 static VERBLIB_INLINE
float verblib_allpass_process (
verblib_allpass* allpass,
float input )
266 undenormalise ( bufout );
268 output = -input + bufout;
282 for ( i = 0; i < allpass->
bufsize; i++ )
284 allpass->
buffer[i] = 0.0f;
289 static void verblib_comb_initialize (
verblib_comb* comb,
float* buf,
int size )
300 for ( i = 0; i < comb->
bufsize; i++ )
306 static void verblib_comb_set_damp (
verblib_comb* comb,
float val )
309 comb->
damp2 = 1.0f - val;
312 static VERBLIB_INLINE
float verblib_comb_process (
verblib_comb* comb,
float input )
317 undenormalise ( output );
332 static void verblib_update (
verblib* verb )
339 verb->
wet2 = verb->
wet * ( ( 1.0f - verb->
width ) / 2.0f );
358 verblib_comb_set_damp ( &verb->
combL[i], verb->
damp1 );
359 verblib_comb_set_damp ( &verb->
combR[i], verb->
damp1 );
364 static void verblib_mute (
verblib* verb )
374 verblib_comb_mute ( &verb->
combL[i] );
375 verblib_comb_mute ( &verb->
combR[i] );
379 verblib_allpass_mute ( &verb->
allpassL[i] );
380 verblib_allpass_mute ( &verb->
allpassR[i] );
384 static int verblib_get_verblib_scaled_buffer_size (
unsigned long sample_rate,
unsigned long value )
386 long double result = (
long double ) sample_rate;
388 result = ( (
long double ) value ) * result;
393 return (
int ) result;
400 if ( channels != 1 && channels != 2 )
404 if ( sample_rate < 22050 )
457 verblib_mute ( verb );
462 void verblib_process (
verblib* verb,
const float* input_buffer,
float* output_buffer,
unsigned long frames )
465 float outL, outR, input;
469 while ( frames-- > 0 )
472 input = ( input_buffer[0] * 2.0f ) * verb->
gain;
477 outL += verblib_comb_process ( &verb->
combL[i], input );
483 outL = verblib_allpass_process ( &verb->
allpassL[i], outL );
487 output_buffer[0] = outL * verb->
wet1 + input_buffer[0] * verb->
dry;
496 while ( frames-- > 0 )
499 input = ( input_buffer[0] + input_buffer[1] ) * verb->
gain;
504 outL += verblib_comb_process ( &verb->
combL[i], input );
505 outR += verblib_comb_process ( &verb->
combR[i], input );
511 outL = verblib_allpass_process ( &verb->
allpassL[i], outL );
512 outR = verblib_allpass_process ( &verb->
allpassR[i], outR );
516 output_buffer[0] = outL * verb->
wet1 + outR * verb->
wet2 + input_buffer[0] * verb->
dry;
517 output_buffer[1] = outR * verb->
wet1 + outL * verb->
wet2 + input_buffer[1] * verb->
dry;
529 verblib_update ( verb );
540 verblib_update ( verb );
551 verblib_update ( verb );
572 verblib_update ( verb );
583 verblib_update ( verb );
606 return (
unsigned long ) decay;