Gen: Slope Detector

    Jun 22 2016 | 10:05 am
    i'm trying to make something like the Serge slope detector for a project ( and have gotten caught up on the implementation of the sensitivity parameter. This should "allow the slope detector to work with either relatively fast events, like the edges of a square wave pulse train, or very slow events, such as the sine output of an LFO being used to drive filter/phaser sweep", which to me souds like a downsampling of the input signal which could be done with a sample and hold. However, i can't get delta to respond to sah very well in the gen domain. Anyone have an idea of how to go about this? Here's the patch at the moment
    Cheers, Camilo.

    • Jun 23 2016 | 2:03 am
      The slope detector works using a capacitor which charges and discharges. I think you could emulate its behavior using something like rampsmooth~, the ramp inputs corresponding to the sensitivity knob.
      Here's my version written in a codebox in gen~, it's stripped down version of my try on emulating the serge slope generator. It seems the sensitivity has to carefully be tuned to the input... in other words, it doesn't work very well...
    • Jun 23 2016 | 2:18 am
      separating the rising and falling parameters allows to generate some nice rhythmic pulse. the good thing is it is always rhythmically related to the input.
    • Jun 23 2016 | 9:30 am
      cheers, Bertrandfraysse! I'm really impressed by the musicality of the example with individual rise and fall slew. Rhythms galore! I'm pretty new to gen, so i can't quite make out what is going on in the codebox, but will be looking into it. Is the algorithm based on Ken Stone's op amp implementation?
    • Jun 23 2016 | 11:43 am
      nice to hear that you like it. it's not an analog imitation, but an algorithmic imitation of the serge slope generator.
      here is a patch using the slope generator as a triggered envelope generator.
    • Jun 23 2016 | 11:54 am
      another version with two generators
    • Jun 23 2016 | 2:19 pm
      I think this one is better as a slope detector. The previous one were especially made to be triggered and of constant amplitude.
      You can use the following one as the smoothed section of the serge smooth/stepped generator.
    • Jun 25 2016 | 4:12 pm
      Thanks again for these examples, Bertrandfraysse. Would you mind commenting on what each section is doing in the patch or describing the algorithm? I would have thought all one needs is a simple lowpass filter and a derivative, but i'm very curious about your implementation.
    • Jun 26 2016 | 8:51 pm
      Yes, you are right a lowpass filter and a derivative will do what you want. Actually, this slope generator is kind of a lowpass filter.
      The last patch is the simpler, It's really like rampsmooth~ The second input, named rate is the increment to add or remove from the current output value (output). If the input > output, it adds the increment to the current output, and tells it's rising. If the input < output, it removes the increment to the current value, and tells it's falling. That's it.
      I hope it helps.
    • Jun 27 2016 | 5:30 pm
      Thanks again! while i also believe(d) that the idea with slew + derivative should work, i'm finding the response a bit limited (patch is at the end). As for the gen code (first example : slew for rise and fall separate), i did want to ask: what is the basic principle of using the History type throughout? is it a buffer that can be rewritten only when conditions are met or is it always the previous sample/ condition which is getting compared to the current?
    • Jun 27 2016 | 9:07 pm
      History can be used for two things, the first and most common one is to allow feedback.
      yes, it isa buffer that can be rewritten only when conditions are met. The if statements use independent values than the outside of the if, so history is a buffer allowing to store the value even if the condition is not met anymore. It's kind of a sample and hold.