---buffer name for gen

slx's icon

hi together,
I realized today that I cannot use the --- for my buffer object I am using for gen.
Does anybody know a solution to create an unique name space in max for live within a gen~ ?

thanks in advance

tyler mazaika's icon

I believe you are mistaken. As long as you type the buffer name as an argument to the max [gen] object (as opposed to only inside the gen code) this should work.

[gen~ @bufname —-nameofbuffer]

slx's icon

hi tyler,

thanks for the suggestion, but it is not working for me. also I would need the buffer length ...
but it seems already the @bufname is invalid.

{
    "boxes" : [         {
            "box" :             {
                "maxclass" : "number~",
                "outlettype" : [ "signal", "float" ],
                "fontsize" : 12.0,
                "id" : "obj-6",
                "fontname" : "Arial",
                "mode" : 2,
                "numinlets" : 2,
                "fontface" : 0,
                "sig" : 0.0,
                "numoutlets" : 2,
                "patching_rect" : [ 58.0, 72.0, 97.0, 22.0 ]
            }
}
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "gen~ @bufname ---bumi",
                "outlettype" : [ "signal" ],
                "id" : "obj-1",
                "numinlets" : 1,
                "numoutlets" : 1,
                "patching_rect" : [ 58.0, 29.0, 165.0, 22.0 ],
                "patcher" :                 {
                    "fileversion" : 1,
                    "appversion" :                     {
                        "major" : 8,
                        "minor" : 5,
                        "revision" : 5,
                        "architecture" : "x64",
                        "modernui" : 1
                    }
,
                    "classnamespace" : "dsp.gen",
                    "rect" : [ 84.0, 131.0, 600.0, 450.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" : "",
                    "assistshowspatchername" : 0,
                    "boxes" : [                         {
                            "box" :                             {
                                "maxclass" : "newobj",
                                "text" : "dim ---bumi",
                                "outlettype" : [ "" ],
                                "id" : "obj-7",
                                "numinlets" : 0,
                                "numoutlets" : 1,
                                "patching_rect" : [ 176.0, 250.0, 100.0, 22.0 ]
                            }
}
,                         {
                            "box" :                             {
                                "maxclass" : "newobj",
                                "text" : "out 1",
                                "id" : "obj-4",
                                "numinlets" : 1,
                                "numoutlets" : 0,
                                "patching_rect" : [ 176.0, 418.0, 35.0, 22.0 ]
                            }
}
 ],
                    "lines" : [                         {
                            "patchline" :                             {
                                "source" : [ "obj-7", 0 ],
                                "destination" : [ "obj-4", 0 ]
                            }
}
 ]
                }
}
}
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "replace $1",
                "outlettype" : [ "" ],
                "id" : "obj-16",
                "numinlets" : 2,
                "numoutlets" : 1,
                "patching_rect" : [ 58.0, 176.0, 76.0, 22.0 ]
            }
}
,         {
            "box" :             {
                "maxclass" : "dropfile",
                "outlettype" : [ "", "" ],
                "id" : "obj-14",
                "numinlets" : 1,
                "numoutlets" : 2,
                "patching_rect" : [ 58.0, 112.0, 121.0, 53.0 ]
            }
}
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "drop file",
                "id" : "obj-13",
                "numinlets" : 1,
                "numoutlets" : 0,
                "patching_rect" : [ 187.0, 112.0, 150.0, 20.0 ]
            }
}
,         {
            "box" :             {
                "maxclass" : "message",
                "text" : "name ---bumi",
                "outlettype" : [ "" ],
                "id" : "obj-9",
                "numinlets" : 2,
                "numoutlets" : 1,
                "patching_rect" : [ 58.0, 246.0, 121.0, 22.0 ]
            }
}
,         {
            "box" :             {
                "maxclass" : "waveform~",
                "outlettype" : [ "float", "float", "float", "float", "list", "" ],
                "id" : "obj-10",
                "numinlets" : 5,
                "buffername" : "---bumi",
                "numoutlets" : 6,
                "patching_rect" : [ 58.0, 280.0, 256.0, 64.0 ]
            }
}
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "buffer~ ---bumi",
                "outlettype" : [ "float", "bang" ],
                "id" : "obj-11",
                "numinlets" : 1,
                "numoutlets" : 2,
                "patching_rect" : [ 58.0, 213.0, 100.0, 22.0 ]
            }
}
 ],
    "lines" : [         {
            "patchline" :             {
                "source" : [ "obj-1", 0 ],
                "destination" : [ "obj-6", 0 ]
            }
}
,         {
            "patchline" :             {
                "source" : [ "obj-9", 0 ],
                "destination" : [ "obj-10", 0 ]
            }
}
,         {
            "patchline" :             {
                "source" : [ "obj-14", 0 ],
                "destination" : [ "obj-16", 0 ]
            }
}
,         {
            "patchline" :             {
                "source" : [ "obj-16", 0 ],
                "destination" : [ "obj-11", 0 ]
            }
}
,         {
            "patchline" :             {
                "source" : [ "obj-11", 1 ],
                "destination" : [ "obj-9", 0 ]
            }
}
 ],
    "appversion" :     {
        "major" : 8,
        "minor" : 5,
        "revision" : 5,
        "architecture" : "x64",
        "modernui" : 1
    }
,
    "classnamespace" : "box"
}
Graham Wakefield's icon

Don't use "---bumi" in the gen~ patcher, use "bufname".

E.g. within gen~, use [buffer bufname], [dim bufname], etc.

The attribute "@bufname ---bumi" on the gen~ object tells the gen~ that where gen~ uses "bufname", it will map to whatever ---bumi is in Max.

slx's icon

Super! Now I understood and it works just fine.
Thanks to both of you.

Is this somewhere described or maybe this falls more into the category of things which are just basic knowledge which I might not have :)

allforabit's icon

I'm trying to do something similar and trying to get a locally scoped buffer into gen (into a codebox). By any chance could you share the working code?

I can't quite figure it out. In my case I'm trying to access a buffer named #1myname so that each instance can be given a unique buffer.

allforabit's icon

Oh I have it, the code I need in the codebox is:

Buffer bufname();

out1 = dim(bufname);

(using the [gen~ @bufname —-nameofbuffer] to create the gen~ as described above).