{"id":586,"date":"2019-12-19T07:47:01","date_gmt":"2019-12-19T07:47:01","guid":{"rendered":"https:\/\/www.hfsignals.com\/?page_id=586"},"modified":"2024-09-05T16:00:19","modified_gmt":"2024-09-05T16:00:19","slug":"bfo-tuning-aid","status":"publish","type":"page","link":"https:\/\/www.hfsignals.com\/index.php\/bfo-tuning-aid\/","title":{"rendered":"BFO tuning Aid"},"content":{"rendered":"<p><script type=\"text\/javascript\"><\/p>\n<p>var samplingRate = 44100;<\/p>\n<p>function canvasDrawLine(oPosX, oPosY, fPosX, fPosY) {\n    var ctx = getCanvas().getContext('2d');\n    ctx.beginPath();\n    ctx.moveTo(oPosX, oPosY);\n    ctx.lineTo(fPosX, fPosY);\n    ctx.stroke();\n}<\/p>\n<p>function canvasInitialize(width, height) {\n    var c = getCanvas();\n    \/\/ Set canvas parameters\n    c.width = width;\n    c.height = height;<\/p>\n<p>    \/\/ Outline\n    var ctx = c.getContext('2d');\n    ctx.strokeStyle='#000000';\n    ctx.clearRect(0,0,width,height);\n    ctx.strokeRect(0,0,width-1,height);<\/p>\n<p>}<\/p>\n<p>function plotSpectrum(array){\n  \/\/calculate the number of freq bins needed to get to 8000 khz\n  var eachbin = samplingRate \/ 1024;\n  var nbins = 8000\/eachbin;\n  var scale = 374\/nbins;<\/p>\n<p>  canvasInitialize(374,260);<\/p>\n<p>  var ctx = getCanvas().getContext('2d');\n  ctx.fillStyle='#00ff00';\n  for (var i = 0; i < nbins; i++) {\n    ctx.fillRect(i * scale, 259, scale, -array[i]);\n  }\n \n   \/\/draw the lines at 300 hz and 3 KHz\n   ctx.strokeStyle='#ff0000'; \n   var pos3000Hz = (3000 * 1024)\/samplingRate;\n   var pos300Hz = (300 * 1024)\/samplingRate;\n   canvasDrawLine(pos300Hz * scale, 1, pos300Hz * scale, 259);\n   canvasDrawLine(pos3000Hz * scale, 1, pos3000Hz * scale, 259);\n \n}\n \nfunction onSuccess(stream) {\n  var context = new AudioContext();\n  var mediaStreamSource = context.createMediaStreamSource(stream);\n  var analyser = context.createAnalyser(); \n  analyser.smoothingTimeConstant = 0.3; \n  samplingRate = analyser.context.sampleRate;\n  document.getElementById(\"sampling_rate\").innerHTML = analyser.context.sampleRate + \"Hz\";\n  analyser.fftSize = 1024; \n \n  var javascriptNode = context.createScriptProcessor(2048, 1, 1); \n \n  javascriptNode.onaudioprocess = function(e) { \n    var array = new Uint8Array(analyser.frequencyBinCount); \n    samplingRate = analyser.context.sampleRate;\n    analyser.getByteFrequencyData(array); \n    plotSpectrum(array);\n  };\n \n  \/\/stream -> mediaSource -> analyser -> javascriptNode -> destination\n  mediaStreamSource.connect(analyser);\n  analyser.connect(javascriptNode);\n  javascriptNode.connect(context.destination);\n}<\/p>\n<p>function onError(err) {\n    alert('Error: You must allow access to the microphone.\\n('+err+')');\n    console.log(\"error: \"+err);\n}<\/p>\n<p>function log(logVal) {\n    getLog().innerHTML = logVal + '\\n<br \/>';\n}<\/p>\n<p>function getCanvas() {\n    return document.getElementById('mycanvas');\n}    <\/p>\n<p>function getLog() {\n    return document.getElementById('mylog');\n}<\/p>\n<p>\/* this code rewritten by Reed, thanks! *\/\nfunction documentReady() {\n    console.log(\"documentReady called\");\n    if('getUserMedia' in navigator) {\n        console.log(\"found navigator.getUserMedia\");\n        navigator.getUserMedia({video: false, audio: true}, onSuccess, onError);\n    }else if('webkitGetUserMedia' in navigator) {\n        console.log(\"found navigator.webkitGetUserMedia\");\n        navigator.webkitGetUserMedia({video: false, audio: true}, onSuccess, onError);\n    } else if('mediaDevices' in navigator && 'getUserMedia' in navigator.mediaDevices){\n        console.log(\"found navigator.mediaDevices.getUserMedia\");\n        navigator.mediaDevices.getUserMedia({video: false, audio: true}).then(onSuccess).catch(onError);\n    } else {\n        console.log(\"No suitable input found\");\n    }\n}\ndocumentReady();\n<\/script><\/p>\n<ol>\n<li>Attach your hands free to your phone or computer<\/li>\n<li>Keep the mic an inch away from the radio&#8217;s speaker.<\/li>\n<li>In the settings, choose &#8220;Setup BFO&#8221;. Tune the knob until the noise graph is centered apporximately between the two red lines of 300 Hz and 3 KHz<\/li>\n<li>Press the encoder button again to save the settings<\/li>\n<\/ol>\n<p><canvas id=\"mycanvas\"><\/canvas><\/p>\n<p>Sampling Rate: <span id=\"sampling_rate\"><\/span><\/p>\n<div id=\"mylog\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Attach your hands free to your phone or computer Keep the mic an inch away from the radio&#8217;s speaker. In the settings, choose &#8220;Setup BFO&#8221;. Tune the knob until the noise graph is centered apporximately between the two red lines of 300 Hz and 3 KHz Press the encoder button again to save the settings &hellip; <a href=\"https:\/\/www.hfsignals.com\/index.php\/bfo-tuning-aid\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;BFO tuning Aid&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-586","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/pages\/586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/comments?post=586"}],"version-history":[{"count":26,"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/pages\/586\/revisions"}],"predecessor-version":[{"id":1063,"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/pages\/586\/revisions\/1063"}],"wp:attachment":[{"href":"https:\/\/www.hfsignals.com\/index.php\/wp-json\/wp\/v2\/media?parent=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}