Ping Pong Delay - Exponential decay

Sam Sturtivant's icon

Hello fellow man

I was wondering if somebody who is more fluent in Max would be able to help me. I want to create a delay that replicates that of when a bouncing ball is dropped from a 'height' that can be user defined.

I'm sure there is a better way of doing it than this;

{
    "boxes" : [         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapout~ 177",
                "id" : "obj-32",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 453.0, 74.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapin~ 177",
                "id" : "obj-31",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "tapconnect" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 419.0, 67.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapout~ 236.2",
                "id" : "obj-30",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 380.0, 84.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapin~ 236.2",
                "id" : "obj-29",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "tapconnect" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 349.0, 77.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapout~ 315.8",
                "id" : "obj-28",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 317.0, 84.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapin~ 315.8",
                "id" : "obj-27",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "tapconnect" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 288.0, 77.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "flonum",
                "id" : "obj-26",
                "fontname" : "Arial",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "outlettype" : [ "float", "bang" ],
                "numoutlets" : 2,
                "fontsize" : 12.0,
                "patching_rect" : [ 321.0, 159.0, 50.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "flonum",
                "id" : "obj-24",
                "fontname" : "Arial",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "outlettype" : [ "float", "bang" ],
                "numoutlets" : 2,
                "fontsize" : 12.0,
                "patching_rect" : [ 290.0, 12.0, 50.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapout~ 421.5",
                "id" : "obj-19",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 256.0, 84.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapin~ 421.5",
                "id" : "obj-20",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "tapconnect" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 220.0, 77.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "expr $i1 * 0.75",
                "id" : "obj-13",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 350.0, 46.0, 88.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapout~ 562.5",
                "id" : "obj-12",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 187.0, 84.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapin~ 562.5",
                "id" : "obj-11",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "tapconnect" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 159.0, 77.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapout~ 750",
                "id" : "obj-10",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 125.0, 74.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "tapin~ 750",
                "id" : "obj-9",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "tapconnect" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 187.0, 92.0, 67.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "ezdac~",
                "id" : "obj-8",
                "numinlets" : 2,
                "numoutlets" : 0,
                "patching_rect" : [ 55.0, 413.0, 45.0, 45.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "gain~",
                "id" : "obj-4",
                "parameter_enable" : 0,
                "numinlets" : 2,
                "outlettype" : [ "signal", "int" ],
                "numoutlets" : 2,
                "patching_rect" : [ 55.5, 211.0, 22.0, 140.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "id" : "obj-3",
                "numinlets" : 1,
                "outlettype" : [ "bang" ],
                "numoutlets" : 1,
                "patching_rect" : [ 86.0, 39.0, 20.0, 20.0 ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "click~",
                "id" : "obj-1",
                "fontname" : "Arial",
                "numinlets" : 1,
                "outlettype" : [ "signal" ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "patching_rect" : [ 86.0, 78.0, 41.0, 20.0 ]
            }

        }
],
    "lines" : [         {
            "patchline" :             {
                "source" : [ "obj-32", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-31", 0 ],
                "destination" : [ "obj-32", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-30", 0 ],
                "destination" : [ "obj-31", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-30", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-29", 0 ],
                "destination" : [ "obj-30", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-28", 0 ],
                "destination" : [ "obj-29", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-28", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-27", 0 ],
                "destination" : [ "obj-28", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-19", 0 ],
                "destination" : [ "obj-27", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-19", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-12", 0 ],
                "destination" : [ "obj-20", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-20", 0 ],
                "destination" : [ "obj-19", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-13", 0 ],
                "destination" : [ "obj-26", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-24", 0 ],
                "destination" : [ "obj-13", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-1", 0 ],
                "destination" : [ "obj-9", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-9", 0 ],
                "destination" : [ "obj-10", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-10", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-10", 0 ],
                "destination" : [ "obj-11", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-11", 0 ],
                "destination" : [ "obj-12", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-12", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-4", 0 ],
                "destination" : [ "obj-8", 1 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-4", 0 ],
                "destination" : [ "obj-8", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-1", 0 ],
                "destination" : [ "obj-4", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-3", 0 ],
                "destination" : [ "obj-1", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
],
    "appversion" :     {
        "major" : 6,
        "minor" : 1,
        "revision" : 5,
        "architecture" : "x86"
    }

}

kodamapixel's icon

Try pasting your Max patch as compressed code: Select All and then Edit > Copy Compressed from the menu.

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

*polite bump*

Roman Thilenius's icon

patch2canvas refused to show me the patch, so i can only look at your first post to guess how it looks like.

some thoughts:

- dont try to make a dynamic version before you got a satisfying static version.

- the conversion of height-to-delay#1 will be based a constant, there is no need to calculate that in realtime.

- [tapout~] takes up to 10 (or 8?) arguments at once: [tapout~ 1000. 500. 333. ...]

- when you are reaching the border for short delays (you will notice it, when that is the case, dont worry), you can improve the process by upsampling the whole delay stuff x4 or x8 using [poly~]

- in real life many materials will sound a bit different at different heights. except glass on glass maybe. so it can be a lot of fun to experiment a bit with [slide~] or other lowpass filters, or influence the sound source itself, for example if it is coming from an FM synth.

-110

Floating Point's icon

basically all you need to do is have a tap which feeds back on itself (with a constant attenuation) and a line whose output is sent to the tap to lessen its delay in a continual manner (until it reaches zero) you'll probably need a sah in there so you don't get pitch changes. ideally you'd poly-fy it to avoid discontinuities