Newbie question about fading positive and negative values

am.syn's icon

I try to build a dry / wet possibility with which I can process positive and negative values.
I have two values ​​to be blend.
The challenge is: 0. equals 1. but if I change the value to +0.5 this value should be +0.5.
If I should change the value to -0-5
I will copy the patcher script for a better understanding for what i mean :)

Cheers in advance….

{
    "patcher" :     {
        "fileversion" : 1,
        "appversion" :         {
            "major" : 7,
            "minor" : 3,
            "revision" : 4,
            "architecture" : "x64",
            "modernui" : 1
        }
,
        "rect" : [ 885.0, 399.0, 640.0, 480.0 ],
        "bglocked" : 0,
        "openinpresentation" : 0,
        "default_fontsize" : 12.0,
        "default_fontface" : 0,
        "default_fontname" : "Arial",
        "gridonopen" : 1,
        "gridsize" : [ 15.0, 15.0 ],
        "gridsnaponopen" : 1,
        "objectsnaponopen" : 1,
        "statusbarvisible" : 2,
        "toolbarvisible" : 1,
        "lefttoolbarpinned" : 0,
        "toptoolbarpinned" : 0,
        "righttoolbarpinned" : 0,
        "bottomtoolbarpinned" : 0,
        "toolbars_unpinned_last_save" : 0,
        "tallnewobj" : 0,
        "boxanimatetime" : 200,
        "enablehscroll" : 1,
        "enablevscroll" : 1,
        "devicewidth" : 0.0,
        "description" : "",
        "digest" : "",
        "tags" : "",
        "style" : "",
        "subpatcher_template" : "",
        "boxes" : [             {
                "box" :                 {
                    "id" : "obj-1",
                    "linecount" : 3,
                    "maxclass" : "comment",
                    "numinlets" : 1,
                    "numoutlets" : 0,
                    "patching_rect" : [ 306.25, 325.0, 166.0, 47.0 ],
                    "presentation_rect" : [ 311.25, 324.0, 0.0, 0.0 ],
                    "style" : "",
                    "text" : "The minus values works fine but the positive values didn`t work fine :)"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-66",
                    "linecount" : 3,
                    "maxclass" : "comment",
                    "numinlets" : 1,
                    "numoutlets" : 0,
                    "patching_rect" : [ 306.25, 265.0, 166.0, 47.0 ],
                    "style" : "",
                    "text" : "If $1 == 0. this value must be +1.0. If i set $1 to -0.5 or + 0.5 this level must be + 0.5"
                }

            }
,             {
                "box" :                 {
                    "format" : 6,
                    "id" : "obj-65",
                    "maxclass" : "flonum",
                    "maximum" : 1.0,
                    "minimum" : -0.5,
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 236.25, 271.0, 41.0, 22.0 ],
                    "style" : ""
                }

            }
,             {
                "box" :                 {
                    "format" : 6,
                    "id" : "obj-89",
                    "maxclass" : "flonum",
                    "maximum" : 1.0,
                    "minimum" : -0.5,
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 175.0, 224.5, 41.0, 22.0 ],
                    "style" : ""
                }

            }
,             {
                "box" :                 {
                    "format" : 6,
                    "id" : "obj-70",
                    "maxclass" : "flonum",
                    "maximum" : 1.0,
                    "minimum" : -0.5,
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 297.0, 224.5, 41.0, 22.0 ],
                    "style" : ""
                }

            }
,             {
                "box" :                 {
                    "fontname" : "Courier",
                    "fontsize" : 10.0,
                    "id" : "obj-31",
                    "maxclass" : "newobj",
                    "numinlets" : 1,
                    "numoutlets" : 1,
                    "outlettype" : [ "" ],
                    "patching_rect" : [ 297.0, 162.5, 95.0, 18.0 ],
                    "style" : "",
                    "text" : "expr 1.-$f1/1."
                }

            }
,             {
                "box" :                 {
                    "format" : 6,
                    "id" : "obj-26",
                    "maxclass" : "flonum",
                    "maximum" : 0.5,
                    "minimum" : -0.5,
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 175.0, 117.0, 39.0, 22.0 ],
                    "style" : ""
                }

            }
