{"id":435,"date":"2010-01-20T21:43:55","date_gmt":"2010-01-20T19:43:55","guid":{"rendered":"http:\/\/www.larsby.com\/johan\/?p=435"},"modified":"2010-01-20T21:43:55","modified_gmt":"2010-01-20T19:43:55","slug":"dronesizer-pt-2","status":"publish","type":"post","link":"http:\/\/www.larsby.com\/johan\/2010\/01\/dronesizer-pt-2\/","title":{"rendered":"Dronesizer pt 2"},"content":{"rendered":"<p>So I&#8217;m like working on my dronesizer, and I&#8217;m like not getting so far ahead as I like to, but like, I wanna show it anyways. So I&#8217;ve made a little movie:<\/p>\n<p><object width=\"425\" height=\"344\"><param name=\"movie\" value=\"http:\/\/www.youtube.com\/v\/RCDCotDyBis&#038;hl=en_US&#038;fs=1&#038;\"><\/param><param name=\"allowFullScreen\" value=\"true\"><\/param><param name=\"allowscriptaccess\" value=\"always\"><\/param><\/object><\/p>\n<p>Basically it is a resistor ladder digital to analog converter, check out the <a href=\"http:\/\/www.uchobby.com\/index.php\/2008\/01\/08\/arduino-audio-dac-options\/\">R2R DAC<\/a> if you want to build one. I added LED&#8217;s as well. I&#8217;ve also added 6 potentiometers. Just do <a href=\"http:\/\/www.arduino.cc\/en\/Tutorial\/Potentiometer\">this<\/a> 6 times \ud83d\ude42<\/p>\n<p>It&#8217;s as easy as that. Now I need to add more sound options and tighten the void loop() function because it&#8217;s dead slow right now.<\/p>\n<pre lang=\"cpp\">\/\/audio out variables\r\nfloat TEMP= 0.0;\r\n\r\n#define SINC_LENGTH 32 \r\n\r\nfloat sinC[3][SINC_LENGTH] = {\r\n  {\/\/sinus\r\n    0.59754515,0.69134176,0.7777851,0.8535534,0.9157348,0.96193975,0.9903926,1.0,0.9903927,0.9619398,0.9157348,0.8535534,0.77778506,0.69134164,0.597545,0.49999985,0.40245464,0.30865806,0.22221464,0.14644638,0.08426499,0.03806007,0.009607285,0.0,0.009607464,0.038060457,0.08426553,0.14644706,0.22221544,0.30865896,0.4024556,0.5000008,  }\r\n  ,\r\n  {\/\/saw\r\n    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  }\r\n  ,\r\n  {\/\/tri\r\n    0.03125,0.0625,0.09375,0.125,0.15625,0.1875,0.21875,0.25,0.28125,0.3125,0.34375,0.375,0.40625,0.4375,0.46875,0.5,0.53125,0.5625,0.59375,0.625,0.65625,0.6875,0.71875,0.75,0.78125,0.8125,0.84375,0.875,0.90625,0.9375,0.96875,1.0,  }\r\n};\r\n\r\nint incomingByte = 0;\t\/\/ for incoming serial datar\r\n\r\nint pin0val =0;\r\n\r\nenum waveFormType {\r\n  SIN, SQUARE,TRI,  };\r\n\r\n\/*\r\nfloat vol1=1.0;\r\n float vol2=1.0;\r\n float vol3=1.0;\r\n float vol4=1.0;*\/\r\n\r\nfloat globalHz1 =0.001;\r\nfloat oscCount1=0;\r\n\r\nfloat globalHz2 =0.001;\r\nfloat oscCount2=0;\r\n\r\nfloat globalHz3 =0.001;\r\nfloat oscCount3=0;\r\n\r\nfloat LFOHz =0.001;\r\nfloat lfoCount=0;\r\n\r\nint type=0;\r\n\r\nvoid setup()\r\n{\r\n\r\n  pinMode(8, OUTPUT);\r\n  pinMode(9, OUTPUT);\r\n  pinMode(10, OUTPUT);\r\n  pinMode(11, OUTPUT);\r\n  pinMode(12, OUTPUT);\r\n  pinMode(13, OUTPUT);\r\n  Serial.begin(9600);\r\n\r\n  randomSeed(analogRead(0));\r\n\r\n  \/\/Timer2 setup  This is the audio rate timer, fires an interrupt at 15625 Hz sampling rate\r\n  TIMSK2 = 1&lt;&lt;&lt;SINC_LENGTH)\r\n    oscCount1=0;\r\n  oscCount2+=globalHz2;\r\n  if(oscCount2&gt;SINC_LENGTH)\r\n    oscCount2=0;\r\n  oscCount3+=globalHz3;\r\n  if(oscCount3&gt;SINC_LENGTH)\r\n    oscCount3=0;\r\n  lfoCount+=LFOHz;\r\n  if(LFOHz&gt;SINC_LENGTH)\r\n    LFOHz=0;\r\n\r\n}\r\n\r\nvoid calculateHz(float in,float detune1, float detune2)\r\n{\r\n\r\n  globalHz1 = ((440 * pow(2.0,(in-69.0)\/12.0))\/1562.50);\r\n  globalHz2 = (440 * pow(2.0,(detune1-69.0)\/12.0))\/1562.50;\r\n  globalHz3 = (440 * pow(2.0,(detune2-69.0)\/12.0))\/1562.50;\r\n\r\n  \/*\r\n  Serial.print(\"  \");\r\n   Serial.print(globalHz1*100000, DEC);\r\n   Serial.print(\"  \");\r\n   Serial.print(globalHz2*100000, DEC);\r\n   Serial.print(\"  \");\r\n   Serial.print(globalHz3*100000, DEC);\r\n   *\/\r\n}\r\n\r\nvoid loop()\r\n{\r\n\r\n  LFOHz = (analogRead(3)\/(SINC_LENGTH*10.0));\r\n  type=analogRead(5)\/51;\/\/ 20 modes\r\n  float note = ((analogRead(0)\/1024.0)*100.0);\r\n  calculateHz(note,note-(((analogRead(1)\/1024.0)*2.0)-1.0),note-(((analogRead(2)\/1024.0)*2.0)-1.0));\r\n\r\n  \/*\r\n  Serial.println(\"vol \");\r\n\r\n   Serial.print(vol,DEC);\r\n\r\n   Serial.println(\" LFOHz\");\r\n   Serial.print(LFOHz,DEC);\r\n\r\n   Serial.print(\"analog 1: \");\r\n   Serial.print( analogRead(1),DEC);\r\n\r\n   Serial.print(\"___ analog 2: \");\r\n   Serial.print( analogRead(2),DEC);\r\n\r\n   Serial.print(\" type \");\r\n   Serial.print(type);\r\n\r\n   Serial.print(\" Note \");\r\n   Serial.print((int)(note) );\r\n   Serial.println(\" \");\r\n\r\n   *\/\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">So I&#8217;m like working on my dronesizer, and I&#8217;m like not getting so far ahead as I like to, but like, I wanna show it anyways. So I&#8217;ve made a little movie: Basically it is a resistor ladder digital to analog converter, check out the R2R DAC if you want to build one. I added&#8230; <a class=\"moretag\" href=\"http:\/\/www.larsby.com\/johan\/2010\/01\/dronesizer-pt-2\/\"> <strong>Read More<\/strong><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"episode_type":"","audio_file":"","cover_image":"","cover_image_id":"","duration":"","filesize":"","date_recorded":"","explicit":"","block":"","filesize_raw":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-435","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pEpYd-71","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/posts\/435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/comments?post=435"}],"version-history":[{"count":3,"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/posts\/435\/revisions"}],"predecessor-version":[{"id":444,"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/posts\/435\/revisions\/444"}],"wp:attachment":[{"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/media?parent=435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/categories?post=435"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.larsby.com\/johan\/wp-json\/wp\/v2\/tags?post=435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}