Max Msp with Phidget

nick2price's icon

Hi, this is my first time using max msp so I am very new to this. I have followed the phidget tutorial on how to read the values from my phidget interface kit. I am using a magnetic sensor and the sensor value changes when I move a magnet closer now. With this done, the next step would be to get it to play a sound if the magnet hits a certain number. This, I am tottally unsure of how to do. This is the patch to get the value from my sensors

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

So currently, the sensor values are being displayed in the number boxes at the bottom. I assume the next step would be to carry on a line from these number boxes which uses a == object. Not sure though if this is where i follow on from. Any advise on what I should do would be great, and then I can work on this and get some more follow up from you guys when I proceed.

Cheers for any advise or suggestions
Nick

seejayjames's icon

With sensor data you might not want to use ==, it may not hit that value reliably each time (though it may pass through it). Probably use a > (threshold) instead. Out of any comparison operator comes a 0 or 1 (false/true), so run that into [select 0 1] and the first two inlets will bang when these match. The bangs then become anything you want.

You could also use [scale] on the sensor values, I'm assuming they're pretty broad. So if they're (say) 0-1023, or a precision float between 0. and 1., you can scale to 0-20 or something, and then the comparisons will work more coarsely (21 steps in this case)...which is sometimes beneficial when you want things to trigger reliably, and don't need to be super-precise.

GhostandtheMachine's icon

I have been messing around with a few of the phidget sensors and mostly the 8/8/8 interface. I usually use the 8/8/8 with distance sensors and the accelerometer. I'm not sure if you want to be able to scale values and use the input data to modulate data or use it to trigger. I'll paste in a velocity patch I messed with a few months ago. You can see some youtube videos of some of my sensor based gesture instrument (http://www.youtube.com/watch?v=Yh7pa871bSs] http://www.youtube.com/watch?v=Ux10f9pJfqU
)

you might be able to use this with your magnet sensor if it works similarly (I am guessing you get higher values the closer you get to the sensor with the magnet). Although it might not be just what you wanted, it might be a place to start.

Also, I saw on a post a little while back a simple sensor smoothing method. Since the phidget interface has an adjustable sample rate which is putting out a lot of data when you are at a speed fast enough to feel close to real time, you might want to find a balance of sample speed and smoothing averaging. My go to now is a zl stream 10, to a zl median with the phidget sample rate at 2ms.

Here is the velocity patch I was messing with. Since it simulates a drum you set the hit increase velocity and the decrease (as if you hit the drum and slowed down) as well as a max hit size to minimize false hits.

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

I haven't used it in a little bit so if something is messed up let me know

j