File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,20 +41,28 @@ float PatchProcessor::getParameterValue(PatchParameterId pid){
4141 return 0 .0f ;
4242}
4343
44+ #define SMOOTH_HYSTERESIS
45+ #define SMOOTH_FACTOR 3
4446void PatchProcessor::setParameterValues (uint16_t *params){
4547 /* Implements an exponential moving average (leaky integrator) to smooth ADC values
4648 * y(n) = (1-alpha)*y(n-1) + alpha*y(n)
4749 * with alpha=0.5, fs=48k, bs=128, then w0 ~= 18hz
4850 */
4951 if (getProgramVector ()->hardware_version == OWL_MODULAR_HARDWARE){
5052 for (int i=0 ; i<NOF_ADC_VALUES; ++i)
51- if (abs (params[i]-parameterValues[i]) > 8 )
53+ #ifdef SMOOTH_HYSTERESIS
54+ if (abs (params[i]-parameterValues[i]) > 7 )
55+ #endif
5256 // invert parameter values for OWL Modular
53- parameterValues[i] = (parameterValues[i] + 0x1000 - params[i]) >> 1 ;
57+ parameterValues[i] = (parameterValues[i]*SMOOTH_FACTOR + 0x1000 - params[i])/(SMOOTH_FACTOR+ 1 ) ;
5458 }else {
5559 for (int i=0 ; i<NOF_ADC_VALUES; ++i)
56- if (abs (params[i]-parameterValues[i]) > 16 )
60+ #ifdef SMOOTH_HYSTERESIS
61+ if (abs (params[i]-parameterValues[i]) > 7 )
62+ #endif
5763 // 16 = half a midi step (4096/128=32)
58- parameterValues[i] = (parameterValues[i] + params[i]) >> 1 ;
64+ parameterValues[i] = (parameterValues[i]*SMOOTH_FACTOR + params[i])/(SMOOTH_FACTOR+ 1 ) ;
5965 }
66+ // for(int i=NOF_ADC_VALUES; i<NOF_PARAMETERS; ++i)
67+ // // todo!
6068}
You can’t perform that action at this time.
0 commit comments