[{"data":1,"prerenderedAt":152},["ShallowReactive",2],{"\u002Ftlt-2013.12.26-overtone-adventures-4":3},{"id":4,"title":5,"body":6,"createdAt":139,"description":12,"draft":140,"extension":141,"image":142,"mastodonThread":142,"meta":143,"navigation":144,"path":145,"seo":146,"stem":147,"tags":148,"updatedAt":150,"__hash__":151},"content\u002FTLT - 2013.12.26 - Overtone Adventures 4.md","TLT_-_2013.12.26_-_Overtone_Adventures_4",{"type":7,"value":8,"toc":136},"minimark",[9,13,30,33],[10,11,12],"p",{},"Tags: Clojure, Overtone, Music",[10,14,15,16,23,24,29],{},"Today I'm playing with ",[17,18,22],"a",{"href":19,"rel":20},"http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FOpen_Sound_Control",[21],"nofollow","Open Sound Control (OSC)",", which is more general-purpose than midi but kinda similar idea. I have an android app on my phone named ",[17,25,28],{"href":26,"rel":27},"https:\u002F\u002Fplay.google.com\u002Fstore\u002Fapps\u002Fdetails?id=com.charlieroberts.Control&hl=en",[21],"Control"," which has a few existing UIs, in my case I'm playing with the multi-touch. I set it to have two touch inputs.",[10,31,32],{},"In my Overtone REPL, I first set it up to listen for OSC events, and dump out whatever events it sees:",[34,35,37,38,47,66,72,106,130],"code",{"clojure":36},"","\n(def server (osc-server 44100 \"osc-clj\"))\n(osc-listen server (fn [msg] (println msg)) :debug)\n**Turn off with:** (osc-rm-listener server :debug)\n",[39,40,45],"pre",{"className":41,"code":43,"language":44},[42],"language-text","\nI got both my laptop and phone on the wifi (which allows peer-to-peer communication) and told the Control app to connect to my laptop server (192.168.0.15 port 44100, in this case). Now when I touch the screen I get a bunch of messages about the generated OSC events. They look like:\n\n","text",[34,46,43],{"__ignoreMap":36},[10,48,49,50,53,54,57,58,61,62,65],{},"{:src-port 45161, ",[51,52],"src-host",{}," 192.168.0.25, ",[55,56],"path",{}," \u002Fmulti\u002F1, ",[59,60],"type-tag",{}," ff, ",[63,64],"args",{}," (0.36825398 0.3961456)}",[39,67,70],{"className":68,"code":69,"language":44},[42],"\nFrom this I see that the path I want to react to is \"\u002Fmulti\u002F1\" and \"\u002Fmulti\u002F2\". Dragging my fingers around, the args are the x and y coordinates normalized to (0..1). For now I'll just make it beep a bit when it gets an event. I'm hooking the first touch up so the X axis generates a frequency, and the second touch up so that the Y axis generates a frequency (just as a test), giving:\n\n",[34,71,69],{"__ignoreMap":36},[10,73,74,75,79,82,83,97,99,100,102,103,105],{},"(osc-handle server \"\u002Fmulti\u002F1\" (fn ",[76,77,78],"span",{},"msg",[80,81],"br",{},"\n(let ",[76,84,85,87,88,90,91,93,94,96],{},[80,86],{},"\nx (nth (",[63,89],{}," msg) 0)",[80,92],{},"\ny (nth (",[63,95],{}," msg) 1)",[80,98],{},"\n(demo 0.1 (saw (+ 100 (* 100 x))))",[80,101],{},"\n)",[80,104],{},"\n))",[10,107,108,109,111,82,113,123,125,126,102,128,105],{},"(osc-handle server \"\u002Fmulti\u002F2\" (fn ",[76,110,78],{},[80,112],{},[76,114,115,87,117,90,119,93,121,96],{},[80,116],{},[63,118],{},[80,120],{},[63,122],{},[80,124],{},"\n(demo 0.1 (saw (+ 100 (* 100 y))))",[80,127],{},[80,129],{},[39,131,134],{"className":132,"code":133,"language":44},[42],"\nEach touch plays for 1\u002F10th of a second, so if I drag around these overlap a bunch. In fact, if I drag around a lot then something gets backed up and the sound is delayed.\n\n",[34,135,133],{"__ignoreMap":36},{"title":36,"searchDepth":137,"depth":137,"links":138},2,[],"2013-12-26T20:41-05:00",false,"md",null,{},true,"\u002Ftlt-2013.12.26-overtone-adventures-4",{"title":5,"description":12},"TLT - 2013.12.26 - Overtone Adventures 4",[149],"blog","2015-10-18T16:07-04:00","6EbkE5YYuIgxGxvQguOBEsGcLcgebkd4ouPOHaDA-n0",1778988314483]