[{"data":1,"prerenderedAt":258},["ShallowReactive",2],{"\u002Ftlt-2013.12.23-overtone-adventures-2":3},{"id":4,"title":5,"body":6,"createdAt":245,"description":12,"draft":246,"extension":247,"image":248,"mastodonThread":248,"meta":249,"navigation":250,"path":251,"seo":252,"stem":253,"tags":254,"updatedAt":256,"__hash__":257},"content\u002FTLT - 2013.12.23 - Overtone Adventures 2.md","TLT_-_2013.12.23_-_Overtone_Adventures_2",{"type":7,"value":8,"toc":242},"minimark",[9,13,28,31,37,177],[10,11,12],"p",{},"Tags: Clojure, Overtone, Music",[10,14,15,16,23,24,27],{},"Today I'm watching ",[17,18,22],"a",{"href":19,"rel":20},"http:\u002F\u002Fyoutu.be\u002FlcRQFGtFiyE",[21],"nofollow","Overtone and ClojureScript"," which is a coding session of someone setting up an web UI to play Overtone stuff. Building a UI like this reminds me of the one-string guitar that I got at an art festival the other day. Clearly home-made, including an energy drink as the echo chamber. And very awesome. Also fun to see someone iterate through their development. Lots of interesting things in there, most of them I can read more or less but doesn't mean I could write them. One thing I noticed was (",[25,26],"use",{}," ...) to pull in instrument libs. I'll try that.",[10,29,30],{},"The Cheat Sheet is interesting, but I don't know enough to actually use a lot of the things on there. Current mission is to get the instruments working.",[10,32,33,34,36],{},"Ah! I need to do (use 'overtone.inst.piano) not (",[25,35],{}," overtone.inst.piano).",[38,39,40,44,47,50,57,60,72,75,78,81,120,149,152,159,174],"ul",{},[41,42,43],"li",{},"Now (piano) plays a note!",[41,45,46],{},"(odoc note) shows that it takes a bunch of params",[41,48,49],{},"(piano 60), (piano 65), etc plays some nice piano notes",[41,51,52,53,56],{},"I looked up named parameteters in clojure. (piano ",[54,55],"note",{}," 65) does what I want",[41,58,59],{},"Achievement unlocked ... I can now use all the intstruments on the cheat sheet!",[41,61,62,63,65,66,68,69,71],{},"Now when I do \"(piano ",[54,64],{}," 60) (piano ",[54,67],{}," 65) (piano ",[54,70],{}," 69)\" (still in REPL) it plays all three notes at once. Need to learn how to sequence things.",[41,73,74],{},"I think I'll go back to that workshop video",[41,76,77],{},"At 13:40 they talk about sequencing things",[41,79,80],{},"Play a piano note in 1 second (at (+ 1000 (now)) (piano))",[41,82,83,84],{},"From their tutorial, I created:\n",[38,85,86,97,100,103,109,112],{},[41,87,88,89,93,94,96],{},"(defn loop-beats ",[90,91,92],"span",{},"time"," (at (+ 500 time) (kick)) (at (+ 1000 time) (open-hat)) (apply-at (+ 1500 time) loop-beats (+ 1500 time) ",[90,95],{},"))",[41,98,99],{},"(loop-beats (now))",[41,101,102],{},"(stop)",[41,104,105,106,108],{},"I don't know exactly what that last ",[90,107],{}," is for. (odoc apply-at) says it is \"argseq\" but gives no explanation.",[41,110,111],{},"In general this is \"temorial recursion\" -- delays a bit before calling back",[41,113,114,115,119],{},"As far as I can tell this ",[116,117,118],"em",{},"does"," create new stack frames! Will eventually run out. I know this because I accidentally put the loop-beats recursion in parens which invoked it.",[41,121,122,123],{},"Following the tutorial, I transformed it to use a metronome:\n",[38,124,125,128,136,139,146],{},[41,126,127],{},"(def metro (metronome 180))",[41,129,88,130,133,134,96],{},[90,131,132],{},"m beat-num"," (at (m (+ 0 beat-num)) (kick)) (at (m (+ 1 beat-num)) (open-hat)) (apply-at (m (+ 2 beat-num)) loop-beats m (+ 2 beat-num) ",[90,135],{},[41,137,138],{},"Get it started: (loop-beats metro (metro))",[41,140,141,142,145],{},"Change the temp live! (metro ",[143,144],"bpm",{}," 200)",[41,147,148],{},"Stop it (stop)",[41,150,151],{},"Instruments take 'notes' (midi numbers), though some things take hz",[41,153,154,155,158],{},"Symbolic notes can be turned into midi numbers via (note ",[156,157],"a4",{},")",[41,160,161,162,158],{},"Can map a sequence of symbolic notes to midi numbers (map note ",[90,163,164,167,168,167,171],{},[165,166],"e4",{}," ",[169,170],"d4",{},[172,173],"c4",{},[41,175,176],{},"Now I can make a general purpose play-note-sequence function. I'll just make it play on the beat.",[178,179,181,182],"code",{"clojure":180},"","\n(defn play-song [metro beat-num notes]\n  (map-indexed (fn [index n]\n    (at (metro (+ index beat-num)) (piano :note (note n)))\n  ) notes)\n)\n```\n",[38,183,184,222,230,233,236,239],{},[41,185,186,187,158],{},"(play-song metro (metro) ",[90,188,189,167,191,167,193,167,195,167,197,167,199,167,201,167,203,167,206,167,208,167,210,167,212,167,214,167,216,167,218,167,220],{},[165,190],{},[169,192],{},[172,194],{},[169,196],{},[165,198],{},[165,200],{},[165,202],{},[204,205],"a0",{},[169,207],{},[169,209],{},[169,211],{},[204,213],{},[165,215],{},[165,217],{},[165,219],{},[204,221],{},[41,223,224,225],{},"OK. Midi time! Looking at ",[17,226,229],{"href":227,"rel":228},"https:\u002F\u002Fgithub.com\u002Fovertone\u002Fovertone\u002Fwiki\u002FMIDI",[21],"Overtone wiki MIDI page",[41,231,232],{},"Fired up jack-keyboard (software midi keyboard) since I'm not at home",[41,234,235],{},"Apparently software midi doesn't get immediately detected. \"modprobe snd-virmidi\" gave me something I can connect to in jack",[41,237,238],{},"Had to restart overtone",[41,240,241],{},"Now I have BUNCHES of midi connections when I do (midi-connected-devices) -- like 64 of them. Too many.",{"title":180,"searchDepth":243,"depth":243,"links":244},2,[],"2013-12-25T01:27-05:00",false,"md",null,{},true,"\u002Ftlt-2013.12.23-overtone-adventures-2",{"title":5,"description":12},"TLT - 2013.12.23 - Overtone Adventures 2",[255],"blog","2015-10-18T16:08-04:00","gEqnu9NRgpMUkmgkMZQHlRBZMapbER_gq1JMbBX6XT8",1778988314468]