bang only on first change

Samelot's icon

Hi guys. I have a patch in which I would like to have a midi slider be divided into 5 different functions. I have successfully split the ranges, now all I need to do is drop out the constant banging which is still being sent from my slider's value and focus my attention only on changes between the ranges. I have seen people coming up with interesting ways to compare numbers, sending out a bang when they are equivalent, but only once.

I think I need to somehow keep track of the last number (split range) keeping it available and as the newest number is triggered perform some kind of comparative operation between the two. Any ideas?

Max Patch
Copy patch and select New From Clipboard in Max.

Here is my max patch

pdelges's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Maybe with a change, like this:

Rick's icon
Max Patch
Copy patch and select New From Clipboard in Max.

A [bucket] is one way to keep track of previous numbers.

Samelot's icon

wow, Thanks guys. Incorporating now

Jay Walker's icon

This is what I did to fire clips on new integer values, storing the last value used in the global scope.

var storeClipCount = null;

// Fire Clip Slot Function
function fireClipSlot(clipCount) {
    var clipCountScaled = Math.round((clipCount/127)-1);
    if (storeClipCount == clipCountScaled) {
        return;
        } else {
    log("ClipKnobValue", clipCountScaled);
    storeClipCount = clipCountScaled;
    var liveSet = new LiveAPI (dummyCallback, 'live_set view selected_track clip_slots ' + clipCountScaled)
liveSet.call("fire");
    }
}

tmhglnd's icon

I would make an integer scaling with [scale 0 127 0 5] and use a [change] (as mentioned above).

Max Patch
Copy patch and select New From Clipboard in Max.