Distance Sensor, Arduino, Max and routing a range of input to a tone

Feb 19, 2010 at 5:57pm

Distance Sensor, Arduino, Max and routing a range of input to a tone

Can anyone give me some suggestions on how to do the following:

I’m using an ultrasonic distance sensor hooked up through Arduino. I want to capture the distance data in Max and route a range to specific tones.

for example
1)if something is 600-800cm play a 90hz sine wave
2)if something is 300-600cm play a 900hz sine wave
3)if something is 0-300cm play a 60hz sine wave

I have the cycle~ and frequency part down..i just need to know the best way to route the ranges

I’ve tried using split~ and routing ranges into 3 different cycle~ and audio out objects but when 1) moves past the threshold and plays 2) the 1)just gets stuck at the peak and continues to play. I’d like the transition b/w ranges to be smooth

#48620
Feb 19, 2010 at 8:43pm

using three separate [cycle~] objects is the problem; can you just use one, and use the ranges to trigger discrete frequency values, like this:

– Pasted Max Patch, click to expand. –

if you need something with a little more, um, finesse, then say the word
Brendan

#174821
Feb 19, 2010 at 8:57pm

actually, i like this version better; smooth transitions between frequencies; no doubt someone will suggest something a little more elegant:

– Pasted Max Patch, click to expand. –
#174822
Feb 19, 2010 at 8:59pm

I’m not sure what to do with this. How do I open this patcher in Max? I’m just learning MaxMSP btw.

#174823
Feb 19, 2010 at 9:01pm

nevermind…I just figured it out. Open from clipboard. Wow I had no idea you could do that. Thanks for doing that…i’ll hook it up and get back to you

#174824
Feb 19, 2010 at 9:07pm

well, if you’re programming the Arduino and piping data to MaxMSP, that’s pretty hardcore dood; let me know how you get on

Brendan

#174825
Feb 20, 2010 at 7:04am

I’d stick to one cycle~ and splits and smooth the frequency transition, another option to do smooth switching is a matrix~…

Stefan

– Pasted Max Patch, click to expand. –
#174826
Feb 20, 2010 at 9:25am

@stefan, I was right

“no doubt someone will suggest something a little more elegant”

[matrix~], nice

Brendan

#174827
Feb 22, 2010 at 12:14am

THanks for the help guys..Brendan your second code was working pretty smoothly. Stephan yours def gave it a clean ramp. This is for a school project …i’ll try to post a vid for you guys to see when i’m done. Again, this was extremely helpful!!

#174828

You must be logged in to reply to this topic.