Difficulty understanding how to use the DSP library in the SDK

Hi, I’m having some trouble understanding how I should be using the dsp::SlewLimiter class in the SDK. No matter what numbers I feed it, it always just increases the output to 10 over a differing period of time, but never descends. Could someone give me an example of how it’s supposed to work?

As I understand it you create a slew limiter

set the rise and file values in units/s (probably volts per second would be most common).

Then every sample you pass in the sample time (1/f) and your input signal to the process method.

The process method returns the output value of the slew limiter.

If your input is greater than the current value, the returned value will increase by no more than the rise limit.

If your input is less than the current value, the returned value will decrease by no more than the fall limit.

I had trouble with this the first time I tried to use it, the numbers you set in the slew should be in Hz

https://vcvrack.com/docs-v2/structrack_1_1dsp_1_1TSlewLimiter

An example:

  const float MS_1{1000.0f}; // 1000 Hz = 1 millisecond
  const float MS_5{200.0f};  // 200 Hz  = 5 milliseconds
  const float MS_10{100.0f}; // 100 Hz  = 10 milliseconds
  const float MS_25{40.0f};  // 40 Hz   = 25 milliseconds
  const float MS_50{20.0f};  // 20 Hz   = 50 milliseconds
  const float MS_100{10.0f}; // 10 Hz   = 100 milliseconds

rack::dsp::ExponentialSlewLimiter _slewFilter{};

_slewFilter.setRiseFall(MS_5, MS_100);

float slewedCvValue = _slewFilter.process(sampleTime, cvValue);
2 Likes

I think that’s a bit misleading.

The documentation is clear that it’s units/s If you set it in Hertz then over what timescale are you expecting a rise from 0 - 5 volts. It would take 5 milliseconds, and a rise from 0 - 10 volts would take 10 milliseconds.

I don’t see that trying to express that in Hertz is terribly useful.

setting it to 1000 is 1000v/s (if your slewedCvValue float represents volts)

Thanks for the explanation, that was just my previous understanding, the way I am using the slew means that the timescale is the same (I think)

anyway

The key part for me, was that the numbers you use in the setRiseFall method are inverse to how I think of a slew working, ie larger numbers are a shorter slew

This made sense to me for the UI, I think to a user, understanding that a slew operates over a certain number of milliseconds is much easier to understand than, say 1000 volts per second. Ok, it may not be 100% accurate to describe it that way, but I think intuitively to a user, lower numbers mean shorter slews.

2 Likes

I was definitely under the impression that lower numbers would mean shorter slew, and thinking about the number as Hz made sense and resulted in the behaviour I expected. For example, setting the rise/fall to SampleRate gave the expected behaviour of the slew limiter not affecting the sound.

Thank you for your help!