Play random audio file from specific folder

Martin's icon

I am trying to make a patch that opens a random audio file (.aif) from a specified folder, This is what I've got bellow. I don't understand what the next stage is to make this work

{
    "boxes" : [         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "sprintf open %ld.aif",
                "fontsize" : 12.0,
                "numinlets" : 1,
                "numoutlets" : 1,
                "patching_rect" : [ 655.0, 689.0, 113.0, 20.0 ],
                "outlettype" : [ "" ],
                "id" : "obj-22",
                "fontname" : "Arial"
            }

        }
,         {
            "box" :             {
                "maxclass" : "toggle",
                "numinlets" : 1,
                "numoutlets" : 1,
                "patching_rect" : [ 700.0, 654.0, 20.0, 20.0 ],
                "outlettype" : [ "int" ],
                "id" : "obj-21"
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "delay 100",
                "fontsize" : 12.0,
                "numinlets" : 2,
                "numoutlets" : 1,
                "patching_rect" : [ 700.0, 629.0, 63.0, 20.0 ],
                "outlettype" : [ "bang" ],
                "id" : "obj-6",
                "fontname" : "Arial"
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "random",
                "fontsize" : 12.0,
                "numinlets" : 2,
                "numoutlets" : 1,
                "patching_rect" : [ 655.0, 592.0, 51.0, 20.0 ],
                "outlettype" : [ "int" ],
                "id" : "obj-19",
                "fontname" : "Arial"
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "sfplay~",
                "fontsize" : 12.0,
                "numinlets" : 2,
                "numoutlets" : 2,
                "patching_rect" : [ 655.0, 725.0, 49.0, 20.0 ],
                "outlettype" : [ "signal", "bang" ],
                "id" : "obj-23",
                "fontname" : "Arial",
                "save" : [ "#N", "sfplay~", "", 1, 120960, 0, "", ";" ]
            }

        }
],
    "lines" : [         {
            "patchline" :             {
                "source" : [ "obj-6", 0 ],
                "destination" : [ "obj-21", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-19", 0 ],
                "destination" : [ "obj-22", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-21", 0 ],
                "destination" : [ "obj-23", 0 ],
                "hidden" : 0,
                "midpoints" : [ 709.5, 681.0, 640.0, 681.0, 640.0, 720.0, 664.5, 720.0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-22", 0 ],
                "destination" : [ "obj-23", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
]
}

demers's icon

You could use [dropfile] into [umenu], and randomly trigger files that way:

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

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

try this

balam's icon

change number 7 for number of files to play

shanejohn's icon

@balam, thanks for that patch :) works great