Audio Threshold


    May 17 2010 | 10:45 am
    people,
    I am making a patcher that do the following:
    - from the mic input comes the sound
    - there is a threshold.
    - when the sound level is above the threshold level it bangs in one exit
    - when the sound level is bellow the threshold level it bangs in a different exit.
    my question is:
    sometimes the sound level is quite unstable and it goes bellow the threshold for some milliseconds. I want to have something the makes the bang only works when it is bellow the threshold level more than 2 seconds.
    segue abaixo o patcher:
    { "boxes" : [ { "box" : { "maxclass" : "newobj", "text" : "onebang 1", "patching_rect" : [ 87.0, 432.0, 67.0, 20.0 ], "fontsize" : 12.0, "numinlets" : 2, "numoutlets" : 2, "outlettype" : [ "bang", "bang" ], "id" : "obj-148", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "button", "patching_rect" : [ 196.0, 498.0, 20.0, 20.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-147" }
    } , { "box" : { "maxclass" : "newobj", "text" : "delay 50", "patching_rect" : [ 196.0, 475.0, 56.0, 20.0 ], "fontsize" : 12.0, "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-146", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 335.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-3", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 296.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-5", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 257.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-6", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 218.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-8", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 180.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-1", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 141.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-2", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "toggle", "patching_rect" : [ 63.0, 79.0, 15.0, 15.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "int" ], "id" : "obj-38" }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 102.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-37", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "meter~", "patching_rect" : [ 63.0, 127.0, 31.0, 58.0 ], "warmcolor" : [ 0.85098, 0.85098, 0.0, 1.0 ], "numinlets" : 1, "tepidcolor" : [ 0.6, 0.729412, 0.0, 1.0 ], "numoutlets" : 1, "outlettype" : [ "float" ], "bgcolor" : [ 0.403922, 0.403922, 0.403922, 1.0 ], "id" : "obj-35", "coldcolor" : [ 0.0, 0.658824, 0.0, 1.0 ], "interval" : 100 }
    } , { "box" : { "maxclass" : "newobj", "text" : "adc~ 1 2 3 4 5 6 7 8", "patching_rect" : [ 62.0, 101.0, 292.0, 20.0 ], "fontsize" : 12.0, "numinlets" : 1, "numoutlets" : 8, "outlettype" : [ "signal", "signal", "signal", "signal", "signal", "signal", "signal", "signal" ], "id" : "obj-32", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "comment", "text" : "record", "patching_rect" : [ 216.0, 438.0, 48.0, 20.0 ], "fontsize" : 11.595187, "numinlets" : 1, "numoutlets" : 0, "id" : "obj-94", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "comment", "text" : "stop", "patching_rect" : [ 161.0, 438.0, 33.0, 20.0 ], "fontsize" : 11.595187, "numinlets" : 1, "numoutlets" : 0, "id" : "obj-93", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "button", "patching_rect" : [ 95.0, 503.0, 20.0, 20.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-91" }
    } , { "box" : { "maxclass" : "newobj", "text" : "onebang 1", "patching_rect" : [ 116.0, 383.0, 67.0, 20.0 ], "fontsize" : 12.0, "numinlets" : 2, "numoutlets" : 2, "outlettype" : [ "bang", "bang" ], "id" : "obj-92", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "button", "patching_rect" : [ 196.0, 438.0, 20.0, 20.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-90" }
    } , { "box" : { "maxclass" : "newobj", "text" : "onebang 1", "patching_rect" : [ 197.0, 383.0, 67.0, 20.0 ], "fontsize" : 12.0, "numinlets" : 2, "numoutlets" : 2, "outlettype" : [ "bang", "bang" ], "id" : "obj-89", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "newobj", "text" : "loadbang", "patching_rect" : [ 61.0, 38.0, 48.0, 17.0 ], "fontsize" : 9.0, "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-10", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "message", "text" : "1", "patching_rect" : [ 64.0, 59.0, 16.0, 15.0 ], "fontsize" : 9.0, "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], "id" : "obj-11", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "button", "patching_rect" : [ 96.0, 366.0, 15.0, 15.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-49" }
    } , { "box" : { "maxclass" : "message", "text" : "peakreset", "patching_rect" : [ 295.0, 328.0, 52.0, 15.0 ], "fontsize" : 9.0, "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], "id" : "obj-63", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "multislider", "patching_rect" : [ 295.0, 356.0, 32.0, 94.0 ], "border_bottom" : 0, "candicane5" : [ 0.584314, 0.827451, 0.431373, 1.0 ], "setstyle" : 1, "candicane4" : [ 0.439216, 0.619608, 0.070588, 1.0 ], "drawpeaks" : 1, "numinlets" : 1, "peakcolor" : [ 0.972549, 0.0, 0.0, 1.0 ], "candicane3" : [ 0.290196, 0.411765, 0.713726, 1.0 ], "border_left" : 0, "candicane8" : [ 0.027451, 0.447059, 0.501961, 1.0 ], "numoutlets" : 2, "slidercolor" : [ 0.0, 0.011765, 0.713726, 1.0 ], "candicane2" : [ 0.145098, 0.203922, 0.356863, 1.0 ], "contdata" : 1, "border_top" : 0, "candicane7" : [ 0.878431, 0.243137, 0.145098, 1.0 ], "outlettype" : [ "", "" ], "bgcolor" : [ 1.0, 0.694118, 0.168627, 1.0 ], "id" : "obj-64", "border_right" : 0, "setminmax" : [ 0.0, 1.0 ], "candicane6" : [ 0.733333, 0.035294, 0.788235, 1.0 ] }
    } , { "box" : { "maxclass" : "message", "text" : "set $1", "patching_rect" : [ 273.0, 304.0, 40.0, 15.0 ], "fontsize" : 9.0, "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], "id" : "obj-65", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "multislider", "patching_rect" : [ 286.0, 368.0, 50.0, 96.0 ], "border_bottom" : 0, "candicane5" : [ 0.584314, 0.827451, 0.431373, 1.0 ], "setstyle" : 1, "candicane4" : [ 0.439216, 0.619608, 0.070588, 1.0 ], "numinlets" : 1, "peakcolor" : [ 0.972549, 0.0, 0.0, 1.0 ], "candicane3" : [ 0.290196, 0.411765, 0.713726, 1.0 ], "border_left" : 0, "candicane8" : [ 0.027451, 0.447059, 0.501961, 1.0 ], "numoutlets" : 2, "slidercolor" : [ 0.0, 0.011765, 0.713726, 1.0 ], "candicane2" : [ 0.145098, 0.203922, 0.356863, 1.0 ], "contdata" : 1, "border_top" : 0, "candicane7" : [ 0.878431, 0.243137, 0.145098, 1.0 ], "outlettype" : [ "", "" ], "bgcolor" : [ 1.0, 0.694118, 0.168627, 1.0 ], "id" : "obj-66", "border_right" : 0, "setminmax" : [ 0.0, 1.0 ], "candicane6" : [ 0.733333, 0.035294, 0.788235, 1.0 ] }
    } , { "box" : { "maxclass" : "flonum", "patching_rect" : [ 134.0, 351.0, 35.0, 18.0 ], "triscale" : 0.9, "fontsize" : 10.0, "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "float", "bang" ], "bgcolor" : [ 0.866667, 0.866667, 0.866667, 1.0 ], "id" : "obj-67", "fontname" : "Arial", "htextcolor" : [ 0.870588, 0.870588, 0.870588, 1.0 ] }
    } , { "box" : { "maxclass" : "message", "text" : "0.24", "patching_rect" : [ 224.0, 284.0, 33.0, 16.0 ], "fontsize" : 10.0, "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], "id" : "obj-68", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "message", "text" : "1", "patching_rect" : [ 179.0, 284.0, 17.0, 16.0 ], "fontsize" : 10.0, "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], "id" : "obj-69", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "newobj", "text" : "loadbang", "patching_rect" : [ 202.0, 255.0, 52.0, 18.0 ], "fontsize" : 10.0, "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-70", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "button", "patching_rect" : [ 224.0, 351.0, 15.0, 15.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-71" }
    } , { "box" : { "maxclass" : "button", "patching_rect" : [ 180.0, 351.0, 15.0, 15.0 ], "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "bang" ], "id" : "obj-72" }
    } , { "box" : { "maxclass" : "comment", "text" : "ampl", "patching_rect" : [ 146.0, 290.0, 31.0, 18.0 ], "fontsize" : 10.0, "numinlets" : 1, "numoutlets" : 0, "id" : "obj-73", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "flonum", "patching_rect" : [ 224.0, 306.0, 35.0, 18.0 ], "triscale" : 0.9, "fontsize" : 10.0, "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "float", "bang" ], "bgcolor" : [ 1.0, 0.360784, 0.682353, 1.0 ], "id" : "obj-74", "fontname" : "Arial", "htextcolor" : [ 0.870588, 0.870588, 0.870588, 1.0 ] }
    } , { "box" : { "maxclass" : "flonum", "patching_rect" : [ 179.0, 306.0, 35.0, 18.0 ], "triscale" : 0.9, "fontsize" : 10.0, "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "float", "bang" ], "bgcolor" : [ 0.866667, 0.866667, 0.866667, 1.0 ], "id" : "obj-75", "fontname" : "Arial", "htextcolor" : [ 0.870588, 0.870588, 0.870588, 1.0 ] }
    } , { "box" : { "maxclass" : "newobj", "text" : "thresh~ "patching_rect" : [ 134.0, 329.0, 109.0, 18.0 ], "fontsize" : 10.0, "numinlets" : 3, "numoutlets" : 3, "outlettype" : [ "float", "", "" ], "id" : "obj-76", "fontname" : "Arial" }
    } , { "box" : { "maxclass" : "comment", "text" : "thresh", "patching_rect" : [ 258.0, 276.0, 37.0, 18.0 ], "fontsize" : 10.0, "numinlets" : 1, "numoutlets" : 0, "id" : "obj-77", "fontname" : "Arial" }
    } ], "lines" : [ { "patchline" : { "source" : [ "obj-92", 0 ], "destination" : [ "obj-148", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-68", 0 ], "destination" : [ "obj-75", 0 ], "hidden" : 0, "midpoints" : [ 233.5, 302.5, 188.5, 302.5 ] }
    } , { "patchline" : { "source" : [ "obj-72", 0 ], "destination" : [ "obj-92", 1 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-11", 0 ], "destination" : [ "obj-38", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 0 ], "destination" : [ "obj-76", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-38", 0 ], "destination" : [ "obj-32", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 1 ], "destination" : [ "obj-37", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 0 ], "destination" : [ "obj-35", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-71", 0 ], "destination" : [ "obj-89", 1 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-71", 0 ], "destination" : [ "obj-92", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-89", 0 ], "destination" : [ "obj-90", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-10", 0 ], "destination" : [ "obj-11", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-76", 0 ], "destination" : [ "obj-67", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-67", 0 ], "destination" : [ "obj-49", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-70", 0 ], "destination" : [ "obj-69", 0 ], "hidden" : 1, "midpoints" : [ 211.5, 278.0, 185.5, 278.0 ] }
    } , { "patchline" : { "source" : [ "obj-69", 0 ], "destination" : [ "obj-75", 0 ], "hidden" : 1, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-75", 0 ], "destination" : [ "obj-76", 1 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-76", 1 ], "destination" : [ "obj-72", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-70", 0 ], "destination" : [ "obj-68", 0 ], "hidden" : 1, "midpoints" : [ 211.5, 278.0, 233.5, 278.0 ] }
    } , { "patchline" : { "source" : [ "obj-65", 0 ], "destination" : [ "obj-74", 0 ], "hidden" : 1, "midpoints" : [ 282.5, 302.0, 233.5, 302.0 ] }
    } , { "patchline" : { "source" : [ "obj-68", 0 ], "destination" : [ "obj-74", 0 ], "hidden" : 1, "midpoints" : [ 233.5, 277.0, 233.5, 277.0 ] }
    } , { "patchline" : { "source" : [ "obj-66", 0 ], "destination" : [ "obj-76", 2 ], "hidden" : 0, "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], "midpoints" : [ 295.5, 473.0, 273.0, 473.0, 273.0, 332.0, 233.5, 332.0 ] }
    } , { "patchline" : { "source" : [ "obj-74", 0 ], "destination" : [ "obj-76", 2 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-76", 2 ], "destination" : [ "obj-71", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-66", 0 ], "destination" : [ "obj-65", 0 ], "hidden" : 1, "midpoints" : [ 295.5, 473.0, 282.5, 473.0, 282.5, 325.0, 282.5, 325.0 ] }
    } , { "patchline" : { "source" : [ "obj-74", 0 ], "destination" : [ "obj-66", 0 ], "hidden" : 0, "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], "midpoints" : [ 233.5, 322.0, 295.5, 322.0 ] }
    } , { "patchline" : { "source" : [ "obj-63", 0 ], "destination" : [ "obj-64", 0 ], "hidden" : 0, "midpoints" : [ 304.5, 345.0, 304.5, 345.0 ] }
    } , { "patchline" : { "source" : [ "obj-67", 0 ], "destination" : [ "obj-64", 0 ], "hidden" : 0, "color" : [ 0.290196, 0.611765, 0.380392, 1.0 ], "midpoints" : [ 143.5, 375.0, 253.0, 375.0, 253.0, 349.0, 304.5, 349.0 ] }
    } , { "patchline" : { "source" : [ "obj-72", 0 ], "destination" : [ "obj-89", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 2 ], "destination" : [ "obj-2", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 3 ], "destination" : [ "obj-1", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 4 ], "destination" : [ "obj-8", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 5 ], "destination" : [ "obj-6", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 6 ], "destination" : [ "obj-5", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-32", 7 ], "destination" : [ "obj-3", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-90", 0 ], "destination" : [ "obj-146", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-146", 0 ], "destination" : [ "obj-147", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } , { "patchline" : { "source" : [ "obj-148", 0 ], "destination" : [ "obj-91", 0 ], "hidden" : 0, "midpoints" : [ ] }
    } ] }

    • May 17 2010 | 12:49 pm
      firstly, when u post patches u should use copy compressed from the edit menu. this will make the data much shorter and less scrolling for forum users, which makes the forum more readable...
      * also ur patch has an error when u copy/paste.
      below is a patch which i think does what u are looking for, but im not entirely sure i understood ur request for the timer part.