Save stretch~ jsui

Jack Hamill's icon

Hello,
In the help file for stretch~ there is a jsui object that represents the waveform much like a flex editor would in a DAW. I'm not too well versed in using js for visual stuff—I'm trying to figure out how I would create the appropriate methods to save the placement of the markers such that I can access them using preset. Any ideas?

All best,
Jack

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

(the pasted help file for convenience)

cees koppe's icon

your dict has the values of the markers.

when you double click dict you find your markers

See example below

{
    "marker0" :     {
        "sourcetime" : 0.0,
        "desttime" : 0.0
    }
,
    "marker1" :     {
        "sourcetime" : 3955.869727317571233,
        "desttime" : 1907.795329486490346
    }
,
    "marker2" :     {
        "sourcetime" : 6564.579441721278272,
        "desttime" : 4264.48367767567197
    }
,
    "marker3" :     {
        "sourcetime" : 9693.683692879623777,
        "desttime" : 7042.009230898654096
    }
,
    "marker4" :     {
        "sourcetime" : 16637.0975056689349,
        "desttime" : 16637.0975056689349
    }

}

cees koppe's icon

{
    "boxes" : [         {
            "box" :             {
                "maxclass" : "message",
                "text" : "42.811533",
                "numinlets" : 2,
                "id" : "obj-51",
                "patching_rect" : [ 513.5, 920.0, 96.5, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "- 0.",
                "numinlets" : 2,
                "id" : "obj-49",
                "patching_rect" : [ 595.5, 877.0, 29.5, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "float" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "unpack l f",
                "numinlets" : 1,
                "id" : "obj-48",
                "patching_rect" : [ 554.5, 769.0, 60.0, 22.0 ],
                "numoutlets" : 2,
                "outlettype" : [ "", "float" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "unpack l f",
                "numinlets" : 1,
                "id" : "obj-47",
                "patching_rect" : [ 463.0, 788.0, 60.0, 22.0 ],
                "numoutlets" : 2,
                "outlettype" : [ "", "float" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "55.371102",
                "numinlets" : 2,
                "id" : "obj-46",
                "patching_rect" : [ 438.5, 834.0, 136.0, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "98.182635",
                "numinlets" : 2,
                "id" : "obj-44",
                "patching_rect" : [ 609.5, 834.0, 140.0, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "1.",
                "numinlets" : 2,
                "id" : "obj-40",
                "patching_rect" : [ 672.0, 652.0, 50.0, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "dict.iter",
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-35",
                "patching_rect" : [ 429.0, 687.0, 65.0, 23.0 ],
                "numoutlets" : 1,
                "fontsize" : 13.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "dict.iter",
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-37",
                "patching_rect" : [ 359.0, 687.0, 65.0, 23.0 ],
                "numoutlets" : 1,
                "fontsize" : 13.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "route marker1 marker2",
                "fontname" : "Arial",
                "numinlets" : 3,
                "id" : "obj-38",
                "patching_rect" : [ 359.0, 652.0, 141.0, 23.0 ],
                "numoutlets" : 3,
                "fontsize" : 13.0,
                "outlettype" : [ "", "", "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "dict.iter",
                "numinlets" : 1,
                "id" : "obj-33",
                "patching_rect" : [ 249.0, 547.0, 47.0, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "dict.view",
                "numinlets" : 1,
                "id" : "obj-32",
                "patching_rect" : [ 111.0, 759.0, 291.0, 277.0 ],
                "numoutlets" : 0
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "marker4 dictionary u001003833",
                "linecount" : 2,
                "numinlets" : 2,
                "id" : "obj-31",
                "patching_rect" : [ 160.0, 662.0, 156.0, 36.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "id" : "obj-26",
                "patching_rect" : [ 43.0, 435.0, 24.0, 24.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "bang" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "jsui",
                "parameter_enable" : 0,
                "ignoreclick" : 1,
                "numinlets" : 1,
                "jsarguments" : [ "stretch~" ],
                "id" : "obj-25",
                "patching_rect" : [ 10.0, 10.0, 180.55999755859375, 57.600002288818359 ],
                "filename" : "helpname.js",
                "numoutlets" : 1,
                "outlettype" : [ "" ],
                "border" : 0
            }

        }
,         {
            "box" :             {
                "maxclass" : "textbutton",
                "hint" : "",
                "parameter_enable" : 0,
                "ignoreclick" : 1,
                "text" : "1",
                "numinlets" : 1,
                "fontface" : 1,
                "id" : "obj-24",
                "rounded" : 60.0,
                "patching_rect" : [ 443.5, 260.5, 20.0, 20.0 ],
                "textcolor" : [ 0.34902, 0.34902, 0.34902, 1.0 ],
                "numoutlets" : 3,
                "legacytextcolor" : 1,
                "bgcolor" : [ 1.0, 0.788235, 0.470588, 1.0 ],
                "outlettype" : [ "", "", "int" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "textbutton",
                "hint" : "",
                "parameter_enable" : 0,
                "ignoreclick" : 1,
                "text" : "2",
                "numinlets" : 1,
                "fontface" : 1,
                "id" : "obj-21",
                "rounded" : 60.0,
                "patching_rect" : [ 594.5, 534.5, 20.0, 20.0 ],
                "textcolor" : [ 0.34902, 0.34902, 0.34902, 1.0 ],
                "numoutlets" : 3,
                "legacytextcolor" : 1,
                "bgcolor" : [ 1.0, 0.788235, 0.470588, 1.0 ],
                "outlettype" : [ "", "", "int" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "textbutton",
                "hint" : "",
                "parameter_enable" : 0,
                "ignoreclick" : 1,
                "text" : "3",
                "numinlets" : 1,
                "fontface" : 1,
                "id" : "obj-27",
                "rounded" : 60.0,
                "patching_rect" : [ 713.5, 508.0, 20.0, 20.0 ],
                "textcolor" : [ 0.34902, 0.34902, 0.34902, 1.0 ],
                "numoutlets" : 3,
                "legacytextcolor" : 1,
                "bgcolor" : [ 1.0, 0.788235, 0.470588, 1.0 ],
                "outlettype" : [ "", "", "int" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "play result",
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-28",
                "patching_rect" : [ 742.5, 508.0, 87.0, 25.0 ],
                "numoutlets" : 0,
                "bubbleside" : 3,
                "fontsize" : 13.0,
                "bubble" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "t 0",
                "numinlets" : 1,
                "id" : "obj-19",
                "patching_rect" : [ 905.0, 588.0, 25.0, 22.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "int" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "dac~",
                "numinlets" : 2,
                "id" : "obj-14",
                "patching_rect" : [ 833.0, 595.0, 39.0, 22.0 ],
                "numoutlets" : 0
            }

        }
,         {
            "box" :             {
                "maxclass" : "toggle",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "id" : "obj-10",
                "patching_rect" : [ 833.0, 508.0, 24.0, 24.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "int" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "play~ stretchy",
                "numinlets" : 1,
                "id" : "obj-9",
                "patching_rect" : [ 833.0, 552.0, 91.0, 22.0 ],
                "numoutlets" : 2,
                "outlettype" : [ "signal", "bang" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "loadbang",
                "numinlets" : 1,
                "id" : "obj-7",
                "patching_rect" : [ 111.0, 237.0, 64.0, 22.0 ],
                "numoutlets" : 1,
                "hidden" : 1,
                "outlettype" : [ "bang" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "Dictionaries can be sent to groove~ and stretch~ for complex realtime and non-realtime warping operations. ",
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-1",
                "patching_rect" : [ 82.0, 206.0, 633.0, 21.0 ],
                "numoutlets" : 0,
                "fontsize" : 13.0
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "replace",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-16",
                "patching_rect" : [ 611.0, 269.0, 50.0, 22.0 ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "slider",
                "parameter_enable" : 0,
                "floatoutput" : 1,
                "numinlets" : 1,
                "id" : "obj-11",
                "size" : 2.0,
                "patching_rect" : [ 111.0, 459.0, 593.0, 10.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "id" : "obj-29",
                "patching_rect" : [ 427.0, 526.0, 24.0, 24.0 ],
                "numoutlets" : 1,
                "outlettype" : [ "bang" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "dict mydict",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-23",
                "patching_rect" : [ 111.0, 500.0, 65.0, 22.0 ],
                "numoutlets" : 4,
                "fontsize" : 12.0,
                "outlettype" : [ "dictionary", "", "", "" ],
                "saved_object_attributes" :                 {
                    "embed" : 0,
                    "parameter_enable" : 0,
                    "parameter_mappable" : 0
                }

            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "init",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-18",
                "patching_rect" : [ 196.5, 305.0, 32.5, 22.0 ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "bang when you want to execute\n",
                "linecount" : 2,
                "presentation_linecount" : 2,
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-17",
                "patching_rect" : [ 472.0, 526.0, 116.0, 52.0 ],
                "numoutlets" : 0,
                "fontsize" : 12.0,
                "bubble" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "dictionary warps",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-15",
                "patching_rect" : [ 427.0, 570.0, 97.0, 22.0 ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "stretch~ stretchy",
                "fontname" : "Arial",
                "numinlets" : 1,
                "fontface" : 0,
                "id" : "obj-5",
                "patching_rect" : [ 427.0, 604.0, 99.0, 22.0 ],
                "numoutlets" : 2,
                "fontsize" : 12.0,
                "outlettype" : [ "float", "bang" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "click to add a marker.\nshift-click to delete.\ndrag to move them around.",
                "linecount" : 3,
                "presentation_linecount" : 3,
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-13",
                "patching_rect" : [ 438.5, 287.0, 157.0, 67.0 ],
                "numoutlets" : 0,
                "bubbleside" : 2,
                "fontsize" : 12.0,
                "bubble" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "draw a simplified waveform, using the specified buffer, and number of points. (currently just gets the peakamp)",
                "linecount" : 6,
                "presentation_linecount" : 6,
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-12",
                "patching_rect" : [ 271.5, 272.0, 150.0, 89.0 ],
                "numoutlets" : 0,
                "fontsize" : 12.0
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "drawbuffer stretchy 1000",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-8",
                "patching_rect" : [ 111.0, 272.0, 142.0, 22.0 ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "replace jongly.aif",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-6",
                "patching_rect" : [ 637.0, 305.0, 100.0, 22.0 ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "buffer~ stretchy",
                "fontname" : "Arial",
                "numinlets" : 1,
                "id" : "obj-4",
                "patching_rect" : [ 611.0, 337.0, 93.0, 22.0 ],
                "numoutlets" : 2,
                "fontsize" : 12.0,
                "outlettype" : [ "float", "bang" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "open",
                "fontname" : "Arial",
                "numinlets" : 2,
                "id" : "obj-3",
                "patching_rect" : [ 150.0, 305.0, 37.0, 22.0 ],
                "numoutlets" : 1,
                "fontsize" : 12.0,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "jsui",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "id" : "obj-20",
                "patching_rect" : [ 111.0, 367.0, 593.0, 87.0 ],
                "filename" : "warpy2.js",
                "numoutlets" : 1,
                "outlettype" : [ "" ]
            }

        }
,         {
            "box" :             {
                "maxclass" : "attrui",
                "fontname" : "Arial",
                "attr" : "mode",
                "numinlets" : 1,
                "fontface" : 0,
                "id" : "obj-22",
                "patching_rect" : [ 532.5, 570.0, 196.0, 23.0 ],
                "numoutlets" : 1,
                "fontsize" : 13.0,
                "outlettype" : [ "" ]
            }

        }
],
    "lines" : [         {
            "patchline" :             {
                "source" : [ "obj-48", 1 ],
                "destination" : [ "obj-49", 0 ],
                "order" : 1
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-47", 1 ],
                "destination" : [ "obj-49", 1 ],
                "order" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-49", 0 ],
                "destination" : [ "obj-51", 1 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-48", 1 ],
                "destination" : [ "obj-44", 1 ],
                "order" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-35", 0 ],
                "destination" : [ "obj-48", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-47", 1 ],
                "destination" : [ "obj-46", 1 ],
                "order" : 1
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-37", 0 ],
                "destination" : [ "obj-47", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-38", 1 ],
                "destination" : [ "obj-35", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-38", 0 ],
                "destination" : [ "obj-37", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-33", 0 ],
                "destination" : [ "obj-38", 0 ],
                "order" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-5", 0 ],
                "destination" : [ "obj-40", 1 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-20", 0 ],
                "destination" : [ "obj-23", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-26", 0 ],
                "destination" : [ "obj-23", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-23", 0 ],
                "destination" : [ "obj-33", 0 ],
                "order" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-23", 0 ],
                "destination" : [ "obj-32", 0 ],
                "order" : 1
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-33", 0 ],
                "destination" : [ "obj-31", 1 ],
                "order" : 1
            }

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

        }
,         {
            "patchline" :             {
                "source" : [ "obj-15", 0 ],
                "destination" : [ "obj-5", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-16", 0 ],
                "destination" : [ "obj-4", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-18", 0 ],
                "destination" : [ "obj-20", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-19", 0 ],
                "destination" : [ "obj-10", 0 ],
                "midpoints" : [ 914.5, 621.0, 953.5, 621.0, 953.5, 497.0, 842.5, 497.0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-22", 0 ],
                "destination" : [ "obj-5", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-29", 0 ],
                "destination" : [ "obj-15", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-3", 0 ],
                "destination" : [ "obj-20", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-6", 0 ],
                "destination" : [ "obj-4", 0 ]
            }

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

        }
,         {
            "patchline" :             {
                "source" : [ "obj-8", 0 ],
                "destination" : [ "obj-20", 0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-9", 0 ],
                "destination" : [ "obj-14", 1 ],
                "order" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-9", 0 ],
                "destination" : [ "obj-14", 0 ],
                "order" : 1
            }

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

        }
],
    "appversion" :     {
        "major" : 8,
        "minor" : 2,
        "revision" : 0,
        "architecture" : "x64",
        "modernui" : 1
    }
,
    "classnamespace" : "box"
}