Smoothing controller changes


#1

if i turn a poti/knob/midicontroller the "digital steps" are quite noticable. how can i smooth that? i was using a micro modular long time back. there are also 127 step controllers but those steps are not there so much audible. of course the mm is more towards a consumer-ready thing + much less objects/freedom ( the reasons why i prefer to use the axoloti) what can be done?


#2

There are smooth objects in the library, even an lp filter (blue in out) can do that


#3

you could use the k-rate filters for this, but as these are exponential smoothing, you might want to use a linear-glide.
This can be done by using the k-rate filter code, but then just limit the difference between input and filter and add this limited difference to the filter's value.
like this:

int32_t in=inlet_in;

int32_t dif=in-val;
if(dif>freq)
{
dif=freq;
}
else if(dif<-freq)
{
dif=-freq;
}
val+=dif;


#4

thanks a lot...i will test and report.
cheers


#5

...but could u explain a bit what the above does?...i have no programming background. just try and error and narrow field solutions..


#6

these codes work from right to left, so whatever is put right from the equal-sign, is put into the "holder" at the left.

int32_t in=inlet_in; <=puts the module-input into "in"

int32_t dif=in-val; <- calculates the difference between input and current glide-output
if(dif>freq) <-if difference is larger than the "freq" value, use the freq value instead (only when dif is positive)
{
dif=freq; <-put "freq" value into "dif"
}
else if(dif<-freq) <-else, if the difference is below the negative freq value, use the negative freq value.
{
dif=-freq;
}
val+=dif; <-add the difference to the glide value so it moves toward the new input value

the "freq" value is calculated with:
int32_t freq;
MTOF(-param_glide,freq)
if you use the simple k-rate lp filter, this is already there in the code and it already uses "val" as the glide-position.
So this code only has to be added after calculating this "freq" value.
If the glide is too fast, just put this in-between the MTOF(-param_glide,freq) and the rest of the code:
freq=freq>>2; (or some other value instead of two.. the bigger the value, the slower the glide)


#7

oh sorry, I just see that "freq" is just called "f" in the k-rate lowpass, so just write "f" instead..


#8

this one would perform better as I just found out:

int32_t freq;
MTOF(param_freq,freq);//calculate the "norm" glide rate

if(!(in==inlet_in))//update rate when input changes in comparison with last position
{
rate=__SMMUL(freq,inletin-val);//calculate needed change-rate
in=inlet_in;//update the "new position"
}

int32_t dif=inlet_in-val;//calculate the current difference between glided signal and input
dif=dif>0?dif:-dif;//fully rectify the difference, so it cannot go beyond the new position

if(rate>dif)//if the rate is higher then the difference between glide and goal value
{
rate=dif;//use the difference value instead of the rate to prevent it from going over
}
else if(rate<-dif)//if the rate is lower then the negative difference between glide and goal value
{
rate=-dif;//use the negative difference value instead of the rate to prevent it from going over
}

val+=rate;//add the rate to the current gliding value

outlet_out= val;//output glided value


#9

ok, one problem it seems... the function:
___SMMUL(....,....) can't be written down in this message box using a name with another underscore in it..
so I'll try writing that part on multiple lines here

rate=__SMMUL(freq,
inlet_in-val); //calculate needed change-rate


#10

i just came back to this and now startet testing. i had put your code in a duplicate of k rate low pass flt...and replaced the existing krate-code with it but like this it doesn't compile. low pass and smooth object already are quite effective...i still would like to use your code....its the first object where i start changing things inside ( though i do have arduino experiences)...could you give me some more advice how to get it working?


#11

the problem is that the textbox overhere mashes up the text when you use multiple underscores. So I can't really exactly write what you need to do, as it will just show up wrong. Go through the text to find the messed up words.
eg.
rate=__SMMUL(freq,inletin-val); should have one more underscore in front of it (3 underscores in total) and one between inlet and in

also, you need to declare "rate" like I declared the int32_t freq;


#12

how or where do i declare "rate"?

i see, if i type, rate=__SMMUL(freq,inletin-val);
in here it had swallowed 2 underscores...
why is that? ...but if one knows it...


#13

seems i found the answer myself...
it compiles ..but doesn't work.
i put in the krate code at the beginning...:maybe not exactly correct...

int32_t freq;
int32_t rate;
int32_t in;


#14

you don't need the "int32_t in;"
as the "in" was part of "inlet_in".
so now you're probably trying to get a value from something that isn't used.


#15

i read:
In member function 'void rootc::instancelow__1::dsp(int32_t, int32_t&, int, int)':
...
error: 'in' was not declared in this scope
if(!(in==inlet_in))

i am learning...
what is wrong?