very simple question


    May 14 2011 | 10:14 am
    Hi everybody,
    I have a problem that is very basic (but I don't know how to solve it)
    What I'm trying to do is to have from a output from Cyclops (the value of a number changes very fast) 2 answers: on/off (1 or 0). if the number from Cyclops output is < of (let's say) 30 then off, if is > 30 then on. I used the object if to do that but EVERYTIME the number is under 30 it output 1 and what I need is that when it goes uder 30 will be just one "bang" (let's say: 30 - bang, 29/27/27 etc.. no bang), i need just the firstone, untill it get back to a value >30.
    I tryed also with "select 30" but some times max doesn't see 30 he jumps from a higher value to a loweer value.
    here a simple example:
    {
    "boxes" : [ {
    "box" : {
    "maxclass" : "message",
    "text" : "if you move fast the slider he doesn't output the number 50, he jups",
    "linecount" : 5,
    "numoutlets" : 1,
    "outlettype" : [ "" ],
    "patching_rect" : [ 456.0, 284.0, 105.0, 73.0 ],
    "id" : "obj-13",
    "fontname" : "Arial",
    "fontsize" : 12.0,
    "numinlets" : 2
    }
    }
    , {
    "box" : {
    "maxclass" : "button",
    "numoutlets" : 1,
    "outlettype" : [ "bang" ],
    "patching_rect" : [ 229.0, 462.0, 20.0, 20.0 ],
    "id" : "obj-12",
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "newobj",
    "text" : "if $i1 < 50 then 1 else 0",
    "numoutlets" : 1,
    "outlettype" : [ "" ],
    "patching_rect" : [ 190.0, 401.0, 135.0, 20.0 ],
    "id" : "obj-10",
    "fontname" : "Arial",
    "fontsize" : 12.0,
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "toggle",
    "numoutlets" : 1,
    "outlettype" : [ "int" ],
    "patching_rect" : [ 193.0, 460.0, 20.0, 20.0 ],
    "id" : "obj-6",
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "number",
    "numoutlets" : 2,
    "outlettype" : [ "int", "bang" ],
    "patching_rect" : [ 189.0, 360.0, 50.0, 20.0 ],
    "id" : "obj-7",
    "fontname" : "Arial",
    "fontsize" : 12.0,
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "slider",
    "numoutlets" : 1,
    "outlettype" : [ "" ],
    "patching_rect" : [ 188.0, 195.0, 20.0, 140.0 ],
    "id" : "obj-9",
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "toggle",
    "numoutlets" : 1,
    "outlettype" : [ "int" ],
    "patching_rect" : [ 584.0, 445.0, 20.0, 20.0 ],
    "id" : "obj-5",
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "number",
    "numoutlets" : 2,
    "outlettype" : [ "int", "bang" ],
    "patching_rect" : [ 584.0, 377.0, 50.0, 20.0 ],
    "id" : "obj-4",
    "fontname" : "Arial",
    "fontsize" : 12.0,
    "numinlets" : 1
    }
    }
    , {
    "box" : {
    "maxclass" : "newobj",
    "text" : "select 50",
    "numoutlets" : 2,
    "outlettype" : [ "bang", "" ],
    "patching_rect" : [ 584.0, 413.0, 59.0, 20.0 ],
    "id" : "obj-3",
    "fontname" : "Arial",
    "fontsize" : 12.0,
    "numinlets" : 2
    }
    }
    , {
    "box" : {
    "maxclass" : "slider",
    "numoutlets" : 1,
    "outlettype" : [ "" ],
    "patching_rect" : [ 584.0, 210.0, 20.0, 140.0 ],
    "id" : "obj-2",
    "numinlets" : 1
    }
    }
    ],
    "lines" : [ {
    "patchline" : {
    "source" : [ "obj-10", 0 ],
    "destination" : [ "obj-12", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    , {
    "patchline" : {
    "source" : [ "obj-10", 0 ],
    "destination" : [ "obj-6", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    , {
    "patchline" : {
    "source" : [ "obj-7", 0 ],
    "destination" : [ "obj-10", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    , {
    "patchline" : {
    "source" : [ "obj-9", 0 ],
    "destination" : [ "obj-7", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    , {
    "patchline" : {
    "source" : [ "obj-3", 0 ],
    "destination" : [ "obj-5", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    , {
    "patchline" : {
    "source" : [ "obj-4", 0 ],
    "destination" : [ "obj-3", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    , {
    "patchline" : {
    "source" : [ "obj-2", 0 ],
    "destination" : [ "obj-4", 0 ],
    "hidden" : 0,
    "midpoints" : [ ]
    }
    }
    ]
    }

    • May 14 2011 | 1:17 pm
      Try using the [change] object.
    • May 14 2011 | 4:26 pm
      for the second part u could use the onebang object.. so it bangs only the first time ur under 30 and then reset it through the right inlet when ur over 30 again
    • May 14 2011 | 10:12 pm
      Hi Bluelemur, intriguing how difficult that is and interesting that the selewct doesn't pick up on the number when you move the slider really fast. I tried fixing your problem with the onebang as kestaya said but this doesn't work because of the if object repeatedly evaluating the incoming value and so repeatedly outputting a 1 or a 0 every time the number changes. I have however made this which should fix your problem, although there must be a better way of doing this.
      Let me know how you do
      Benny
    • May 14 2011 | 11:20 pm
      as Luke said the change object helps a lot in this situation. You could adapt Benny's patch and incorporate [change], or use this patch
      `
      edit: or use [togedge]