MAX/MSP Help for new user! senors to trigger audio files.

briang's icon

Hi,
I'm new to MAX and have worked some with arduino and their boards.

I am looking to create an art installation consisting of multiple senors (mainly IR, pressure, motion; from starter packs). It will need to play audio samples real-time from human interaction via sensors.

Question#1- If I have a sensor that is run through to MAX do I need to use an arduino board (something cheaper) and/or can I gang a couple of sensors through that board (Duemilanove) and still get independent signals? I am looking to have 6 to 10 sensors to multiple folders of audio.

Question#2- If I need to make some kind of router or interface what would be the best way via MIDI or USB? I'm looking cheap and DIY.

Question#3- How would I set-up my audio files to have one sensor per audio folder? (for example I have sensor #1 that once triggered would only play audio files from folder #1). That sensor would also need to randomly choose different audio files from only that 1# folder.

Question#4- Once a sensor is triggered and audio is playing, what is the best way to manage the sensor (or audio) being retriggered before the sample has completed?

P.S. I'm running MAX5 on a 1yr old MacBook w/ a express slot

Thanks Brian

pgk's icon

Hi,

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

#1, #2: not sure.
#3: Here is a snippet for getting the paths of audio files from a folder:

you can then use sfplay~ to play the files stored on the unemu. Look at the helpfile.
One nice feature of sfplay~ is that it bangs when it finishes playing. So,

#4: With that bang, in conjunction with some logic, you can sample the next value from your sensor (maybe with [snapshot]?). Look for helpfiles on [gate], [snapshot~] and possibly [onebang].

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

(edit)
Here is an example with sfplay~:

brendan mccloskey's icon

Hi Brian
I think I can address at least some of your queries.

#1 You can access 6 independent analog sensors via the arduino board; if you wish to use more than this number you will need to add a multiplexer to your circuit. You could add switches etc to the digital inputs though.

#2 A router to do what?

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

#3 You don't mention how you are getting serial data into Max: have you built your own patch or are you using an external such as Maxduino, Arduino2Max, SARCduino? Gettin 'random' audiofiles into your [buffer~] is actually quite straightforward; I would use the following:

see the sticky at the top of this forum if you don't know what to do with this garbled text.

#4 [onebang]

Good luck
Brendan

Gregory Taylor's icon

...and let the "end of term project" regatta set sail! :-)

brendan mccloskey's icon

LMAO - if a little cynical Greg, but i think "well-spotted";
in my haste to be helpful, I missed the faint whiff of newbie desperation

Brendan

pgk's icon

Well, at least we left some room for 'free will' no? :)

Panos

brendan mccloskey's icon

@Panos
yes we did;

loved your solution btw

pgk's icon

Hey, Brendan, thanks. On the larger scale of things this patch has served me well. It is usually the first bpatcher I put in any new sf/buffer playback based patch. Usually sprinkled with a named coll object and an uzi to collect paths.

Cheers,
Panos

p.s. @ Gregory: Hey, the other day I was hearing "Seismic Profile". Nicely done! Somehow fits with the wavelength of my brainwaves when programming.

briang's icon

Thanks for the tips, sorry for such the newbie questions. The router was a though as to using a wireless router with a number of shields available for the arduino boards; I was also thinking of MIDI but that is past musician in me (maybe I'm over thinking this).

Thanks,

Brian