detecting change to pass a value with a threshold

    MaxMSPadvanced

    Tim Rohde's icon
    Tim Rohde's icon
    Tim Rohde
    Feb 22 2022 | 1:58 pm
    Hi, I'm doing a project for uni, for which I'm using an arduino. Because of the load of the components or sth. the values coming into max are changing, which is not good because I've implemented a shift funktion. So all values, which are using shift, are overwritten, when I press shift. I tried to use a smaller quantization, but there are obviously still changes in some cases. I need like a filter, that detects a change of like 6 steps before it passes a value. I provided a drawing fo the problem.

    • Tim Rohde's icon
      Tim Rohde's icon
      Tim Rohde
      Feb 22 2022 | 1:59 pm
      I tried to build a filter like this with a counter and a gate, but it doesn't work at all. Also I tried smoothing with line, but that doesn't solve anything either.
      Share
    • Tim Rohde's icon
      Tim Rohde's icon
      Tim Rohde
      Feb 22 2022 | 2:12 pm
      So this would be the counter. How do I detect, that there is there is no more change?
    • double_UG's icon
      double_UG's icon
      double_UG
      Feb 22 2022 | 2:13 pm
      cycle 6
      Max Patcher
      In Max, select New From Clipboard.
      Show Text
    • Tim Rohde's icon
      Tim Rohde's icon
      Tim Rohde
      Feb 22 2022 | 2:13 pm
      I guess I could do this with a delay, which is driven by the bangs generated by the dial, but if someone has a better idea, I'd like to know. My idea seems a little to complicated
    • Tim Rohde's icon
      Tim Rohde's icon
      Tim Rohde
      Feb 22 2022 | 2:14 pm
      @DOUBLE_UG thank you very much. didn't know this one.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Feb 22 2022 | 9:29 pm
      I'm just wondering if we have understood your question properly? When you say "steps", do you mean sequencer or timing steps or are you actually referring to the output value of the dial.
      I can imagine a scenario where the output of the dial is flickering in a small range, say between 97 and 103, and that you want to filter this minor variation out but that you then want to capture the larger changes. If that is what you mean then this would do the trick:
      Max Patcher
      In Max, select New From Clipboard.
      The threshold for the filter can be set in the number object at the top (set to 5 in the example). The gate at the bottom is controlled by the clock/counter in the middle. Essentially, once the threshold has been exceeded, the dial output will be passed through the gate for at least one second (set by the second argument of the counter in tenths of a second) and all the while the changes in the dial value exceed the threshold (done by resetting the counter to 1 every time the bang is triggered by the if statement).
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Feb 23 2022 | 10:15 am
      if you problem is analog input jitter or fluctuations, then you should do the filtering in arduino, then send clean 0 - 127 to max. If you can't do so, then rather send full 0 - 1023 scale and do filtering in max, and then scale to 0 - 127 Goal is to receive full range 0 - 127 without values being droped because of the filter.
    • Tim Rohde's icon
      Tim Rohde's icon
      Tim Rohde
      Feb 23 2022 | 6:32 pm
      jitterfilter.maxpat
      text/plain 11.62 KB
      I've solved like this and it kind of works, but it's not at all perfect. I've handed the patch in today though, but thanks for the advise.
    • Tim Rohde's icon
      Tim Rohde's icon
      Tim Rohde
      Feb 25 2022 | 10:13 am
      @ANDY MASKELL Sry, haven't read your post. The potentiometer had very bad flickering and I wanted to filter this out. And it was changing between values, when I use the switches aswell. That was a range from like 4-6. Thank you for your idea. It's way better than mine :D