{"id":990,"date":"2018-08-23T13:59:38","date_gmt":"2018-08-23T13:59:38","guid":{"rendered":"http:\/\/martindebie.com\/workshop\/?p=990"},"modified":"2019-01-29T13:50:24","modified_gmt":"2019-01-29T13:50:24","slug":"vocal-drawing","status":"publish","type":"post","link":"https:\/\/martindebie.com\/workshop\/vocal-drawing\/","title":{"rendered":"VOCAL DRAWING"},"content":{"rendered":"<h2>VOCAL DRAWING<\/h2>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/TAB 1\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/Code to draw with sound, applying specific drawing for each frequency\/\/\/\/ \r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\r\n\r\n\r\nvoid setup() {\r\n\/\/size of the canvas  \r\n  size(600, 600, P3D);\r\n\/\/color of background  \r\n  background(0);\r\n\/\/element for the sound analysis  \r\n  minim = new Minim(this);\r\n  in = minim.getLineIn();\r\n  fft = new FFT( in.bufferSize(), in.sampleRate() );\r\n\/\/smooth the image  \r\n  smooth();\r\n}\r\n\r\n\r\nvoid draw() {\r\n  analysis(); \r\n  visual();\r\n  interaction();\r\n}\r\n\r\n\/\/ function to draw element trigger by certain frequency\r\nvoid interaction() {\r\n  if (fft.getBand(\/* band number x *\/) &gt; \/* seuil *\/) {\r\n\/\/Draw something\r\n  }\r\n}\r\n\r\n\/\/ function to save image by pressing key 's'\r\nvoid record() {\r\n  if (keyPressed == true) {\r\n    if (key == 'S' || key == 's') {\r\n      int i = 1;\r\n      save(&quot;img&quot;+i+&quot;.png&quot;);\r\n      println(&quot;IMAGE SAVED&quot;);\r\n      i++;\r\n      delay(10);\r\n    }\r\n  }\r\n}\r\n\r\n\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/TAB 2\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/part of the code that analyse frequencies of the sound from the mic\/\/\/\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\r\n\/\/add library minim\r\nimport ddf.minim.analysis.*;\r\nimport ddf.minim.*;\r\n\r\n\/\/declare object\r\nMinim       minim;\r\nAudioInput in;\r\nFFT         fft;\r\n\r\n\/\/number of separate part of frequencies\r\nint nBands = 64;\r\n\r\n\/\/function to analyse sound \r\nvoid analysis() {\r\n  fft.forward( in.mix ); \r\n}\r\n\r\n\/\/function to create a visual feedback to see which frequency is trigger by sound\r\nvoid visual() { \r\n  background(0);\r\n  stroke(0);\r\n  fill(255);  \r\n  for(int i = 0; i &lt; fft.specSize(); i++) {\r\n     if (fft.getBand(i) &lt; 15) {\r\n       fill(255);\r\n     }\r\n     else {\r\n       fill(255, 0, 0);\r\n     }    \r\n    rect(i*(width\/nBands), height, (width\/nBands), -fft.getBand(i)*4);\r\n  }\r\n}\r\n\r\n\/\/ function to get info value from the band where you clicked with the mouse \r\nvoid mousePressed() {\r\n  float bands = map(mouseX, 0, width, 0, nBands);\r\n  int band = int(bands);\r\n  float val = fft.getBand(band);\r\n  \r\n  println(&quot;band:&quot; +band + &quot; \/ value: &quot;+val);\r\n  \r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>VOCAL DRAWING \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \/\/\/\/TAB 1\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \/\/\/\/Code to draw with sound, applying specific drawing for&#8230;<\/p>\n","protected":false},"author":1,"featured_media":996,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-990","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts\/990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/comments?post=990"}],"version-history":[{"count":6,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":2262,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts\/990\/revisions\/2262"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/media\/996"}],"wp:attachment":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/media?parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/categories?post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/tags?post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}