,             {
                "box" :                 {
                    "fontname" : "Courier",
                    "fontsize" : 12.0,
                    "id" : "obj-19",
                    "maxclass" : "newobj",
                    "numinlets" : 1,
                    "numoutlets" : 1,
                    "outlettype" : [ "" ],
                    "patching_rect" : [ 175.0, 162.5, 111.0, 20.0 ],
                    "style" : "",
                    "text" : "expr 1.+$f1/1."
                }

            }
],
        "lines" : [             {
                "patchline" :                 {
                    "destination" : [ "obj-89", 0 ],
                    "source" : [ "obj-19", 0 ]
                }

            }
,             {
                "patchline" :                 {
                    "destination" : [ "obj-19", 0 ],
                    "order" : 1,
                    "source" : [ "obj-26", 0 ]
                }

            }
,             {
                "patchline" :                 {
                    "destination" : [ "obj-31", 0 ],
                    "midpoints" : [ 184.5, 151.0, 306.5, 151.0 ],
                    "order" : 0,
                    "source" : [ "obj-26", 0 ]
                }

            }
,             {
                "patchline" :                 {
                    "destination" : [ "obj-70", 0 ],
                    "source" : [ "obj-31", 0 ]
                }

            }
,             {
                "patchline" :                 {
                    "destination" : [ "obj-65", 0 ],
                    "source" : [ "obj-70", 0 ]
                }

            }
,             {
                "patchline" :                 {
                    "destination" : [ "obj-65", 0 ],
                    "source" : [ "obj-89", 0 ]
                }

            }
],
        "dependency_cache" : [ ],
        "autosave" : 0
    }

}

Jonas Magnussen's icon

Hey am.syn, try going to your patcher window, unlock the patcher, press Cmd/Ctrl+A, then go to Edit, and press copy compressed. Paste your clipboard in your post to make us able to check out your patch; it looks much more tidy.

Below I posted compressed code of the solution to your question. The "abs" object calculates the absolute value of the input, which is the distance between 0 and the input value. It then goes into the "if" object, which lets you do a myriad of logical stuff, and transforms your 0s into 1s.

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


Best, Jonas

am.syn's icon

Hello Jonas,
thanks for your reply and your compress and abs hint. :)
The abs module is nice but it has one thing that not work for me.
When i go to zero the value jumps to 1. this is not possible because i get a Level jump in my outgoing sound.
This little switch controls my Dry/Wet Signal so value jumps to 1. are allowed ;)
If you will look to the numboxes directly underneath my expressions you will see what i want.
The problem is when i change into a positive value the numbox at the very end of my patch does not respond to the right expression.
I wish my math skills were better...... :)

Many thanks and i wish you a nice and relaxed X-Mas Time....stay tuned.....
greetz from Hamburg
Volker

am.syn's icon

Sorry i mean: This little switch controls my Dry/Wet Signal so value jumps to 1. are " not" allowed ;)

am.syn's icon

Problem solved, a gate brings the soloution. :)
Thanks for your Help Jonas :)

Jonas Magnussen's icon

I misunderstood what you wanted, now I think I understand. Please go through the "Message ordering" tutorial in the Max tutorials (you'll find them in your reference under the help tab). That tutorial will teach you what you did wrong in your patch. Your last number object briefly becomes the value from the right expression, but always ends up with the value from the left expression; order of operations. You gotta nail that if you wanna program in the Max environment.

Here's your solution, merry christmas! :)

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

am.syn's icon

Yeah...this is what im, looking for... very cool thanks.
My solution works but yours is much more efficient and more elegant, my solution is more mechanical :)

Thanks a lot :)
Here is my way....

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

Jonas Magnussen's icon

Yours doesn't really work though, you're messing up your message ordering again, so the result is wrong sometimes (try changing your first number box from 0. to -0.1, and you'll see your final value will not change, since you're sending your value through the gate before you have opened it). As I said, it's imperative that you learn message ordering in Max, or you'll keep getting bugs and finding your patches not working.

Max Gardener's icon

Jonas is right. The "Message Ordering" tutorial in Max will save you *all kinds of* problems - not only in the patches you're posting now, but in other patches down the road.

https://docs.cycling74.com/max7/tutorials/basicchapter05