Comparing current value and previous value in a list


    Mar 01 2008 | 12:10 pm
    hi people!
    I need to store incoming acceleration data in some kind of list format, like an array. The list would need to store about 30 incoming values and then eventually empty itself and start again. Would a buffer be better and how would I go about doing this?
    Also I need to be able to compare the current value that has just entered the list, to previous int values within the list. Basically say for example that in order for an acceleration value to trigger a sound, it must be above 135. I want to be able to check back to where the last trigger point occurred, if the incoming values in the list start to decrease below the trigger point. I also want to check how much time has passed since the last trigger point. This is a similar idea to a peak finder!
    I hope this makes sense! Thanks
    A

    • Mar 02 2008 | 7:01 am
      I am not sure if you want to compare two consecutive numbers or all numbers of your list with the current one... comparing two numbers is easy (see patch), also the biggest number out of a list isn't that hard (patch again) - I am sure there is a more efficient way, but it's late...
      Hope this helps and gets you started.
    • Mar 02 2008 | 11:54 am
      hi thanks, I'm having a look at your patch but I'm not 100% sure of what is going on? If you have time could you explain it please!
      Thanks!
    • Mar 02 2008 | 12:49 pm
      Hi sorry just had a look and I understand what is going on now! Based on that patch, would it be possible to create something that takes in acceleration values and only sends an output if they fulfill a condition.
      That the acceleration value is between the maximum and minimum trigger threshold, e.g. >= 120 &&
      If it is between the threshold, before the acceleration value is sent out, It needs to check if it has increased by more than 20 after less than 30 milliseconds since the last hit and if it has then, its value will be subtracted by a certain amount before being outputted!
    • Mar 02 2008 | 1:18 pm
      I'm retired from Oberlin but the teacher in me still kicks in now and then.
      Reading manuals is not a waste of time. There have been several recent posts
      that are almost immediately answered by referring the questioner to a basic
      object. I love newbies but this makes learning max a very long and
      frustrating process.
      Here what I did/do...
      First, read the Max/MSP manuals from cover to cover without trying to get
      every detail. This gives a general understanding of what is there.
      Then, periodically, skim the manual reading only the headers. On the right
      is the name of the object and on the left is a brief description of the
      object. If the object has a graphic representation in the middle of the
      header. I do this about once a week and it takes 10-15 minutes - less each
      time I skim. I also skim the bookmarks in the PDF files stopping to read
      about objects that I don't recognize. What this does is remind me of what is
      in the toolkit. When a need arises for a particular function I can usually
      answer by telling myself that that function does exist. Saves me the time
      in trying to write it myself.
      I do the same thing - less perfectly (right, ej, st?) - with the third party
      packages that I use regularly.
      Another approach is to use maxobjects.com as a thesaurus. Try searching
      "increment decrement." I got seven items including IncDec with some
      descriptions running to more than 10 lines. It also included gak, a genetic
      algorithm kit that I did not know about. So (sorry to use my professor
      voice) but I learned something useful while looking for something else. Now
      THAT saves time!
      Cheers
      Gary Lee Nelson
      Oberlin College
      www.timara.oberlin.edu/GaryLeeNelson
      On 3/2/08 6:54 AM, "Adam" wrote:
      >
      > hi thanks, I'm having a look at your patch but I'm not 100% sure of what is
      > going on? If you have time could you explain it please!
      >
      > Thanks!
    • Mar 02 2008 | 10:17 pm
      Quote: spondoo@hotmail.com wrote on Sun, 02 March 2008 05:49
      ----------------------------------------------------
      > Hi sorry just had a look and I understand what is going on now! Based on that patch, would it be possible to create something that takes in acceleration values and only sends an output if they fulfill a condition.
      >
      > That the acceleration value is between the maximum and minimum trigger threshold, e.g. >= 120 &&
      Your answer is in the question. Use >= and
      >
      > If it is between the threshold, before the acceleration value is sent out, It needs to check if it has increased by more than 20 after less than 30 milliseconds since the last hit and if it has then, its value will be subtracted by a certain amount before being outputted!
      Maybe look at timer???