madskjeldgaard / portedplugins

A collection of plugins for the SuperCollider sound environment, all of which are ported / remixed from elsewhere
GNU General Public License v3.0
180 stars 13 forks source link

norm vadim resonance #21

Closed salkin-mada closed 3 years ago

salkin-mada commented 3 years ago

This is just a cozy cozy res val normalization PR. Close/Reject it at will :)~ First I just did a in0( Resonance * 4.0f ) in line 19 and 39 (VadimFilter.cpp). Though a mult of 4.0 on the .sc side gets the job done. Hacky. But normalized res values are nice.

salkin-mada commented 3 years ago

okay. yes we should do it on the cpp side instead. clipping or with a sc cpp linlin method?

template <typename T> T inline linlin(T x, T in_min, T in_max, T out_min, T out_max) {
    if (x <= in_min)
        return out_min;
    if (x >= in_max)
        return out_max;
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
madskjeldgaard commented 3 years ago

I think it is probably simplest to do what you did before ( * 4) on the input value but do it in the next function in the cpp file for this plugin and then wrap that in sc_clip (which is equivalent to clip in sclang) or sc_clip2 (which is equivalent to clip2 in sclang)

madskjeldgaard commented 3 years ago

the sc_clip functions are defined in the https://github.com/supercollider/supercollider/blob/develop/include/plugin_interface/SC_InlineBinaryOp.h headerfile which I think is already included in the plugin, otherwise include SC_InlineBinaryOp.h to make it work

madskjeldgaard commented 3 years ago

sorry - this was fixed in 0.3.0d on the c++ side. But thanks!!