Max/msp and arduino
Hi,
I am doing a project for school and i need to have analog input and output, digital input and output, and communication. So what i want to do is make a song playlist in max and then send that to arduino to control the rgb led.. so it would change colors with the song beats.. can someone help me? im new to this communication stuff and I really need help.
Did the tutor who gave you this task also give you any tools or resources? It's good that you have a fairly clear idea of what you want to achieve with your project, but simply posting a request for "I need a patch that does X, Y and Z for my school project" is unlikely to illicit many responses.
There are some excellent beginner resources below, which may at first seem a little daunting (the sheer volume of material), but look closely and there are many well-written and accessible tutorials.
Arduino:
http://www.arduino.cc/playground/
http://www.ladyada.net/learn/arduino/
http://itp.nyu.edu/physcomp/Intro/HomePage
MaxMSP:
MaxMSP documentation and examples
http://www.peterbatchelor.com/maxTuts.html
I learned all (the little) I know about digital musical environments using only these resources.....(and this forum natch) good luck; any further challenges/glitches/questions, ask this forum.
Brendan
No, I do have on mind what I want to do. I have finished my digital input and output using a button, i've also done the analog input and output using a sensor.. i just want to do the rgb controlled by sound in max. I am just not quite sure how to make a playlist or maybe piano notes that could change the rgb coloring in an arduino.
Thanks for the help and links though :):)
Oh right I see, sorry.
For beat detection perhaps re-post with a topic such as 'beat detection' or something, and look at the [peakamp~] object helpfile; I'm not in front of Max currently, so that's the best I can do at the moment. Playlists can easily be compiled in Max, just look at the helpfiles for [dropfile], [folder](I think), [sfplay~] plus the [preload] /cue message, [sflist~] and [umenu]; also look in the /examples folder in your Cycling74 folder...again, not at Max at the mo so can't be more specific
Best
Brendan
Hi Ha !!!!! I want to achieve the same thing as you but me it's for my pleasure not for school..... I think the best way to start this project is by using maxuino. Maxuino is a bridge between the arduino board and max/msp... Never try but it's where I will start the first operation of my project....
Ben
thanks Brendan :D
Ben i've been reading about maxuino but the problem is that i have no time to explore new stuff :S If you were able to make it work please let me know thanks :)
In my opinion, using pre-built patches and firmware such as Maxuino et al is only useful if you are confident enough to hack or adapt the code/patch to your own needs; let's say, someone at an Intermediate level of programming skill. Quite often this forum features posts from people using these utiities, and then questioning when they don't work as expected, after pulling out the bits they need. Anyway, back to your question........
You say you have achieved both digital and analog in/out; is this through Arduino+Max, or Arduino alone. If you have achieved this, then sending PWM data out the digital pins to your RGB should be child's play. As I said earlier, the best solution would be to post a new thread (here and on the Arduino forum: they are incredibly helpful there too), with a more specific topic.
In the meantime, here is a link to an Arduino program AND Max patch, to control an LED:
Best
Brendan
I have done digital and analog in/out using arduino only. I am not sure PWM is? I am sending data through the serial port to max but i have no idea how to make a playlist that can control the rgb led colors. I have looked at the dimmer example but it doesn't help with the audio. Thanks..
Dood, you gotta use the resources people recommend.......
If you can describe exactly what your hardware and software setup is (sensors, circuits, code, Max patch etc), and exactly what you want the Max patch to do, then we can and will gladly help. It's all a bit vague at the moment, which is why you're not getting more responses......
Brendan
Ok so I am using a button that turns the rgb on and off. when the rgb led is on it blends colors and fades. I am also using a potentiometer and it's all wired up in the arduino. My problem now is making a max patcher that will have a song playlist or just a piano that will be controlled by the potentiometer to change songs or play on the piano is you turn it and then make those piano notes or songs change the led colors. Now I only have this max patcher that sends and receives data.
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Serial object has two required arguments 1) port (as a letter), 2) baud rate (as a number).n[serial "port" "baud"]nnHow to find out port.n1) Click print. Find the letter matched to Arduino's Serial Port. Enter the letter in the object.nn2) Match the baud rate (speed) to the rate listed in the Arduino program. ",
"linecount" : 7,
"numinlets" : 1,
"patching_rect" : [ 100.0, 298.0, 531.0, 103.0 ],
"id" : "obj-22",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "Send and Receive Data from Serial Port",
"numinlets" : 1,
"patching_rect" : [ 15.0, 6.0, 409.0, 29.0 ],
"id" : "obj-21",
"fontname" : "Arial",
"numoutlets" : 0,
"bgcolor" : [ 0.917647, 0.937255, 0.670588, 1.0 ],
"fontsize" : 20.0
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "open and close the serial port (do this when switching applications)",
"linecount" : 3,
"numinlets" : 1,
"patching_rect" : [ 34.0, 215.0, 146.0, 48.0 ],
"id" : "obj-19",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "check which serial ports are available",
"linecount" : 2,
"numinlets" : 1,
"patching_rect" : [ 290.0, 118.0, 117.0, 34.0 ],
"id" : "obj-17",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "number",
"numinlets" : 1,
"patching_rect" : [ 166.0, 110.0, 50.0, 20.0 ],
"id" : "obj-16",
"fontname" : "Arial",
"numoutlets" : 2,
"minimum" : 0,
"outlettype" : [ "int", "bang" ],
"maximum" : 255,
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "send data (0-255)",
"numinlets" : 1,
"patching_rect" : [ 166.0, 85.0, 108.0, 20.0 ],
"id" : "obj-13",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "bang to check for received data (0-255)",
"linecount" : 2,
"numinlets" : 1,
"patching_rect" : [ 16.0, 44.0, 126.0, 34.0 ],
"id" : "obj-12",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "close",
"numinlets" : 2,
"patching_rect" : [ 76.0, 265.0, 39.0, 18.0 ],
"id" : "obj-9",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "" ],
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "open",
"numinlets" : 2,
"patching_rect" : [ 34.0, 265.0, 37.0, 18.0 ],
"id" : "obj-7",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "" ],
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "toggle",
"numinlets" : 1,
"patching_rect" : [ 18.0, 79.0, 20.0, 20.0 ],
"id" : "obj-5",
"numoutlets" : 1,
"outlettype" : [ "int" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "metro 10",
"numinlets" : 2,
"patching_rect" : [ 18.0, 102.0, 58.0, 20.0 ],
"id" : "obj-3",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"fontsize" : 12.0
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "print",
"numinlets" : 2,
"patching_rect" : [ 291.0, 154.0, 33.0, 18.0 ],
"id" : "obj-27",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "" ],
"fontsize" : 11.595187
}
}
, {
"box" : {
"maxclass" : "button",
"numinlets" : 1,
"patching_rect" : [ 18.0, 126.0, 20.0, 20.0 ],
"id" : "obj-34",
"numoutlets" : 1,
"outlettype" : [ "bang" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial a 9600",
"numinlets" : 1,
"patching_rect" : [ 18.0, 356.0, 77.0, 20.0 ],
"id" : "obj-37",
"fontname" : "Arial",
"numoutlets" : 2,
"bgcolor" : [ 1.0, 0.643137, 0.839216, 1.0 ],
"outlettype" : [ "int", "" ],
"fontsize" : 11.595187
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print data",
"numinlets" : 1,
"patching_rect" : [ 18.0, 382.0, 59.0, 20.0 ],
"id" : "obj-40",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 11.595187
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-16", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"midpoints" : [ 175.5, 154.0, 27.5, 154.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-9", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-37", 0 ],
"destination" : [ "obj-40", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-27", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"midpoints" : [ 300.5, 183.0, 27.5, 183.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-34", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-34", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-3", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}
}
]
}
Hello,
Please excuse me if this is a really stupid question but i was wondering if there are any arduino to max bridges that run with Max 4.6?
I'm using MaxMSP 4.6.3 on a MacBook and I have an Arduino Uno. I got an update to max 5 but now none of my patches work and are full of glitches and even when it starts to come to life it freezes and crashes. I really just want to use max 4 because I've put so many hours into my patches I can't face rebuilding them. (it's a sampler/sequencer and granular synth built in the most convoluted and labyrinthine way that only a relative beginner would do!)
Any help would be hugely appreciated. My heart sank when I couldn't find a way.
Thanks in advance,
Ed.
here's a patch with two elements, RGBa control via dial and piano-keboard, and a playlist creator for the [sfplay~] object; copy the text below and go
File/New from Clipboard
Brendan
ps when posting patches, select all, go Edit/Copy Compressed
As pseudo as it gets. Drank beer, can't fix now. Plus if i would what would be the fun?
@edsevenbillion; If you copy in 4.6 and paste in max5.0, is it still messed up then? I had luck with this one before. Good luck!
Aargh, Brendan beat me too it! :)
[get] no such object....
:) Get beer...
Thanks so much FRid. i'll try it.
It didn't like that at all. It ran for all of 5 seconds and then froze right up again. The patch works fine in 4 though. Perhaps Ive used some bits that aren't used in 5 anymore. Ive been working on this patch for years so I can't remember all the parts. It's been one of these ongoing projects.
re. arduino with max 4. you don't happen to know if theres anyway to get them to talk do you? No one has yet been able to answer but it seems crazy that it should be so difficult.
Thanks again for your help.
ed
I've loaded the patch after saving it in 5 after pasting it from 4 and its running ok. Its a bit glitchy. I have to use it in performance so I really dont want it to crash on me during a show. I'll test it for a while and see if it carries on working.
I'll keep looking for a way to use arduino with max 4 in the meantime.
I feel a bit sad leaving max 4 behind (if 5 carries on working that is) I like how square and blocky it is, kind of looks homemade.
Thanks again anyway.
Ed
Isn't there a serial-object in max4? If not and you really want to use 4 why not just route data between 4 and 5?(dirty workaround and not desirable at all but hey) Drawback ofcourse is you would need to take apart all the parts to understand it again.
ah cheers man. That might just do it. Maybe its time to look at the old sampler and build it more efficiently anyway. its all done very clumsily. I'll try that workaround and see.
I'm going to keep testing the patch in 5 for reliability.
Thanks for all your help dude.
all the best,
e
d
@FRid
":) Get beer..."
Friday night? Might just have to :-}
Yep! Plus mandatory drinking because of opening/closing of our exhibition but that goes without saying ofcourse :)
Got the beer in the meantime, starting max, i just love intoxicated coding...
...or intoxicoded cating?
Thanks Brendan for the code. One question.. now I have a potentiometer sending 0-255 to the dial/piano and the frequency but as you can see in the max code below the last keystroke in the piano corresponds to 27 and my potentiometer keeps going up to 9999 and the piano after 27 never plays anything. I am also using the potentiometer to change the frequency and graph but the numbers keep getting very high and change very quickly. I posted my arduino code below too.
arduino code:
int rx_byte; // a variable for receiving data
int sense; // a variable for storing sensor data
void setup()
{
Serial.begin( 9600 ); // start serial port at this speed (match with other software eg. MAX, Processing)
// make pin an output - connect to LED (remember to use => 220ohm resistor)
}
void loop()
{
Serial.println(analogRead(0));
delay(10);
if( Serial.available() > 0 ) { // if we receive a byte:
rx_byte = Serial.read(); // store it,
}
sense = analogRead( 0 ); // read the sensor - returns 0 to 1023
sense = map( sense, 0,1023, 0,255 ); // adjust values to transmit - scale to 0 to 255 (...dividing sense by 4 would do the same)
Serial.print( sense, BYTE); // send the sensor data
}
you need to set the appropriate ranges for both kslider and dial using their Inspectors
do you know what is a good range and to listen to the keyboard playing i send it to what? make note? because the keystrokes are being played but no sound. thank you so much and sorry for bugging you. I'm just very new to this stuff.
look at the helpfiles for:
[makenote]
[noteout]
Created a project on Google Code with an Arduino sketch and a Max patch. The two neatly work together over serial (tested with Bluetooth, too!).