{"id":112,"date":"2007-10-10T22:05:05","date_gmt":"2007-10-11T03:05:05","guid":{"rendered":"http:\/\/www.tigoe.net\/pcomp\/code\/category\/code\/arduinowiring\/112"},"modified":"2007-10-30T10:24:40","modified_gmt":"2007-10-30T15:24:40","slug":"analog-to-frequency-for-maxmsp","status":"publish","type":"post","link":"https:\/\/www.tigoe.com\/pcomp\/code\/arduinowiring\/112\/","title":{"rendered":"Analog to Frequency for Max\/MSP"},"content":{"rendered":"<p>This Max\/MSP patch takes a serial string in and converts it to a numeric value, then plays a frequency using the value.<\/p>\n<p>To use the patch, copy the text and paste it into a new max patch window.<\/p>\n<p>Thanks to David Mellis and Jamie Allen for the collaboration. These patches were written for a one-day Arduino workshop at NIME 07 hosted by the three of us. The Arduino program comes from the Arduino example files, by David Mellis.<\/p>\n<p><!-- technorati tags start --><\/p>\n<p style=\"text-align:right;font-size:10px;\">Technorati Tags: <a href=\"http:\/\/www.technorati.com\/tag\/pcomp\" rel=\"tag\">pcomp<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/physical computing\" rel=\"tag\">physical computing<\/a><\/p>\n<p><!-- technorati tags end --><br \/>\n<!--more--><br \/>\n<a href=\"https:\/\/tigoe.com\/pcomp\/code\/wp-content\/uploads\/2007\/10\/analogtofrequency.png\" title=\"analogtofrequency.png\"><img decoding=\"async\" src=\"https:\/\/tigoe.com\/pcomp\/code\/wp-content\/uploads\/2007\/10\/analogtofrequency.thumbnail.png\" alt=\"analogtofrequency.png\" \/><\/a><\/p>\n<pre>max v2;\n#N vpatcher 193 214 742 698;\n#P user multiSlider 299 322 125 91 0. 1023. 1 3449 15 0 0 2 0 0 0;\n#M frgb 0 0 0;\n#M brgb 255 255 255;\n#M rgb2 127 127 127;\n#M rgb3 0 0 0;\n#M rgb4 37 52 91;\n#M rgb5 74 105 182;\n#M rgb6 112 158 18;\n#M rgb7 149 211 110;\n#M rgb8 187 9 201;\n#M rgb9 224 62 37;\n#M rgb10 7 114 128;\n#P window setfont \"Sans Serif\" 9.;\n#P comment 278 81 191 196617 Click here to get a list of serial ports;\n#P comment 144 236 112 196617 Here's your frequency;\n#P comment 331 214 215 196617 Convert ASCII to symbol;\n#P comment 331 191 215 196617 Convert integer to ASCII;\n#P number 263 235 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;\n#P newex 263 214 62 196617 fromsymbol;\n#B color 5;\n#P newex 263 191 40 196617 itoa;\n#B color 5;\n#P newex 263 168 55 196617 zl group 4;\n#P newex 207 130 67 196617 select 10 13;\n#P toggle 207 37 15 0;\n#P newex 207 59 52 196617 metro 10;\n#P message 242 81 32 196617 print;\n#P newex 207 106 71 196617 serial a 9600;\n#P window linecount 2;\n#P comment 12 59 191 196617 Read serial input buffer every 10 milliseconds;\n#P window linecount 3;\n#P comment 280 130 215 196617 If you get newline (ASCII 10) , send the list. If you get return (ASCII 13) do nothing. Any other value , add to the list;\n#P window linecount 1;\n#P comment 234 37 100 196617 Click to start;\n#P comment 60 255 196 196617 digital-to-analog converter makes sounds;\n#P comment 363 276 215 196617 Click to stop frequency generator;\n#P comment 363 255 215 196617 Click to start frequency generator;\n#P message 330 276 29 196617 stop;\n#P message 321 255 33 196617 start;\n#P newex 263 299 31 196617 dac~;\n#P newex 263 255 40 196617 cycle~;\n#P connect 13 0 12 0;\n#P fasten 11 0 10 0 247 101 212 101;\n#P connect 12 0 10 0;\n#P connect 10 0 14 0;\n#P fasten 14 2 15 0 268 171 268 171;\n#P fasten 14 0 15 0 212 159 268 159;\n#P connect 15 0 16 0;\n#P connect 16 0 17 0;\n#P connect 17 0 18 0;\n#P connect 18 0 0 0;\n#P connect 0 0 1 0;\n#P fasten 2 0 1 0 326 284 268 284;\n#P fasten 3 0 1 0 335 295 268 295;\n#P fasten 18 0 23 0 268 280 304 280;\n#P pop;\n<\/pre>\n<p>Arduino code that sends in an analog value in the appropriate format:<\/p>\n<pre>void setup()\n{\n  Serial.begin(9600);\n}\n\nvoid loop()\n{\n  int val = analogRead(0);\n  Serial.println(val, DEC);\n  delay(100);\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This Max\/MSP patch takes a serial string in and converts it to a numeric value, then plays a frequency using the value.To use the patch, copy the text and paste it into a new max patch window.Thanks to David Mellis and Jamie Allen for the collaboration.max v2;#N vpatcher 193 214 742 698;#P user multiSlider 299 322 125 91 0&#8230;.  1 3449 15 0 0 2 0 0 0;#M frgb 0 0 0;#M brgb 255 255 255;#M rgb2 127 127 127;#M rgb3 0 0 0;#M rgb4 37 52 91;#M rgb5 74 105 182;#M rgb6 112 158 18;#M rgb7 149 211 110;#M rgb8 187 9 201;#M rgb9 224 62 37;#M rgb10 7 114 128;#P window setfont &#8220;Sans Serif&#8221; 9.;#P comment 278 81 191 196617 Click here to get a list of serial ports;#P comment 144 236 112 196617 Here&#8217;s your frequency;#P comment 331 214 215 196617 Convert ASCII to symbol;#P comment 331 191 215 196617 Convert integer to ASCII;#P number 263 235 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;#P newex 263 214 62 196617 fromsymbol;#B color 5;#P newex 263 191 40 196617 itoa;#B color 5;#P newex 263 168 55 196617 zl group 4;#P newex 207 130 67 196617 select 10 13;#P toggle 207 37 15 0;#P newex 207 59 52 196617 metro 10;#P message 242 81 32 196617 print;#P newex 207 106 71 196617 serial a 9600;#P window linecount 2;#P comment 12 59 191 196617 Read serial input buffer every 10 milliseconds;#P window linecount 3;#P comment 280 130 215 196617 If you get newline (ASCII 10) \\, send the list.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,15],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-arduinowiring","category-MaxMSP"],"_links":{"self":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":0,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}