help finding a logic max object

  • hi.
    i'm trying my hand at programming a patch and i'm wondering if you all can help me or point me in the right direction..

    i want to find some kind of logic object or combination of objects that compares a incoming integer value off a dial object to the previous value off that dial object.

    my idea is that if the value is greater than the previous value a button will toggle on. if the value is less than the previous value the button will toggle off.

    i hope this is clear. probably seems like a simple to most of you, but like i said, i'm new to this so after browsing about a dozen objects, i thought i'd turn to the experts.

    thanks.

  • there are (as usual) a number of ways you could go about doing this...

    one of the simplest would be with [change] objects, e.g.

    ----------begin_max5_patcher----------
    441.3ocyUssbCBBD8Y8qfgWaRFD7RReqeGcxzAURCcTHihSSal7uWDzDSSZp
    MU6zW1cXYc4bN6Bty0AFK2xJgf6AOBbb1453XBUGvoYsCLmtMIiVZRClHyyY
    BEbhcOEaqxDmuBvU.dIHkkTvnkbwys4rRJTk72Y044glgZBugpRVqS6oBVhx
    BARDQuMvKBabAHia9LDXYyGIpx4hLlx.FuNGfflaN.3CEbZV6QySMwjwuL0K
    .drFxJUaQP0A265ValLTh.Wb6h.lDTSaLhLBh.Y3Dg3JkRJZqmsXp21vrr.F
    S0j+.juTy1egsYSrzs0dcZ1gLKtLW7FctTvJ0cephKEc6a91F17vZGpwbME.
    GDXUfvaTAhFNEPvdUWwylnSVqoNCf.S+RwANQO3WeYv5N.9ev0d+HiNPLJPv
    7Abf+Kl2IifBc2HpP3fvNJT3P9j.d3TnzNmvYhvpLIUc8GDvFRFZr9nVauuM
    3882FL0BlwEe9mdF3TG+T5UJqJRZYPy7D3HhRYkJtv7PPmbVbRNq4ooLy1s8
    2bd5FodPnABfkWTp6Khv8.QQ+oHxqGHh7uCQ3eAhzK169APFMRBf
    -----------end_max5_patcher-----------

    also, this isn't the most practical solution as it stands, because you will be sending so many more bang messages than necessary, if you only need to toggle it on/off. in this case you could use a [onebang] object to provide "traffic control".

    ----------begin_max5_patcher----------
    681.3ocyWssbaBCD8Y7WwN7Zc7fj3hou0uiNY5HCxAkAj7.x0tMS92qt.MjD
    eA6ho9EogUx6dNGs6J4Wl44uRtm03CeE9N348xLOOqIiAu1u87qn6yJoM1s4
    mIqpXBk+b2ZJ1dk0NilU.RAaEU7DriWVBzxR4NPUvf075FEXWQUTK29Twbic
    ArixUMvVghWZ2XNmVBEzFnR9SVNvEVqxMajMbkY4ZVlhKE.UAkLp1oRQFaNr
    hsVVy.pPp2esKRYTAnAKqKjK5fbIWvxj5fZvcTqw0Rgpg+alwFJXQPq4MTUV
    AW7zOLA1IS3PrdYfPrSnkKMSwgKBfGa+QhsUbQISYELTu.HnU1.3+sZMQ6vC
    O2ZSt54GPg9u4C4VUmSBLFec1Lyv7AdPsZqRIEc9y4L0u1vbrv2nQ9+ExGfm
    DRpgY3TKAwAcimll8IC5vjA8efL3XjiLwWIYVNdbQv1o83mJf5pcPmlky+Ha
    OVlaMqQWmRMkK8OUQIVtGEYlBZGNYdfKeGGRLSQKcY8GS5vWR5dzgEU78qnd
    nLKhSdvit7DNdxyw5ZyWCbEvafbVVstgJ2HFWpDPRrR.Jw0QLJ3zZvk0QLZ7
    5HdVQfKtdQ.kD4DgjafHPtitVHL0wSxU1IM8N5Vgn1yrq8Vgja9sBYEZRvf.
    3giRSS2KtIs1McE8vHgtjVRvP5gcQotGIykbCTnubCUHbTbOEJdLKtwimBk2
    KBeRDVWJopSWZisjL1NFFzMN7G7c9pAquru.+C+oCKbL1eO8Zjaqy5XP6SFf
    2PTNqQwE123zaOlGd1aSE77blc8tC3Jd9FoNSnECviGTqGJjBG.jVN4HBcFD
    E8t8bqQzPN1BmTDkLPDMcmZoC.QQSJhPC.Q36NDQlTDgG.hRlTDQF.hR+GPj
    9iWm8GvCdNj+
    -----------end_max5_patcher-----------

    sorry that this is pretty quick and dirty, but hope it helps!

    EDIT: if you wanted to use logical operations, you could do something like this with the "if" object:

    [if $i1>$i2 then bang out1 else out2 bang]

  • I'd use [bucket] and a comparison object like [>]. Here's an example. You can insert a [change] at the very end if you only want to report direction changes, rather than the result for every input.


    ----------begin_max5_patcher----------
    374.3ocuTsraCBCD7r4qvxmoUwlGpsGpT+Nphpb.mjsEriBKpoMJ+6Erg7nh
    z.oQbwKdrWuyriwa8HrYlMpBF8I5qTBYqGgXgpAHMyIrb4ljLYgcaLs5Syr2
    Y9tkP0FzBiTfBsnyMZr.9VUuBWb+jF3URLYInW71ZUB5pYbb0pT9iSpCAh6i
    7ohpuoSaRQWlaJwLEZKtnA0AgesR4NEFnQluKrOUH0RrJxdW7wDSKysowdYM
    HyXGJDnaqCuFammW8feO6KnYwhLE6RRUD4BSZGOiT4+kT6RiQ2LkbFG94q0c
    EAg8xcGrjCFnsJtcMiYkIenvg2Qdv461MQCiu1KAc1NDivs7ziNryZ3gA1ep
    Ci1GFp9lmYjc647KJEaVrLP+620r7sF+T8UXJWmzV3lWKn780NUUffVhfQez
    dp50zCpZIjlprK2Z84P5JS081FJPm1YutuLheR05lQwiJih6AiBFUFI5Ii3i
    FiB5Aih9G8npI679APlPEOE
    -----------end_max5_patcher-----------

  • +1 for the above solution, obviously.



    my max/msp skills may not yet be at the level where i should be offering assistance to others...

  • thanks guys..i guess there is more than one way to skin a cat.

    i have this idea that i'll use a patch like this to control looper in live. the m4l dial will control the speed dial in looper and when the direction of the dial changes, the m4l toggles/buttons will activate the reverse button on the looper device. i imagine it will be a pretty great effect, possibly emulating 'scratching' the sample as if a record.

    is it possible to set up mapping in live for m4l patches to control parameters of a separate device on another track?

  • yes. you can directly call and set the state of live objects and devices, look into live.path and live.object, and the 'Live Object Model' in general.