Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

3132 lines
122KB

  1. <!DOCTYPE html>
  2. <!-- vim: set ts=4: -->
  3. <html>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="mobile-web-app-capable" content="yes">
  8. <!--
  9. Modified from original Node-Red source, for audio system visualization
  10. Copyright 2013 IBM Corp.
  11. Licensed under the Apache License, Version 2.0 (the "License");
  12. you may not use this file except in compliance with the License.
  13. You may obtain a copy of the License at
  14. http://www.apache.org/licenses/LICENSE-2.0
  15. Unless required by applicable law or agreed to in writing, software
  16. distributed under the License is distributed on an "AS IS" BASIS,
  17. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. See the License for the specific language governing permissions and
  19. limitations under the License.
  20. -->
  21. <head>
  22. <title>Audio System Design Tool for Teensy Audio Library</title>
  23. <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
  24. <link href="jquery/css/smoothness/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" media="screen">
  25. <link rel="stylesheet" type="text/css" href="orion/built-editor.css"/>
  26. <link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css"/>
  27. <link rel="stylesheet" href="style.css">
  28. <style>
  29. table.doc {border-spacing:3px; border-collapse:separate; font-size: 80%}
  30. tr.top {background-color:#C0C0C0}
  31. tr.odd {background-color:#F0F0F0}
  32. tr.even {background-color:#E0E0E0}
  33. p.func {padding-bottom:0; margin:0px}
  34. p.desc {padding-left:2em; margin:0px; padding-top:0.2em; padding-bottom:0.8em; font-size:0.75em}
  35. p.exam {padding-left:2em; text-indent:-1.2em; margin:0px; padding-top:0; padding-bottom:0.5em; font-size:0.75em; font-weight:bold}
  36. pre.desc {padding-left:3em; margin:0px; padding-top:0em; padding-bottom:0.8em; font-size:0.75em;
  37. background-color:#FFFFFF; border:0px; line-height:100%;
  38. }
  39. span.indent {padding-left:2em}
  40. span.literal {color: #006699}
  41. span.comment {color: #777755}
  42. span.keyword {color: #cc6600}
  43. span.function {color: #996600}
  44. span.mainfunction {color: #993300; font-weight: bolder}
  45. </style>
  46. </head>
  47. <body spellcheck="false">
  48. <div class="navbar navbar-inverse navbar-fixed-top">
  49. <div class="navbar-inner">
  50. <div class="container-fluid">
  51. <span class="brand">Audio System Design Tool for <a href="http://www.pjrc.com/teensy/td_libs_Audio.html" target="_blank">Teensy Audio Library</a></span>
  52. <div class="btn-group pull-right">
  53. <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-align-justify"></i> <span class="caret"></span></a>
  54. <ul class="dropdown-menu">
  55. <li><a id="btn-sidebar" tabindex="-1" href="#"><i class="icon-ok pull-right"></i><i class="icon-list-alt"></i> Sidebar</a></li>
  56. <li class="divider"></li>
  57. <!-- <li><a id="btn-node-status" tabindex="-1" href="#"><i class="icon-ok pull-right"></i><i class="icon-info-sign"></i> Node Status</a></li>
  58. <li class="divider"></li> -->
  59. <!--<li class="dropdown-submenu pull-left"><a tabindex="-1" href="#"><i class="icon-edit"></i> Import from...</a>
  60. <ul class="dropdown-menu">
  61. <li><a id="btn-import" tabindex="-1" href="#"><i class="icon-edit"></i> Clipboard...</a></li>
  62. <li id="flow-menu-parent" class="dropdown-submenu pull-left">
  63. <a tabindex="-1" href="#"><i class="icon-book"></i> Library</a>
  64. <ul class="dropdown-menu"></ul>
  65. </li>
  66. </ul>
  67. </li>
  68. <li id="li-menu-export" class="dropdown-submenu disabled pull-left"><a tabindex="-1" href="#"><i class="icon-share"></i> Export to...</a>
  69. <ul class="dropdown-menu">
  70. <li id="li-menu-export-clipboard" class="disabled"><a id="btn-export-clipboard" tabindex="-1" href="#"><i class="icon-share"></i> Clipboard...</a></li>
  71. <li id="li-menu-export-library" class="disabled"><a id="btn-export-library" tabindex="-1" href="#"><i class="icon-book"></i> Library...</a></li>
  72. </ul>
  73. </li>
  74. <li class="divider"></li>-->
  75. <!-- <li><a id="btn-config-nodes" tabindex="-1" href="#"><i class="icon-th-list"></i> Configuration nodes...</a></li>
  76. <li class="divider"></li>-->
  77. <!--<li class="dropdown-submenu pull-left"><a tabindex="-1" href="#"><i class="icon-th-large"></i> Workspaces</a>
  78. <ul id="workspace-menu-list" class="dropdown-menu">
  79. <li><a id="btn-workspace-add" tabindex="-1" href="#"><i class="icon-plus"></i> Add</a></li>
  80. <li><a id="btn-workspace-edit" tabindex="-1" href="#"><i class="icon-edit"></i> Rename</a></li>
  81. <li><a id="btn-workspace-delete" tabindex="-1" href="#"><i class="icon-minus"></i> Delete</a></li>
  82. <li class="divider"></li>
  83. </ul>
  84. </li>
  85. <li class="divider"></li>-->
  86. <li><a id="btn-keyboard-shortcuts" tabindex="-1" href="#"><i class="icon-question-sign"></i> Keyboard Shortcuts</a></li>
  87. <li><a id="btn-help" tabindex="-1" href="http://node-red.github.io/docs" target="_blank"><i class="icon-question-sign"></i> Help...</a></li>
  88. </ul>
  89. </div>
  90. <div class="btn-group pull-left">
  91. <a id="btn-deploy" class="btn action-deploy disabled" href="#"><i id="btn-icn-deploy" class="icon-upload"></i>Export</a>
  92. <a id="btn-import" class="btn action-import disabled" href="#"><i id="btn-icn-download" class="icon-download"></i>Import</a>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div id="main-container" class="sidebar-closed">
  98. <div id="palette">
  99. <img src="img/spin.svg" class="palette-spinner"/>
  100. <div id="palette-container" class="palette-scroll">
  101. </div>
  102. <div id="palette-search">
  103. <i class="icon-search"></i><input id="palette-search-input" type="text" placeholder="filter"><a href="#" id="palette-search-clear"><i class="icon-remove"></i></a></input>
  104. </div>
  105. </div><!-- /palette -->
  106. <div id="workspace">
  107. <ul id="workspace-tabs"></ul>
  108. <!--<div id="workspace-add-tab"><a id="btn-workspace-add-tab" href="#"><i class="icon-plus"></i></a></div>-->
  109. <div id="chart"></div>
  110. <div id="workspace-toolbar">
  111. <div class="btn-group">
  112. <a class="btn btn-small" href="#"><i class="icon-zoom-out"></i></a>
  113. <a class="btn btn-small" href="#"><i class="icon-th"></i></a>
  114. <a class="btn btn-small" href="#"><i class="icon-zoom-in"></i></a>
  115. </div>
  116. </div>
  117. </div>
  118. <div id="chart-zoom-controls">
  119. <div class="btn-group">
  120. <a class="btn btn-mini" id="btn-zoom-out" href="#"><i class="icon-zoom-out"></i></a>
  121. <a class="btn btn-mini" id="btn-zoom-zero" href="#"><i class="icon-th"></i></a>
  122. <a class="btn btn-mini" id="btn-zoom-in" href="#"><i class="icon-zoom-in"></i></a>
  123. </div>
  124. </div>
  125. <div id="sidebar">
  126. <ul id="sidebar-tabs"></ul>
  127. <div id="sidebar-content"></div>
  128. </div>
  129. <div id="sidebar-separator"></div>
  130. </div>
  131. <div id="notifications"></div>
  132. <div id="dropTarget"><div>Drop the flow here</div></div>
  133. <div id="dialog" class="hide"><form id="dialog-form" class="form-horizontal"></form></div>
  134. <div id="node-config-dialog" class="hide"><form id="dialog-config-form" class="form-horizontal"></form><div class="form-tips" id="node-config-dialog-user-count"></div></div>
  135. <div id="node-dialog-confirm-deploy" class="hide">
  136. <form class="form-horizontal">
  137. <div id="node-dialog-confirm-deploy-config" style="text-align: center; padding-top: 30px;">
  138. Some of the nodes are not properly configured. Are you sure you want to deploy?
  139. </div>
  140. <div id="node-dialog-confirm-deploy-unknown" style="text-align: center; padding-top: 10px;">
  141. The workspace contains some unknown node types:
  142. <ul style="width: 300px; margin: auto; text-align: left;" id="node-dialog-confirm-deploy-unknown-list"></ul>
  143. Are you sure you want to deploy?
  144. </div>
  145. </form>
  146. </div>
  147. <div id="node-help" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="node-help-label" aria-hidden="true">
  148. <div class="modal-header">
  149. <h5 id="node-help-label">Keyboard Shortcuts <span style="float: right;"><a href="http://node-red.github.io/docs" target="_blank">Open help in new window &raquo;</a></span></h5>
  150. </div>
  151. <div class="modal-body">
  152. <table>
  153. <tr>
  154. <td><span class="help-key">?</span></td><td>Help</td>
  155. <td><span class="help-key">Ctrl</span> <span class="help-key">a</span></td><td>Select all nodes</td>
  156. </tr>
  157. <tr>
  158. <td><span class="help-key">Ctrl</span> <span class="help-key">Space</span></td><td>Toggle sidebar</td>
  159. <td><span class="help-key">Shift</span> <span class="help-key">Click</span></td><td>Select all connected nodes</td>
  160. </tr>
  161. <tr>
  162. <td><span class="help-key">Ctrl</span> <span class="help-key">z</span></td><td>Undo</td>
  163. <td><span class="help-key">Ctrl</span> <span class="help-key">Click</span></td><td>Add/remove node from selection</td>
  164. </tr>
  165. <tr>
  166. <td></td><td></td>
  167. <td><span class="help-key">Delete</span></td><td>Delete selected nodes or link</td>
  168. </tr>
  169. <tr>
  170. <td><span class="help-key">Ctrl</span> <span class="help-key">x</span></td><td>Cut selected nodes</td>
  171. <td></td><td></td>
  172. </tr>
  173. <tr>
  174. <td><span class="help-key">Ctrl</span> <span class="help-key">c</span></td><td>Copy selected nodes</td>
  175. <td><span class="help-key">Ctrl</span> <span class="help-key">v</span></td><td>Paste nodes</td>
  176. </tr>
  177. <tr>
  178. <td><span class="help-key">Ctrl</span> <span class="help-key">i</span></td><td>Import nodes</td>
  179. <td><span class="help-key">Ctrl</span> <span class="help-key">e</span></td><td>Export selected nodes</td>
  180. </tr>
  181. <tr>
  182. <td colspan="2"></td>
  183. </tr>
  184. <tr>
  185. <td><span class="help-key">Ctrl</span> <span class="help-key">+</span></td><td>Zoom in</td>
  186. <td><span class="help-key">Ctrl</span> <span class="help-key">-</span></td><td>Zoom out</td>
  187. </tr>
  188. </table>
  189. </div>
  190. <div class="modal-footer">
  191. <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
  192. </div>
  193. </div>
  194. <div id="node-dialog-library-save-confirm" class="hide">
  195. <form class="form-horizontal">
  196. <div style="text-align: center; padding-top: 30px;">
  197. A <span id="node-dialog-library-save-type"></span> called <span id="node-dialog-library-save-name"></span> already exists. Overwrite?
  198. </div>
  199. </form>
  200. </div>
  201. <div id="node-dialog-library-save" class="hide">
  202. <form class="form-horizontal">
  203. <div class="form-row">
  204. <label for="node-dialog-library-save-folder"><i class="icon-folder-open"></i> Folder</label>
  205. <input type="text" id="node-dialog-library-save-folder" placeholder="Folder">
  206. </div>
  207. <div class="form-row">
  208. <label for="node-dialog-library-save-filename"><i class="icon-file"></i> Filename</label>
  209. <input type="text" id="node-dialog-library-save-filename" placeholder="Filename">
  210. </div>
  211. </form>
  212. </div>
  213. <div id="node-dialog-library-lookup" class="hide">
  214. <form class="form-horizontal">
  215. <div class="form-row">
  216. <ul id="node-dialog-library-breadcrumbs" class="breadcrumb">
  217. <li class="active"><a href="#">Library</a></li>
  218. </ul>
  219. </div>
  220. <div class="form-row">
  221. <div style="vertical-align: top; display: inline-block; height: 100%; width: 30%; padding-right: 20px;">
  222. <div id="node-select-library" style="border: 1px solid #999; width: 100%; height: 100%; overflow:scroll;"><ul></ul></div>
  223. </div>
  224. <div style="vertical-align: top; display: inline-block;width: 65%; height: 100%;">
  225. <div style="height: 100%; width: 95%;" class="node-text-editor" id="node-select-library-text" ></div>
  226. </div>
  227. </div>
  228. </form>
  229. </div>
  230. <div id="node-dialog-rename-workspace" class="hide">
  231. <form class="form-horizontal">
  232. <div class="form-row">
  233. <label for="node-input-workspace-name" ><i class="icon-tag"></i> Name:</label>
  234. <input type="text" id="node-input-workspace-name">
  235. </div>
  236. </form>
  237. </div>
  238. <div id="node-dialog-delete-workspace" class="hide">
  239. <form class="form-horizontal">
  240. <div style="text-align: center; padding-top: 30px;">
  241. Are you sure you want to delete '<span id="node-dialog-delete-workspace-name"></span>'?
  242. </div>
  243. </form>
  244. </div>
  245. <script type="text/x-red" data-template-name="export-clipboard-dialog">
  246. <div class="form-row">
  247. <label for="node-input-export" style="display: block; width:100%;"><i class="icon-share"></i> Source Code:</label>
  248. <textarea readonly style="font-family: monospace; font-size: 12px; background:rgb(226, 229, 255); padding-left: 0.5em;" class="input-block-level" id="node-input-export" rows="12"></textarea>
  249. </div>
  250. <div class="form-tips">
  251. Select the text above and copy to the clipboard with Ctrl-A Ctrl-C.
  252. </div>
  253. </script>
  254. <script type="text/x-red" data-template-name="export-library-dialog">
  255. <div class="form-row">
  256. <label for="node-input-filename" ><i class="icon-tag"></i> Filename:</label>
  257. <input type="text" id="node-input-filename" placeholder="Filename">
  258. </div>
  259. </script>
  260. <script type="text/x-red" data-template-name="import-dialog">
  261. <div class="form-row">
  262. <label for="node-input-import"><i class="icon-share"></i>Nodes:</label>
  263. <textarea style="font-family: monospace; font-size: 12px; background:rgb(226, 229, 255); padding-left: 0.5em;" class="input-block-level" id="node-input-import" rows="5" placeholder="Paste nodes here, or lookup in the library. When importing Arduino code, the whole flow will be replaced."></textarea>
  264. </div>
  265. <div class="form-tips">
  266. <label for="node-input-arduino" style="font-size: 13px; padding: 2px 0px 0px 4px;">
  267. <input style="margin-bottom: 4px; margin-right: 4px;" type="checkbox" id="node-input-arduino" checked="checked" class="input-block-level" />
  268. &nbsp;Import copied code from the Arduino IDE
  269. </label>
  270. </div>
  271. </script>
  272. <script src="jquery/js/jquery-1.9.1.js"></script>
  273. <script src="bootstrap/js/bootstrap.min.js"></script>
  274. <script src="jquery/js/jquery-ui-1.10.3.custom.min.js"></script>
  275. <script src="jquery/js/jquery.ui.touch-punch.min.js"></script>
  276. <script src="orion/built-editor.min.js"></script>
  277. <script src="red/d3/d3.v3.min.js"></script>
  278. <script src="red/main.js"></script>
  279. <script src="red/ui/state.js"></script>
  280. <script src="red/nodes.js"></script>
  281. <script src="red/storage.js"></script>
  282. <script src="red/history.js"></script>
  283. <script src="red/ui/keyboard.js"></script>
  284. <script src="red/ui/tabs.js"></script>
  285. <script src="red/ui/view.js"></script>
  286. <script src="red/ui/sidebar.js"></script>
  287. <script src="red/ui/palette.js"></script>
  288. <script src="red/ui/tab-info.js"></script>
  289. <script src="red/ui/tab-config.js"></script>
  290. <script src="red/ui/editor.js"></script>
  291. <script src="red/ui/library.js"></script>
  292. <script src="red/ui/notifications.js"></script>
  293. <script src="red/ui/touch/radialMenu.js"></script>
  294. <!-- TODO: generate some or all of this automatically from the C++ source -->
  295. <!-- TODO: add a field for maximum instance count -->
  296. <!-- TODO: add a field for exclusive to other objects (not allowed if they're used) -->
  297. <!-- TODO: add "parameters" fields, to replace the form html stuff -->
  298. <script type="text/javascript">
  299. RED.nodes.registerType('AudioInputI2S',{
  300. shortName: "i2s",
  301. inputs:0,
  302. outputs:2,
  303. category: 'input-function',
  304. color:"#E6E0F8",
  305. icon: "arrow-in.png"
  306. });
  307. </script>
  308. <script type="text/x-red" data-help-name="AudioInputI2S">
  309. <h3>Summary</h3>
  310. <p>Receive 16 bit stereo audio from the
  311. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  312. or another I2S device, using I2S master mode.</p>
  313. <p align=center><img src="img/audioshield_inputs.jpg"></p>
  314. <h3>Audio Connections</h3>
  315. <table class=doc align=center cellpadding=3>
  316. <tr class=top><th>Port</th><th>Purpose</th></tr>
  317. <tr class=odd><td align=center>Out 0</td><td>Left Channel</td></tr>
  318. <tr class=odd><td align=center>Out 1</td><td>Right Channel</td></tr>
  319. </table>
  320. <h3>Functions</h3>
  321. <p>This object has no functions to call from the Arduino sketch. It
  322. simply streams data from the I2S hardware to its 2 output ports.</p>
  323. <h3>Hardware</h3>
  324. <p align=center><img src="img/audioshield_backside.jpg"></p>
  325. <p>The I2S signals are used in "master" mode, where Teensy creates
  326. all 3 clock signals and controls all data timing.</p>
  327. <table class=doc align=center cellpadding=3>
  328. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  329. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  330. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  331. <tr class=odd><td align=center>13</td><td>RX</td><td>Input</td></tr>
  332. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  333. </table>
  334. <p>Audio from
  335. master mode I2S may be used in the same project as ADC, DAC and
  336. PWM signals, because all remain in sync to Teensy's timing</p>
  337. <h3>Examples</h3>
  338. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughStereo
  339. </p>
  340. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  341. </p>
  342. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterStereo
  343. </p>
  344. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; FFT
  345. </p>
  346. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; SpectrumAnalyzerBasic
  347. </p>
  348. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Chorus
  349. </p>
  350. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Flange
  351. </p>
  352. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter
  353. </p>
  354. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter_FIR
  355. </p>
  356. <h3>Notes</h3>
  357. <p>Normally, this object is used with the Audio Shield, which
  358. is controlled separately by the "sgtl5000" object.</p>
  359. <p>Only one I2S input and one I2S output object may be used. Master
  360. and slave modes may not be mixed (both must be of the same type).
  361. </p>
  362. <p>I2S master objects can be used together with non-I2S input and output
  363. objects, for simultaneous audio streaming on different hardware.</p>
  364. </script>
  365. <script type="text/x-red" data-template-name="AudioInputI2S">
  366. <div class="form-row">
  367. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  368. <input type="text" id="node-input-name" placeholder="Name">
  369. </div>
  370. </script>
  371. <script type="text/javascript">
  372. RED.nodes.registerType('AudioInputAnalog',{
  373. shortName: "adc",
  374. inputs:0,
  375. outputs:1,
  376. category: 'input-function',
  377. color:"#E6E0F8",
  378. icon: "arrow-in.png"
  379. });
  380. </script>
  381. <script type="text/x-red" data-help-name="AudioInputAnalog">
  382. <h3>Summary</h3>
  383. <p>Receive audio using the built-in analog to digital converter.</p>
  384. <h3>Audio Connections</h3>
  385. <table class=doc align=center cellpadding=3>
  386. <tr class=top><th>Port</th><th>Purpose</th></tr>
  387. <tr class=odd><td align=center>Out 0</td><td>Audio Channel</td></tr>
  388. </table>
  389. <h3>Functions</h3>
  390. <p>This object has no functions to call from the Arduino sketch. It
  391. simply streams data from the ADC to its output port.</p>
  392. <h3>Hardware</h3>
  393. <p>Pin A2 is used for audio input. This circuitry is recommended.</p>
  394. <p align=center><img src="img/adccircuit.png"></p>
  395. <p>Signal range is 0 to 1.2V</p>
  396. <h3>Examples</h3>
  397. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  398. </p>
  399. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterMono
  400. </p>
  401. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_7segment
  402. </p>
  403. <h3>Notes</h3>
  404. <p>A different pin may be used, but adding it as an parameter
  405. to the AudioInputAnalog object definition.
  406. </p>
  407. <p>For example, to use pin A3:
  408. </p>
  409. <p class=desc><span class=keyword>AudioInputAnalog</span> adc1(<span class=literal>A3</span>);
  410. </p>
  411. <p>Noise due to high source impedance, which allows rapidly switching digital signals
  412. to capacitively couple... avoiding higher analog impedance is the solution.</p>
  413. <p>Power Supply rejection issue with simple DC bias (bigger capacitor may be needed if 3.3V has low frequency noise)</p>
  414. <p>Algorithm for automatic DC bias tracking</p>
  415. <p>TODO: actual noise measurements with different input circuitry
  416. (it's not as quiet as the audio shield)</p>
  417. </script>
  418. <script type="text/x-red" data-template-name="AudioInputAnalog">
  419. <div class="form-row">
  420. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  421. <input type="text" id="node-input-name" placeholder="Name">
  422. </div>
  423. </script>
  424. <script type="text/javascript">
  425. RED.nodes.registerType('AudioInputI2Sslave',{
  426. shortName: "i2ss",
  427. inputs:0,
  428. outputs:2,
  429. category: 'input-function',
  430. color:"#E6E0F8",
  431. icon: "arrow-in.png"
  432. });
  433. </script>
  434. <script type="text/x-red" data-help-name="AudioInputI2Sslave">
  435. <h3>Summary</h3>
  436. <p>Receive 16 bit stereo audio from an I2S device using I2S slave mode.</p>
  437. <h3>Audio Connections</h3>
  438. <table class=doc align=center cellpadding=3>
  439. <tr class=top><th>Port</th><th>Purpose</th></tr>
  440. <tr class=odd><td align=center>Out 0</td><td>Left Channel</td></tr>
  441. <tr class=odd><td align=center>Out 1</td><td>Right Channel</td></tr>
  442. </table>
  443. <h3>Functions</h3>
  444. <p>This object has no functions to call from the Arduino sketch. It
  445. simply streams data from the I2S hardware to its 2 output ports.</p>
  446. <h3>Hardware</h3>
  447. <p>The I2S signals are used in "slave" mode, where the I2S device controls
  448. data timing.</p>
  449. <table class=doc align=center cellpadding=3>
  450. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  451. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Input</td></tr>
  452. <tr class=odd><td align=center>13</td><td>RX</td><td>Input</td></tr>
  453. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Input</td></tr>
  454. </table>
  455. <!--<h3>Examples</h3>
  456. <p class=exam>File &gt; Examples &gt; Audio &gt;
  457. </p>-->
  458. <h3>Notes</h3>
  459. <p>Slave mode I2S <b>should not used in the same project as ADC, DAC and
  460. PWM</b> signals. Differences in timing between the I2S device and
  461. Teensy's clock can cause occasional audio glitches when I2S slave mode
  462. is used together with other input or output objects based on Teensy's
  463. timing.</p>
  464. <p>Only one I2S input and one I2S output object may be used. Master
  465. and slave modes may not be mixed (both must be of the same type).
  466. </p>
  467. </script>
  468. <script type="text/x-red" data-template-name="AudioInputI2Sslave">
  469. <div class="form-row">
  470. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  471. <input type="text" id="node-input-name" placeholder="Name">
  472. </div>
  473. </script>
  474. <script type="text/javascript">
  475. RED.nodes.registerType('AudioOutputI2S',{
  476. shortName: "i2s",
  477. inputs:2,
  478. outputs:0,
  479. category: 'output-function',
  480. color:"#E6E0F8",
  481. icon: "arrow-in.png"
  482. });
  483. </script>
  484. <script type="text/x-red" data-help-name="AudioOutputI2S">
  485. <h3>Summary</h3>
  486. <p>Transmit 16 bit stereo audio to the
  487. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  488. or another I2S device, using I2S master mode.</p>
  489. <p align=center><img src="img/audioshield_outputs.jpg"></p>
  490. <h3>Audio Connections</h3>
  491. <table class=doc align=center cellpadding=3>
  492. <tr class=top><th>Port</th><th>Purpose</th></tr>
  493. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  494. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  495. </table>
  496. <h3>Functions</h3>
  497. <p>This object has no functions to call from the Arduino sketch. It
  498. simply streams data from its 2 input ports to the I2S hardware.</p>
  499. <h3>Hardware</h3>
  500. <p align=center><img src="img/audioshield_backside.jpg"></p>
  501. <p>The I2S signals are used in "master" mode, where Teensy creates
  502. all 3 clock signals and controls all data timing.</p>
  503. <table class=doc align=center cellpadding=3>
  504. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  505. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  506. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  507. <tr class=odd><td align=center>22</td><td>TX</td><td>Output</td></tr>
  508. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  509. </table>
  510. <p>Audio from
  511. master mode I2S may be used in the same project as ADC, DAC and
  512. PWM signals, because all remain in sync to Teensy's timing</p>
  513. <h3>Examples</h3>
  514. <p>Nearly all the examples use this object. Here are some of the highlights:</p>
  515. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughStereo
  516. </p>
  517. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  518. </p>
  519. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  520. </p>
  521. <p class=exam>File &gt; Examples &gt; Audio &gt; WavFilePlayer
  522. </p>
  523. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Chorus
  524. </p>
  525. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  526. </p>
  527. <h3>Notes</h3>
  528. <p>Normally, this object is used with the Audio Shield, which
  529. is controlled separately by the "sgtl5000" object.</p>
  530. <p>Only one I2S input and one I2S output object may be used. Master
  531. and slave modes may not be mixed (both must be of the same type).
  532. </p>
  533. </script>
  534. <script type="text/x-red" data-template-name="AudioOutputI2S">
  535. <div class="form-row">
  536. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  537. <input type="text" id="node-input-name" placeholder="Name">
  538. </div>
  539. </script>
  540. <script type="text/javascript">
  541. RED.nodes.registerType('AudioOutputSPDIF',{
  542. shortName: "spdif",
  543. inputs:2,
  544. outputs:0,
  545. category: 'output-function',
  546. color:"#E6E0F8",
  547. icon: "arrow-in.png"
  548. });
  549. </script>
  550. <script type="text/x-red" data-help-name="AudioOutputSPDIF">
  551. <h3>Summary</h3>
  552. <p>Transmit 16 bit stereo audio as Digital S/PDIF.</p>
  553. <p align=center><img src="img/spdif_proto.jpg"></p>
  554. <h3>Audio Connections</h3>
  555. <table class=doc align=center cellpadding=3>
  556. <tr class=top><th>Port</th><th>Purpose</th></tr>
  557. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  558. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  559. </table>
  560. <h3>Functions</h3>
  561. <p>This object has no functions to call from the Arduino sketch. It
  562. simply streams data from its 2 input ports S/PDIF encoded digital
  563. audio on pin 22.</p>
  564. <h3>Hardware</h3>
  565. <p>The S/PDIF output signal can be used to drive an optical TOSLINK
  566. cable, or a standard (usually orange) RCA jack.</p>
  567. <table class=doc align=center cellpadding=3>
  568. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  569. <tr class=odd><td align=center>22</td><td>S/PDIF</td><td>Output</td></tr>
  570. </table>
  571. <p>For optical TOSLINK output, this
  572. <a href="https://www.oshpark.com/shared_projects/KcDBKHta" target="_blank">OSH Park board</a>
  573. can be used with the inexpensive Everlight PLT133/T6A connector, available
  574. at Digikey, 1080-1434-ND.
  575. </p>
  576. <h3>Examples</h3>
  577. <p>The AudioOutputSPDIF object can be used in place of the AudioOutputI2S object,
  578. <p>used in nearly all the examples. The WavFilePlayer shows how to substitute
  579. output objects for different hardware types.
  580. </p>
  581. <p class=exam>File &gt; Examples &gt; Audio &gt; WavFilePlayer
  582. </p>
  583. <h3>Credits</h3>
  584. <p><a href="https://github.com/FrankBoesing" target="_blank">Frank Boesing</a>
  585. developed the AudioOutputSPDIF code. The original
  586. <a href="https://forum.pjrc.com/threads/28639-S-pdif" target="_blank">forum disussion</a>
  587. included valuable input and code from "kpc".
  588. <h3>Notes</h3>
  589. <p>S/PDIF output uses the I2S hardware. This object can not be used
  590. together with any of the I2S objects, because it requires the I2S
  591. hardware with different internal settings.</p>
  592. </p>
  593. </script>
  594. <script type="text/x-red" data-template-name="AudioOutputSPDIF">
  595. <div class="form-row">
  596. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  597. <input type="text" id="node-input-name" placeholder="Name">
  598. </div>
  599. </script>
  600. <script type="text/javascript">
  601. RED.nodes.registerType('AudioOutputAnalog',{
  602. shortName: "dac",
  603. inputs:1,
  604. outputs:0,
  605. category: 'output-function',
  606. color:"#E6E0F8",
  607. icon: "arrow-in.png"
  608. });
  609. </script>
  610. <script type="text/x-red" data-help-name="AudioOutputAnalog">
  611. <h3>Summary</h3>
  612. <p>Transmit 12 bit audio using Teensy 3.1's built-in digital to analog converter.</p>
  613. <h3>Audio Connections</h3>
  614. <table class=doc align=center cellpadding=3>
  615. <tr class=top><th>Port</th><th>Purpose</th></tr>
  616. <tr class=odd><td align=center>In 0</td><td>Audio Channel</td></tr>
  617. </table>
  618. <h3>Functions</h3>
  619. <p>This object has no functions to call from the Arduino sketch. It
  620. simply streams data from the ADC to its output port.</p>
  621. <h3>Hardware</h3>
  622. <p align=center><img src="img/dacpin.jpg"></p>
  623. <p>Signal range is 0 to 1.2V</p>
  624. <p>Most applications require at least a 10&micro;F DC-blocking capacitor.</p>
  625. <p>TODO: photo of Teensy 3.1 with 10&micro;F capacitor and 3.5mm jack.</p>
  626. <h3>Examples</h3>
  627. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  628. </p>
  629. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  630. </p>
  631. <h3>Notes</h3>
  632. <p>The output rate is 44.1 kHz (no oversampling). Ultrasonic noise present if
  633. not filtered. This may not
  634. be an issue for many uses, but care should be used if amplified and driven
  635. to high power tweeters.</p>
  636. </script>
  637. <script type="text/x-red" data-template-name="AudioOutputAnalog">
  638. <div class="form-row">
  639. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  640. <input type="text" id="node-input-name" placeholder="Name">
  641. </div>
  642. </script>
  643. <script type="text/javascript">
  644. RED.nodes.registerType('AudioOutputPWM',{
  645. shortName: "pwm",
  646. inputs:1,
  647. outputs:0,
  648. category: 'output-function',
  649. color:"#E6E0F8",
  650. icon: "arrow-in.png"
  651. });
  652. </script>
  653. <script type="text/x-red" data-help-name="AudioOutputPWM">
  654. <h3>Summary</h3>
  655. <p>Transmit audio using Teensy 3.1's PWM pins. Two pins are
  656. used for coarse and fine pulses, to be combined by scaled
  657. resistors.</p>
  658. <h3>Audio Connections</h3>
  659. <table class=doc align=center cellpadding=3>
  660. <tr class=top><th>Port</th><th>Purpose</th></tr>
  661. <tr class=odd><td align=center>In 0</td><td>Audio Channel</td></tr>
  662. </table>
  663. <h3>Functions</h3>
  664. <p>This object has no functions to call from the Arduino sketch. It
  665. simply streams data from the its input port to the PWM pins.</p>
  666. <h3>Hardware</h3>
  667. <p>The following circuit is recommended.</p>
  668. <p align=center><img src="img/pwmdualcircuit.jpg"></p>
  669. <p>Signal range is approx 1.55 Vp-p.</p>
  670. <p>These resistor values assume approx 20 ohms output impedance
  671. on the digital pins. The 127K resistor may be adjusted or
  672. trimmed for variation in output drive and tolerance on the
  673. 475 ohm resistor.</p>
  674. <p>A plastic film (Polypropylene, Polyethylene, Polyester, etc) or
  675. C0G/NPO ceramic capacitor should be used for filtering. Low
  676. quality ceramic (X7R, Y5V, Z5U, etc) can cause signal distortion.</p>
  677. <h3>Examples</h3>
  678. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  679. </p>
  680. <h3>Notes</h3>
  681. <p>This object only works properly when Tools > CPU_Speed is set to
  682. 48 or 96 MHz. Other speeds aren't supported and will likely fail
  683. in strange ways.</p>
  684. <p>The PWM carrier frequency is 88.2 kHz. The suggested circuit
  685. will only slightly filter the carrier. Extra filtering will be
  686. required for a clean signal without the ultrasonic PWM carrier.
  687. </p>
  688. <p>Analog signals created by filtering PWM waveforms use the digital
  689. power supply as their reference voltage. Any noise on the digital
  690. power line can directly couple to the output signal. The built-in DAC or
  691. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  692. should be used when higher quality signals are needed.</p>
  693. </script>
  694. <script type="text/x-red" data-template-name="AudioOutputPWM">
  695. <div class="form-row">
  696. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  697. <input type="text" id="node-input-name" placeholder="Name">
  698. </div>
  699. </script>
  700. <script type="text/javascript">
  701. RED.nodes.registerType('AudioOutputI2Sslave',{
  702. shortName: "i2ss",
  703. inputs:2,
  704. outputs:0,
  705. category: 'output-function',
  706. color:"#E6E0F8",
  707. icon: "arrow-in.png"
  708. });
  709. </script>
  710. <script type="text/x-red" data-help-name="AudioOutputI2Sslave">
  711. <h3>Summary</h3>
  712. <p>Transmit 16 bit stereo audio to an I2S device using I2S slave mode.</p>
  713. <h3>Audio Connections</h3>
  714. <table class=doc align=center cellpadding=3>
  715. <tr class=top><th>Port</th><th>Purpose</th></tr>
  716. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  717. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  718. </table>
  719. <h3>Functions</h3>
  720. <p>This object has no functions to call from the Arduino sketch. It
  721. simply streams data from its 2 input ports to the I2S hardware.</p>
  722. <h3>Hardware</h3>
  723. <p>The I2S signals are used in "slave" mode, where the I2S device controls
  724. data timing.</p>
  725. <table class=doc align=center cellpadding=3>
  726. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  727. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Input</td></tr>
  728. <tr class=odd><td align=center>22</td><td>TX</td><td>Output</td></tr>
  729. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Input</td></tr>
  730. </table>
  731. <h3>Examples</h3>
  732. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WM8731MikroSine
  733. </p>
  734. <h3>Notes</h3>
  735. <p>Slave mode I2S <b>should not used in the same project as ADC, DAC and
  736. PWM</b> signals. Differences in timing between the I2S device and
  737. Teensy's clock can cause occasional audio glitches when I2S slave mode
  738. is used together with other input or output objects based on Teensy's
  739. timing.</p>
  740. <p>Only one I2S input and one I2S output object may be used. Master
  741. and slave modes may not be mixed (both must be of the same type).
  742. </p>
  743. </script>
  744. <script type="text/x-red" data-template-name="AudioOutputI2Sslave">
  745. <div class="form-row">
  746. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  747. <input type="text" id="node-input-name" placeholder="Name">
  748. </div>
  749. </script>
  750. <script type="text/javascript">
  751. RED.nodes.registerType('AudioMixer4',{
  752. shortName: "mixer",
  753. inputs:4,
  754. outputs:1,
  755. category: 'mixer-function',
  756. color:"#E6E0F8",
  757. icon: "arrow-in.png"
  758. });
  759. </script>
  760. <script type="text/x-red" data-help-name="AudioMixer4">
  761. <h3>Summary</h3>
  762. <p>Combine up to 4 audio signals together, each with adjustable gain.
  763. All channels support signal attenuation or amplification.</p>
  764. <h3>Audio Connections</h3>
  765. <table class=doc align=center cellpadding=3>
  766. <tr class=top><th>Port</th><th>Purpose</th></tr>
  767. <tr class=odd><td align=center>In 0</td><td>Input signal #1</td></tr>
  768. <tr class=odd><td align=center>In 1</td><td>Input signal #2</td></tr>
  769. <tr class=odd><td align=center>In 2</td><td>Input signal #3</td></tr>
  770. <tr class=odd><td align=center>In 3</td><td>Input signal #4</td></tr>
  771. <tr class=odd><td align=center>Out 0</td><td>Sum of all inputs</td></tr>
  772. </table>
  773. <h3>Functions</h3>
  774. <p class=func><span class=keyword>gain</span>(channel, level);</p>
  775. <p class=desc>Adjust the amplification or attenuation. "channel" must
  776. be 0 to 3. "level" may be any floating point number from 0 to 32767.
  777. 1.0 passes the signal through directly. Level of 0 shuts the channel
  778. off completely. Between 0 to 1.0 attenuates the signal, and above
  779. 1.0 amplifies it. All 4 channels have separate settings.
  780. </p>
  781. <h3>Examples</h3>
  782. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  783. </p>
  784. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  785. </p>
  786. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; SpectrumAnalyzerBasic
  787. </p>
  788. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_Serial
  789. </p>
  790. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  791. </p>
  792. <h3>Notes</h3>
  793. <p>Signal clipping can occur when any channel has gain greater than 1.0,
  794. or when multiple signals add together to greater than 1.0.</p>
  795. <p>More than 4 channels may be combined by connecting multiple mixers
  796. in tandem. For example, a 16 channel mixer may be built using 5
  797. mixers, where the fifth mixer combines the outputs of the first 4.
  798. </p>
  799. </script>
  800. <script type="text/x-red" data-template-name="AudioMixer4">
  801. <div class="form-row">
  802. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  803. <input type="text" id="node-input-name" placeholder="Name">
  804. </div>
  805. </script>
  806. <script type="text/javascript">
  807. RED.nodes.registerType('AudioPlayMemory',{
  808. shortName: "playMem",
  809. inputs:0,
  810. outputs:1,
  811. category: 'play-function',
  812. color:"#E6E0F8",
  813. icon: "arrow-in.png"
  814. });
  815. </script>
  816. <script type="text/x-red" data-help-name="AudioPlayMemory">
  817. <h3>Summary</h3>
  818. <p>Play a short sound clip, stored directly in memory.
  819. Data files are created with the
  820. <a href="https://github.com/PaulStoffregen/Audio/tree/master/examples/SamplePlayer/wav2sketch" target="_blank">wav2sketch program</a>,
  821. and copied to the sketch folder to become part of your sketch.</p>
  822. <h3>Audio Connections</h3>
  823. <table class=doc align=center cellpadding=3>
  824. <tr class=top><th>Port</th><th>Purpose</th></tr>
  825. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  826. </table>
  827. <h3>Functions</h3>
  828. <p class=func><span class=keyword>play</span>(data);</p>
  829. <p class=desc>Begin playing a sound clip. If already playing, the
  830. currently playing clip is stopped and this new data begins
  831. playing from the beginning.
  832. </p>
  833. <p class=func><span class=keyword>stop</span>();</p>
  834. <p class=desc>Stop playing. If not playing, this function has no effect.
  835. </p>
  836. <p class=func><span class=keyword>isPlaying</span>();</p>
  837. <p class=desc>Return true (non-zero) if playing, or false (zero)
  838. when not playing.
  839. </p>
  840. <p class=func><span class=keyword>positionMillis</span>();</p>
  841. <p class=desc>While playing, return the current time offset, in
  842. milliseconds. When not playing, the return from this function
  843. is undefined.
  844. </p>
  845. <p class=func><span class=keyword>lengthMillis</span>();</p>
  846. <p class=desc>Return the total length of the current sound clip,
  847. in milliseconds. When not playing, the return from this function
  848. is undefined.
  849. </p>
  850. <h3>Examples</h3>
  851. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  852. </p>
  853. <h3>Notes</h3>
  854. <p>TODO: supported sample rates: 11.025, 22.05, 44.1</p>
  855. <p>TODO: ulaw vs uncompressed encoding</p>
  856. <p>Polyphonic playback can be built by creating multiple
  857. objects, with their output combined by mixers.</p>
  858. </script>
  859. <script type="text/x-red" data-template-name="AudioPlayMemory">
  860. <div class="form-row">
  861. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  862. <input type="text" id="node-input-name" placeholder="Name">
  863. </div>
  864. </script>
  865. <script type="text/javascript">
  866. RED.nodes.registerType('AudioPlaySdWav',{
  867. shortName: "playSdWav",
  868. inputs:0,
  869. outputs:2,
  870. category: 'play-function',
  871. color:"#E6E0F8",
  872. icon: "arrow-in.png"
  873. });
  874. </script>
  875. <script type="text/x-red" data-help-name="AudioPlaySdWav">
  876. <h3>Summary</h3>
  877. <p>Play a WAV file, stored on a SD card.</p>
  878. <h3>Audio Connections</h3>
  879. <table class=doc align=center cellpadding=3>
  880. <tr class=top><th>Port</th><th>Purpose</th></tr>
  881. <tr class=odd><td align=center>Out 0</td><td>Left Channel Output</td></tr>
  882. <tr class=odd><td align=center>Out 1</td><td>Right Channel Output</td></tr>
  883. </table>
  884. <h3>Functions</h3>
  885. <p class=func><span class=keyword>play</span>(filename);</p>
  886. <p class=desc>Begin playing a WAV file. If a file is already playing,
  887. it is stopped and this file starts playing from the beginning.
  888. </p>
  889. <p class=func><span class=keyword>stop</span>();</p>
  890. <p class=desc>Stop playing. If not playing, this function has no effect.
  891. </p>
  892. <p class=func><span class=keyword>isPlaying</span>();</p>
  893. <p class=desc>Return true (non-zero) if playing, or false (zero)
  894. when not playing. See the note below about delayed start.
  895. </p>
  896. <p class=func><span class=keyword>positionMillis</span>();</p>
  897. <p class=desc>While playing, return the current time offset, in
  898. milliseconds. When not playing, the return from this function
  899. is undefined.
  900. </p>
  901. <p class=func><span class=keyword>lengthMillis</span>();</p>
  902. <p class=desc>Return the total length of the current sound clip,
  903. in milliseconds. When not playing, the return from this function
  904. is undefined.
  905. </p>
  906. <h3>Examples</h3>
  907. <p class=exam>File &gt; Examples &gt; Audio &gt; WavFilePlayer
  908. </p>
  909. <h3>Notes</h3>
  910. <p>Only 16 bit PCM, 44100 Hz WAV files are supported. When mono
  911. files are played, both output ports transmit a copy of the
  912. single sound. Of course, stereo WAV files play with the left
  913. channel on port 0 and the right channel on port 1.
  914. </p>
  915. <p>A brief delay after calling play() will usually occur before
  916. isPlaying() returns true and positionMillis() returns valid
  917. time offset. WAV files have a header at the beginning of the
  918. file, which the audio library must read and parse before
  919. playing can begin.
  920. </p>
  921. <p>While playing, the audio library accesses the SD card automatically.
  922. If card access is required, you must
  923. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">use AudioNoInterrupts()</a>
  924. to prevent the library from accessing the SD card while you use it.
  925. Disabling the audio library interrupt for too long may cause audible
  926. dropouts or glitches.
  927. </p>
  928. </script>
  929. <script type="text/x-red" data-template-name="AudioPlaySdWav">
  930. <div class="form-row">
  931. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  932. <input type="text" id="node-input-name" placeholder="Name">
  933. </div>
  934. </script>
  935. <script type="text/javascript">
  936. RED.nodes.registerType('AudioPlaySdRaw',{
  937. shortName: "playSdRaw",
  938. inputs:0,
  939. outputs:1,
  940. category: 'play-function',
  941. color:"#E6E0F8",
  942. icon: "arrow-in.png"
  943. });
  944. </script>
  945. <script type="text/x-red" data-help-name="AudioPlaySdRaw">
  946. <h3>Summary</h3>
  947. <p>Play a RAW data file, stored on a SD card. RAW format is simpler
  948. than WAV and begins playing immediately, without parsing WAV file
  949. header info.</p>
  950. <h3>Audio Connections</h3>
  951. <table class=doc align=center cellpadding=3>
  952. <tr class=top><th>Port</th><th>Purpose</th></tr>
  953. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  954. </table>
  955. <h3>Functions</h3>
  956. <p class=func><span class=keyword>play</span>(filename);</p>
  957. <p class=desc>Begin playing a RAW data file. If a file is already playing,
  958. it is stopped and this file starts playing from the beginning.
  959. </p>
  960. <p class=func><span class=keyword>stop</span>();</p>
  961. <p class=desc>Stop playing. If not playing, this function has no effect.
  962. </p>
  963. <p class=func><span class=keyword>isPlaying</span>();</p>
  964. <p class=desc>Return true (non-zero) if playing, or false (zero)
  965. when not playing.
  966. </p>
  967. <p class=func><span class=keyword>positionMillis</span>();</p>
  968. <p class=desc>While playing, return the current time offset, in
  969. milliseconds. When not playing, the return from this function
  970. is undefined.
  971. </p>
  972. <p class=func><span class=keyword>lengthMillis</span>();</p>
  973. <p class=desc>Return the total length of the current sound clip,
  974. in milliseconds. When not playing, the return from this function
  975. is undefined.
  976. </p>
  977. <h3>Examples</h3>
  978. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  979. </p>
  980. <h3>Notes</h3>
  981. <p>The data file must be RAW 16 bit signed integers in LSB-first format.
  982. </p>
  983. <p>While playing, the audio library accesses the SD card automatically.
  984. If card access is required, you must
  985. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  986. to prevent the library from accessing the SD card while you use it.
  987. Disabling the audio library interrupt for too long may cause audible
  988. dropouts or glitches.
  989. </p>
  990. </script>
  991. <script type="text/x-red" data-template-name="AudioPlaySdRaw">
  992. <div class="form-row">
  993. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  994. <input type="text" id="node-input-name" placeholder="Name">
  995. </div>
  996. </script>
  997. <script type="text/javascript">
  998. RED.nodes.registerType('AudioPlaySerialflashRaw',{
  999. shortName: "playFlashRaw",
  1000. inputs:0,
  1001. outputs:1,
  1002. category: 'play-function',
  1003. color:"#E6E0F8",
  1004. icon: "arrow-in.png"
  1005. });
  1006. </script>
  1007. <script type="text/x-red" data-help-name="AudioPlaySerialflashRaw">
  1008. <h3>Summary</h3>
  1009. <div>
  1010. <p>Play a RAW data file, stored on a Serial Flash chip. These chips
  1011. are far more efficient than SD cards, allowing many files to be
  1012. played simultaneously by copies of this object.
  1013. </p>
  1014. <p align=center><img src="img/w25q128fv.jpg"><br><small>W25Q128FV Serial Flash</small></p>
  1015. </div>
  1016. <h3>Audio Connections</h3>
  1017. <table class=doc align=center cellpadding=3>
  1018. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1019. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1020. </table>
  1021. <h3>Functions</h3>
  1022. <p class=func><span class=keyword>play</span>(filename);</p>
  1023. <p class=desc>Begin playing a RAW data file. If a file is already playing,
  1024. it is stopped and this file starts playing from the beginning.
  1025. </p>
  1026. <p class=func><span class=keyword>stop</span>();</p>
  1027. <p class=desc>Stop playing. If not playing, this function has no effect.
  1028. </p>
  1029. <p class=func><span class=keyword>isPlaying</span>();</p>
  1030. <p class=desc>Return true (non-zero) if playing, or false (zero)
  1031. when not playing.
  1032. </p>
  1033. <p class=func><span class=keyword>positionMillis</span>();</p>
  1034. <p class=desc>While playing, return the current time offset, in
  1035. milliseconds. When not playing, the return from this function
  1036. is undefined.
  1037. </p>
  1038. <p class=func><span class=keyword>lengthMillis</span>();</p>
  1039. <p class=desc>Return the total length of the current sound clip,
  1040. in milliseconds. When not playing, the return from this function
  1041. is undefined.
  1042. </p>
  1043. <h3>Examples</h3>
  1044. <!--<p class=exam>File &gt; Examples &gt; Audio &gt; Recorder-->
  1045. <p class=exam>TODO: play example needed....
  1046. </p>
  1047. <p class=exam>File &gt; Examples &gt; SerialFlash &gt; CopyFromSD
  1048. </p>
  1049. <h3>Notes</h3>
  1050. <p>The data file must be RAW 16 bit signed integers in LSB-first format.
  1051. </p>
  1052. <p>The <a href="https://github.com/PaulStoffregen/SerialFlash" target="_blank">SerialFlash library</a>
  1053. is used to access the flash chip. You can also use SerialFlash's functions
  1054. to access the stored files, or add data to the flash chip.
  1055. </p>
  1056. <p>File names are case sensitive with SerialFlash. If your sound does
  1057. not play, use <b>File &gt; Examples &gt; SerialFlash &gt; ListFiles</b> to
  1058. check the exact file names stored in the flash memory chip.
  1059. </script>
  1060. <script type="text/x-red" data-template-name="AudioPlaySerialflashRaw">
  1061. <div class="form-row">
  1062. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1063. <input type="text" id="node-input-name" placeholder="Name">
  1064. </div>
  1065. </script>
  1066. <script type="text/javascript">
  1067. RED.nodes.registerType('AudioPlayQueue',{
  1068. shortName: "queue",
  1069. inputs:0,
  1070. outputs:1,
  1071. category: 'play-function',
  1072. color:"#E6E0F8",
  1073. icon: "arrow-in.png"
  1074. });
  1075. </script>
  1076. <script type="text/x-red" data-help-name="AudioPlayQueue">
  1077. <h3>Summary</h3>
  1078. <p>Play audio data provided by the Arduino sketch. This object provides
  1079. functions to allow the sketch code to push data into the audio system.</p>
  1080. <h3>Audio Connections</h3>
  1081. <table class=doc align=center cellpadding=3>
  1082. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1083. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1084. </table>
  1085. <h3>Functions</h3>
  1086. <p class=func><span class=keyword>play</span>(int16);</p>
  1087. <p class=desc>not yet implemented
  1088. </p>
  1089. <p class=func><span class=keyword>play</span>(int16[], length);</p>
  1090. <p class=desc>not yet implemented
  1091. </p>
  1092. <p class=func><span class=keyword>getBuffer</span>();</p>
  1093. <p class=desc>Returns a pointer to an array of 128 int16. This buffer
  1094. is within the audio library memory pool, providing the most efficient
  1095. way to input data to the audio system. The buffer is likely to be
  1096. populated by previously used data, so the entire 128 words should be
  1097. written before calling playBuffer(). Only a single buffer should be
  1098. requested at a time. This function may return NULL if no memory is
  1099. available.
  1100. </p>
  1101. <p class=func><span class=keyword>playBuffer</span>();</p>
  1102. <p class=desc>Transmit the buffer previously obtained from getBuffer().
  1103. </p>
  1104. <h3>Examples</h3>
  1105. <p><a href="http://community.arm.com/groups/embedded/blog/2014/05/23/led-video-panel-at-maker-faire-2014" target="_blank">4320 LED Video+Sound Project</a>
  1106. </p>
  1107. <!--<p class=exam>File &gt; Examples &gt; Audio &gt;
  1108. </p>-->
  1109. <h3>Notes</h3>
  1110. <p>TODO: many caveats....</p>
  1111. <p>
  1112. </p>
  1113. </script>
  1114. <script type="text/x-red" data-template-name="AudioPlayQueue">
  1115. <div class="form-row">
  1116. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1117. <input type="text" id="node-input-name" placeholder="Name">
  1118. </div>
  1119. </script>
  1120. <script type="text/javascript">
  1121. RED.nodes.registerType('AudioRecordQueue',{
  1122. shortName: "queue",
  1123. inputs:1,
  1124. outputs:0,
  1125. category: 'record-function',
  1126. color:"#E6E0F8",
  1127. icon: "arrow-in.png"
  1128. });
  1129. </script>
  1130. <script type="text/x-red" data-help-name="AudioRecordQueue">
  1131. <h3>Summary</h3>
  1132. <p>Record audio data by sending to the Arduino sketch. This object allows
  1133. sketch code to receive audio packets.</p>
  1134. <h3>Audio Connections</h3>
  1135. <table class=doc align=center cellpadding=3>
  1136. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1137. <tr class=odd><td align=center>In 0</td><td>Sound To Access</td></tr>
  1138. </table>
  1139. <h3>Functions</h3>
  1140. <p class=func><span class=keyword>begin</span>();</p>
  1141. <p class=desc>Begin capturing incoming audio to the queue. After calling
  1142. begin, readBuffer() and freeBuffer(), or clear() must be used frequently
  1143. to prevent the queue from filling up.
  1144. </p>
  1145. <p class=func><span class=keyword>available</span>();</p>
  1146. <p class=desc>Returns the number of audio packets available to read.
  1147. </p>
  1148. <p class=func><span class=keyword>readBuffer</span>();</p>
  1149. <p class=desc>Read a single audio packet. A pointer to a 128 sample
  1150. array of 16 bit integers is returned. NULL is returned if no packets
  1151. are available.
  1152. </p>
  1153. <p class=func><span class=keyword>freeBuffer</span>();</p>
  1154. <p class=desc>Release the memory from the previously read packet returned
  1155. from readBuffer(). Only a single packet at a time may be read, and
  1156. each packet must be freed with this function, to return the memory to
  1157. the audio library.
  1158. </p>
  1159. <p class=func><span class=keyword>clear</span>();</p>
  1160. <p class=desc>Discard all audio held in the queue.
  1161. </p>
  1162. <p class=func><span class=keyword>end</span>();</p>
  1163. <p class=desc>Stop capturing incoming audio into the queue. Data already
  1164. captured remains in the queue and may be read with readBuffer().
  1165. </p>
  1166. <h3>Examples</h3>
  1167. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  1168. </p>
  1169. <h3>Notes</h3>
  1170. <p>
  1171. Up to 52 packets may be queued by this object, which allows approximately
  1172. 150 ms of audio to be held in the queue, to allow time for the Arduino
  1173. sketch to write data to media or do other high-latency tasks.
  1174. The actual packets are taken
  1175. from the pool created by AudioMemory().
  1176. </p>
  1177. </script>
  1178. <script type="text/x-red" data-template-name="AudioRecordQueue">
  1179. <div class="form-row">
  1180. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1181. <input type="text" id="node-input-name" placeholder="Name">
  1182. </div>
  1183. </script>
  1184. <script type="text/javascript">
  1185. RED.nodes.registerType('AudioSynthWaveformSine',{
  1186. shortName: "sine",
  1187. inputs:0,
  1188. outputs:1,
  1189. category: 'synth-function',
  1190. color:"#E6E0F8",
  1191. icon: "arrow-in.png"
  1192. });
  1193. </script>
  1194. <script type="text/x-red" data-help-name="AudioSynthWaveformSine">
  1195. <h3>Summary</h3>
  1196. <p>Create a sine wave signal</p>
  1197. <h3>Audio Connections</h3>
  1198. <table class=doc align=center cellpadding=3>
  1199. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1200. <tr class=odd><td align=center>Out 0</td><td>Sine Wave Output</td></tr>
  1201. </table>
  1202. <h3>Functions</h3>
  1203. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1204. <p class=desc>Set the amplitude, from 0 to 1.0.
  1205. </p>
  1206. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1207. <p class=desc>Set the frequency, from 0 to 22000. Very low values may
  1208. be used to create a LFO (Low Frequency Oscillator) for objects
  1209. with modulation signal inputs.
  1210. </p>
  1211. <p class=func><span class=keyword>phase</span>(angle);</p>
  1212. <p class=desc>
  1213. Cause the generated waveform to jump to a specific point within
  1214. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1215. are configured,
  1216. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1217. should be used to guarantee all new settings take effect together.
  1218. </p>
  1219. <h3>Examples</h3>
  1220. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  1221. </p>
  1222. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_Serial
  1223. </p>
  1224. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; FFT
  1225. </p>
  1226. <h3>Notes</h3>
  1227. <p></p>
  1228. </script>
  1229. <script type="text/x-red" data-template-name="AudioSynthWaveformSine">
  1230. <div class="form-row">
  1231. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1232. <input type="text" id="node-input-name" placeholder="Name">
  1233. </div>
  1234. </script>
  1235. <script type="text/javascript">
  1236. RED.nodes.registerType('AudioSynthWaveformSineModulated',{
  1237. shortName: "sine_fm",
  1238. inputs:1,
  1239. outputs:1,
  1240. category: 'synth-function',
  1241. color:"#E6E0F8",
  1242. icon: "arrow-in.png"
  1243. });
  1244. </script>
  1245. <script type="text/x-red" data-help-name="AudioSynthWaveformSineModulated">
  1246. <h3>Summary</h3>
  1247. <p>Create a modulated sine wave, using any audio signal to continuously
  1248. modulate the sine wave frequency.</p>
  1249. <h3>Audio Connections</h3>
  1250. <table class=doc align=center cellpadding=3>
  1251. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1252. <tr class=odd><td align=center>In 0</td><td>Modulation Signal</td></tr>
  1253. <tr class=odd><td align=center>Out 0</td><td>Sine Wave Output</td></tr>
  1254. </table>
  1255. <h3>Functions</h3>
  1256. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1257. <p class=desc>Set the amplitude, from 0 to 1.0.
  1258. </p>
  1259. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1260. <p class=desc>Set the center frequency, from 0 to 11000. The output will
  1261. be this center frequency when the input modulation signal is zero.
  1262. Modulation input 1.0 causes the frequency to double, and input -1.0
  1263. causes zero Hz (DC) output. For less modulation, attenuate the input
  1264. signal (perhaps with a mixer object) before it arrives here.
  1265. </p>
  1266. <p class=func><span class=keyword>phase</span>(angle);</p>
  1267. <p class=desc>
  1268. Cause the generated waveform to jump to a specific point within
  1269. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1270. are configured,
  1271. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1272. should be used to guarantee all new settings take effect together.
  1273. </p>
  1274. <!--<h3>Examples</h3>
  1275. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1276. </p>-->
  1277. <h3>Notes</h3>
  1278. <p></p>
  1279. </script>
  1280. <script type="text/x-red" data-template-name="AudioSynthWaveformSineModulated">
  1281. <div class="form-row">
  1282. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1283. <input type="text" id="node-input-name" placeholder="Name">
  1284. </div>
  1285. </script>
  1286. <script type="text/javascript">
  1287. RED.nodes.registerType('AudioSynthWaveform',{
  1288. shortName: "waveform",
  1289. inputs:0,
  1290. outputs:1,
  1291. category: 'synth-function',
  1292. color:"#E6E0F8",
  1293. icon: "arrow-in.png"
  1294. });
  1295. </script>
  1296. <script type="text/x-red" data-help-name="AudioSynthWaveform">
  1297. <h3>Summary</h3>
  1298. <p>Create a waveform: sine, sawtooth, square, triangle, pulse or arbitrary.</p>
  1299. <h3>Audio Connections</h3>
  1300. <table class=doc align=center cellpadding=3>
  1301. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1302. <tr class=odd><td align=center>Out 0</td><td>Waveform Output</td></tr>
  1303. </table>
  1304. <h3>Functions</h3>
  1305. <p class=func><span class=keyword>begin</span>(waveform);</p>
  1306. <p class=desc>Configure the waveform type to create.
  1307. </p>
  1308. <p class=func><span class=keyword>begin</span>(level, frequency, waveform);</p>
  1309. <p class=desc>Output a waveform, and set the amplitude and frequency.
  1310. </p>
  1311. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1312. <p class=desc>Change the frequency.
  1313. </p>
  1314. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1315. <p class=desc>Change the amplitude. Set to 0 to turn the signal off.
  1316. </p>
  1317. <p class=func><span class=keyword>phase</span>(angle);</p>
  1318. <p class=desc>
  1319. Cause the generated waveform to jump to a specific point within
  1320. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1321. are configured,
  1322. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1323. should be used to guarantee all new settings take effect together.
  1324. </p>
  1325. <p class=func><span class=keyword>pulseWidth</span>(amount);</p>
  1326. <p class=desc>Change the width (duty cycle) of the pulse.</p>
  1327. <p class=func><span class=keyword>arbitraryWaveform</span>(array, maxFreq);</p>
  1328. <p class=desc>
  1329. Configure the waveform to be used with WAVEFORM_ARBITRARY. Array
  1330. must be an array of 256 samples. Currently, the data is used
  1331. without any filtering, which can cause aliasing with frequencies
  1332. above 172 Hz. For higher frequency output, you must bandwidth
  1333. limit your waveform data. Someday, "maxFreq" will be used to
  1334. do this automatically.
  1335. </p>
  1336. <h3>Examples</h3>
  1337. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  1338. </p>
  1339. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; pulseWidth
  1340. </p>
  1341. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WM8731MikroSine
  1342. </p>
  1343. <h3>Notes</h3>
  1344. <p>Supported Waveforms:<br>
  1345. <ul>
  1346. <li><span class=literal>WAVEFORM_SINE</span></li>
  1347. <li><span class=literal>WAVEFORM_SAWTOOTH</span></li>
  1348. <li><span class=literal>WAVEFORM_SQUARE</span></li>
  1349. <li><span class=literal>WAVEFORM_TRIANGLE</span></li>
  1350. <li><span class=literal>WAVEFORM_ARBITRARY</span></li>
  1351. <li><span class=literal>WAVEFORM_PULSE</span></li>
  1352. </ul>
  1353. </p>
  1354. </script>
  1355. <script type="text/x-red" data-template-name="AudioSynthWaveform">
  1356. <div class="form-row">
  1357. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1358. <input type="text" id="node-input-name" placeholder="Name">
  1359. </div>
  1360. </script>
  1361. <script type="text/javascript">
  1362. RED.nodes.registerType('AudioSynthToneSweep',{
  1363. shortName: "tonesweep",
  1364. inputs:0,
  1365. outputs:1,
  1366. category: 'synth-function',
  1367. color:"#E6E0F8",
  1368. icon: "arrow-in.png"
  1369. });
  1370. </script>
  1371. <script type="text/x-red" data-help-name="AudioSynthToneSweep">
  1372. <h3>Summary</h3>
  1373. <p>Create a continuously varying (in frequency) sine wave</p>
  1374. <h3>Audio Connections</h3>
  1375. <table class=doc align=center cellpadding=3>
  1376. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1377. <tr class=odd><td align=center>Out 0</td><td>Continuously varying tone</td></tr>
  1378. </table>
  1379. <h3>Functions</h3>
  1380. <p class=func><span class=keyword>play</span>(level, lowFreq, highFreq, time);</p>
  1381. <p class=desc>Start generating frequency sweep output. The time is specified
  1382. in milliseconds. Level is 0 to 1.0.
  1383. </p>
  1384. <p class=func><span class=keyword>isPlaying</span>();</p>
  1385. <p class=desc>Returns true (non-zero) while the output is active.
  1386. </p>
  1387. <h3>Examples</h3>
  1388. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; ToneSweep
  1389. </p>
  1390. <h3>Notes</h3>
  1391. <p>Uses excessive CPU time</p>
  1392. </script>
  1393. <script type="text/x-red" data-template-name="AudioSynthToneSweep">
  1394. <div class="form-row">
  1395. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1396. <input type="text" id="node-input-name" placeholder="Name">
  1397. </div>
  1398. </script>
  1399. <script type="text/javascript">
  1400. RED.nodes.registerType('AudioSynthWaveformDc',{
  1401. shortName: "dc",
  1402. inputs:0,
  1403. outputs:1,
  1404. category: 'synth-function',
  1405. color:"#E6E0F8",
  1406. icon: "arrow-in.png"
  1407. });
  1408. </script>
  1409. <script type="text/x-red" data-help-name="AudioSynthWaveformDc">
  1410. <h3>Summary</h3>
  1411. <p>Create constant (DC) signal, useful for control of objects that take
  1412. a modulation or control input signal. This constant level can be
  1413. used to modify other waveforms using mixer or multiplier objects</p>
  1414. <h3>Audio Connections</h3>
  1415. <table class=doc align=center cellpadding=3>
  1416. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1417. <tr class=odd><td align=center>Out 0</td><td>Output constant DC level</td></tr>
  1418. </table>
  1419. <h3>Functions</h3>
  1420. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1421. <p class=desc>Set the output. Level is -1.0 to 1.0. The output is
  1422. changed immediately.
  1423. </p>
  1424. <p class=func><span class=keyword>amplitude</span>(level, milliseconds);</p>
  1425. <p class=desc>Set the output. Level is -1.0 to 1.0. The output is
  1426. gradually changed over a "milliseconds" time period. Any time may
  1427. be specified, but periods longer than 1 second may be automatically
  1428. shortened for small level changes, due to numerical precision limits.
  1429. </p>
  1430. <!--<h3>Examples</h3>
  1431. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1432. </p>-->
  1433. <h3>Notes</h3>
  1434. <p>Of course, the term "DC", for Direct Current, doesn't properly apply
  1435. to a pure digital stream of numerical values. But the term is widely
  1436. understood in audio applications, so hopefully it's not too confusing?</p>
  1437. </script>
  1438. <script type="text/x-red" data-template-name="AudioSynthWaveformDc">
  1439. <div class="form-row">
  1440. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1441. <input type="text" id="node-input-name" placeholder="Name">
  1442. </div>
  1443. </script>
  1444. <script type="text/javascript">
  1445. RED.nodes.registerType('AudioSynthNoiseWhite',{
  1446. shortName: "noise",
  1447. inputs:0,
  1448. outputs:1,
  1449. category: 'synth-function',
  1450. color:"#E6E0F8",
  1451. icon: "arrow-in.png"
  1452. });
  1453. </script>
  1454. <script type="text/x-red" data-help-name="AudioSynthNoiseWhite">
  1455. <h3>Summary</h3>
  1456. <div>
  1457. <p>Create white noise.
  1458. </p>
  1459. <p align=center><img src="img/whitenoise.png"></p>
  1460. </div>
  1461. <h3>Audio Connections</h3>
  1462. <table class=doc align=center cellpadding=3>
  1463. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1464. <tr class=odd><td align=center>Out 0</td><td>White Noise</td></tr>
  1465. </table>
  1466. <h3>Functions</h3>
  1467. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1468. <p class=desc>Set the output peak level, from 0 (off) to 1.0.
  1469. The default is off. Noise is generated only after setting
  1470. to a non-zero level.
  1471. </p>
  1472. <h3>Examples</h3>
  1473. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1474. </p>
  1475. <h3>Notes</h3>
  1476. <p>Setting the amplitude to zero causes this object to stop using
  1477. CPU time to generate random numbers.
  1478. </p>
  1479. </script>
  1480. <script type="text/x-red" data-template-name="AudioSynthNoiseWhite">
  1481. <div class="form-row">
  1482. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1483. <input type="text" id="node-input-name" placeholder="Name">
  1484. </div>
  1485. </script>
  1486. <script type="text/javascript">
  1487. RED.nodes.registerType('AudioSynthNoisePink',{
  1488. shortName: "pink",
  1489. inputs:0,
  1490. outputs:1,
  1491. category: 'synth-function',
  1492. color:"#E6E0F8",
  1493. icon: "arrow-in.png"
  1494. });
  1495. </script>
  1496. <script type="text/x-red" data-help-name="AudioSynthNoisePink">
  1497. <h3>Summary</h3>
  1498. <div>
  1499. <p>Create pink noise, using Stefan Stenzel's "New Shade Of Pink" algorithm.
  1500. </p>
  1501. <!--<p align=center><img src="img/whitenoise.png"></p>-->
  1502. </div>
  1503. <h3>Audio Connections</h3>
  1504. <table class=doc align=center cellpadding=3>
  1505. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1506. <tr class=odd><td align=center>Out 0</td><td>Pink Noise</td></tr>
  1507. </table>
  1508. <h3>Functions</h3>
  1509. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1510. <p class=desc>Set the output peak level, from 0 (off) to 1.0.
  1511. The default is off. Noise is generated only after setting
  1512. to a non-zero level.
  1513. </p>
  1514. <h3>Examples</h3>
  1515. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  1516. </p>
  1517. <h3>Notes</h3>
  1518. <p>Setting the amplitude to zero causes this object to stop using
  1519. CPU time. CPU usage is approx 3% on Teensy 3.1.
  1520. </p>
  1521. <p>Stefan Stenzel's
  1522. <a href="http://stenzel.waldorfmusic.de/post/pink/" target="_blank">New Shade Of Pink</a>
  1523. algorithm. Stefan's terms of use are "Use for any purpose. If used
  1524. in a commercial product, you should give me one."
  1525. </p>
  1526. </script>
  1527. <script type="text/x-red" data-template-name="AudioSynthNoisePink">
  1528. <div class="form-row">
  1529. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1530. <input type="text" id="node-input-name" placeholder="Name">
  1531. </div>
  1532. </script>
  1533. <script type="text/javascript">
  1534. RED.nodes.registerType('AudioEffectFade',{
  1535. shortName: "fade",
  1536. inputs:1,
  1537. outputs:1,
  1538. category: 'effect-function',
  1539. color:"#E6E0F8",
  1540. icon: "arrow-in.png"
  1541. });
  1542. </script>
  1543. <script type="text/x-red" data-help-name="AudioEffectFade">
  1544. <h3>Summary</h3>
  1545. <p>Gradually increase or decrease audio level.</p>
  1546. <h3>Audio Connections</h3>
  1547. <table class=doc align=center cellpadding=3>
  1548. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1549. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1550. <tr class=odd><td align=center>Out 0</td><td>Signal Output</td></tr>
  1551. </table>
  1552. <h3>Functions</h3>
  1553. <p class=func><span class=keyword>fadeIn</span>(milliseconds);</p>
  1554. <p class=desc>Begin increasing the audio level, to reach 1.0 (input passed
  1555. directly to the output) after "milliseconds" time.
  1556. </p>
  1557. <p class=func><span class=keyword>fadeOut</span>(milliseconds);</p>
  1558. <p class=desc>Begin decreasing the audio level, to reach 0 (no output)
  1559. after "milliseconds" time.
  1560. </p>
  1561. <!--<h3>Examples</h3>
  1562. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1563. </p>-->
  1564. <h3>Notes</h3>
  1565. <p>Cross fading can be built with 2 fade objects fed into a mixer.
  1566. When one fade object is off (fully faded out) and the other on
  1567. (fully faded in), if both are started at the same moment for the
  1568. same time duration, their signal gains always add to 1.0. This
  1569. allows 2 fade objects to work together for a smooth transition
  1570. between a pair of signals.
  1571. </p>
  1572. <p><a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1573. should be used when changing
  1574. settings on multiple objects, so all changes always take effect
  1575. at the same moment.
  1576. </p>
  1577. </script>
  1578. <script type="text/x-red" data-template-name="AudioEffectFade">
  1579. <div class="form-row">
  1580. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1581. <input type="text" id="node-input-name" placeholder="Name">
  1582. </div>
  1583. </script>
  1584. <script type="text/javascript">
  1585. RED.nodes.registerType('AudioEffectChorus',{
  1586. shortName: "chorus",
  1587. inputs:1,
  1588. outputs:1,
  1589. category: 'effect-function',
  1590. color:"#E6E0F8",
  1591. icon: "arrow-in.png"
  1592. });
  1593. </script>
  1594. <script type="text/x-red" data-help-name="AudioEffectChorus">
  1595. <h3>Summary</h3>
  1596. <p>The chorus effect simulates the richness of several nearly-identical
  1597. sound sources (like the way a choir sounds different to a single singer).
  1598. It does this by sampling from a delay line, so each voice is actually
  1599. the same but at a slightly different point in time. This is a type of
  1600. comb filtering.</p>
  1601. <p>Chorus combines one or more samples ranging from the most recent
  1602. sample back to about 50ms ago. The additional samples are evenly spread
  1603. through the supplied delay line, and there is no modulation.</p>
  1604. <p>If the number of voices is specified as 2, then the
  1605. effect combines the current sample and the oldest sample (the last one
  1606. in the delay line). If the number of voices is 3 then the effect combines
  1607. the most recent sample, the oldest sample and the sample in the middle of
  1608. the delay line.</p>
  1609. <p>For two voices the effect can be represented as:<br/>
  1610. result = (sample(0) + sample(dt))/2<br/>
  1611. where sample(0) represents the current sample and sample(dt)
  1612. is the sample in the delay line from dt milliseconds ago.</p>
  1613. <h3>Audio Connections</h3>
  1614. <table class=doc align=center cellpadding=3>
  1615. <tr class="top"><th>Port</th><th>Purpose</th></tr>
  1616. <tr class="odd"><td align="center">In 0</td><td>Signal Input</td></tr>
  1617. <tr class="odd"><td align="center">Out 0</td><td>Chorused Output</td></tr>
  1618. </table>
  1619. <h3>Functions</h3>
  1620. <p class=func><span class=keyword>begin</span>(delayBuffer, length, n_chorus);</p>
  1621. <p class=desc>Create a chorus by specifying the address of the delayline, the
  1622. total number of samples in the delay line (often done as an integer multiple of
  1623. AUDIO_BLOCK_SAMPLES) and the number of voices in the chorus <em>including</em>
  1624. the original voice (so, 2 and up to get a chorus effect, although you can
  1625. specify 1 if you want).
  1626. </p>
  1627. <p class=func><span class=keyword>modify</span>(n_chorus);</p>
  1628. <p class=desc>Alters the number of voices in a running chorus (previously started with begin).
  1629. </p>
  1630. <h3>Examples</h3>
  1631. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Chorus
  1632. </p>
  1633. <h3>Notes</h3>
  1634. <p>The longer the length of the chorus, the more memory blocks are used.</p>
  1635. </script>
  1636. <script type="text/x-red" data-template-name="AudioEffectChorus">
  1637. <div class="form-row">
  1638. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1639. <input type="text" id="node-input-name" placeholder="Name">
  1640. </div>
  1641. </script>
  1642. <script type="text/javascript">
  1643. RED.nodes.registerType('AudioEffectFlange',{
  1644. shortName: "flange",
  1645. inputs:1,
  1646. outputs:1,
  1647. category: 'effect-function',
  1648. color:"#E6E0F8",
  1649. icon: "arrow-in.png"
  1650. });
  1651. </script>
  1652. <script type="text/x-red" data-help-name="AudioEffectFlange">
  1653. <h3>Summary</h3>
  1654. <p>Originally, flanging was produced by playing the same signal on two synchronized
  1655. reel-to-reel tape recorders and making one of the reels slow down and speed up by
  1656. pressing on the flange of the reel (hence the name). This is a type of
  1657. comb filtering, and produces a harmonically-related series of peaks and notches
  1658. in the audio spectrum.</p>
  1659. <p>This flanger uses a delay line, combining the original voice with only one sample from the delay
  1660. line, but the position of that sample varies sinusoidally.</p>
  1661. <p>The effect can be represented as:<br>
  1662. result = sample(0) + sample(dt + depth*sin(2*PI*Fe))</p>
  1663. <p>The value of the sine function is always a number from -1 to +1 and
  1664. so the result of depth*(sin(Fe)) is always a number from -depth to +depth.
  1665. Thus, the delayed sample will be selected from the range (dt-depth) to
  1666. (dt+depth). This selection will vary at whatever rate is specified as the
  1667. frequency of the effect, Fe. Typically a low frequency (a few Hertz) is used.
  1668. <h3>Audio Connections</h3>
  1669. <table class=doc align=center cellpadding=3>
  1670. <tr class="top"><th>Port</th><th>Purpose</th></tr>
  1671. <tr class="odd"><td align="center">In 0</td><td>Signal Input</td></tr>
  1672. <tr class="odd"><td align="center">Out 0</td><td>Flanged Output</td></tr>
  1673. </table>
  1674. <h3>Functions</h3>
  1675. <p class=func><span class=keyword>begin</span>(delayBuffer, length, offset, depth, delayRate);</p>
  1676. <p class=desc>Create a flanger by specifying the address of the delayline, the
  1677. total number of samples in the delay line (often done as an integer multiple of
  1678. AUDIO_BLOCK_SAMPLES), the offset (how far back the flanged sample is from the original voice),
  1679. the modulation depth (larger values give a greater variation) and the modulation
  1680. frequency, in Hertz.
  1681. </p>
  1682. <p class=func><span class=keyword>modify</span>(offset, depth, delayRate);</p>
  1683. <p class=desc>Alters the parameters in a running flanger (previously started with begin).
  1684. </p>
  1685. <h3>Examples</h3>
  1686. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Flange
  1687. </p>
  1688. <h3>Notes</h3>
  1689. <p>The longer the length of the delay buffer, the more memory blocks are used.</p>
  1690. <p>Try these settings:<br>
  1691. #define FLANGE_DELAY_LENGTH (2*AUDIO_BLOCK_SAMPLES)<br>
  1692. and<br>
  1693. int s_idx = 2*FLANGE_DELAY_LENGTH/4;<br>
  1694. int s_depth = FLANGE_DELAY_LENGTH/4;<br>
  1695. double s_freq = 3;</p>
  1696. <p>The flange effect can also produce a chorus-like effect if a longer
  1697. delay line is used with a slower modulation rate, for example try:<br>
  1698. #define FLANGE_DELAY_LENGTH (12*AUDIO_BLOCK_SAMPLES)<br>
  1699. and<br>
  1700. int s_idx = 3*FLANGE_DELAY_LENGTH/4;<br>
  1701. int s_depth = FLANGE_DELAY_LENGTH/8;<br>
  1702. double s_freq = .0625;</p>
  1703. </script>
  1704. <script type="text/x-red" data-template-name="AudioEffectFlange">
  1705. <div class="form-row">
  1706. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1707. <input type="text" id="node-input-name" placeholder="Name">
  1708. </div>
  1709. </script>
  1710. <script type="text/javascript">
  1711. RED.nodes.registerType('AudioEffectEnvelope',{
  1712. shortName: "envelope",
  1713. inputs:1,
  1714. outputs:1,
  1715. category: 'effect-function',
  1716. color:"#E6E0F8",
  1717. icon: "arrow-in.png"
  1718. });
  1719. </script>
  1720. <script type="text/x-red" data-help-name="AudioEffectEnvelope">
  1721. <h3>Summary</h3>
  1722. <div>
  1723. <p>Modify a signal with a DAHDSR (Delay Attack Hold Decay Sustain
  1724. Release) envelope.
  1725. </p>
  1726. <p align=center><img src="img/dahdsr.png"></p>
  1727. </div>
  1728. <h3>Audio Connections</h3>
  1729. <table class=doc align=center cellpadding=3>
  1730. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1731. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1732. <tr class=odd><td align=center>Out 0</td><td>Signal with Envelope Applied</td></tr>
  1733. </table>
  1734. <h3>Functions</h3>
  1735. <p class=func><span class=keyword>noteOn</span>();</p>
  1736. <p class=desc>Begin the delay to attack, or the attack phase is
  1737. delay is zero.
  1738. </p>
  1739. <p class=func><span class=keyword>noteOff</span>();</p>
  1740. <p class=desc>Begin the release phase.
  1741. </p>
  1742. <p class=func><span class=keyword>delay</span>(milliseconds);</p>
  1743. <p class=desc>Set the delay from noteOn to the attach phase. The
  1744. default is zero, for no delay.
  1745. </p>
  1746. <p class=func><span class=keyword>attack</span>(milliseconds);</p>
  1747. <p class=desc>Set the attack time. The default is 1.5 milliseconds.
  1748. </p>
  1749. <p class=func><span class=keyword>hold</span>(milliseconds);</p>
  1750. <p class=desc>Set the hold time. The default is 0.5 milliseconds.
  1751. </p>
  1752. <p class=func><span class=keyword>decay</span>(milliseconds);</p>
  1753. <p class=desc>Set the decay time. The default is 15 milliseconds.
  1754. </p>
  1755. <p class=func><span class=keyword>sustain</span>(level);</p>
  1756. <p class=desc>Set the sustain level. The range is 0 to 1.0. The
  1757. gain will be maintained at this level after the decay phase,
  1758. until noteOff() is called.
  1759. </p>
  1760. <p class=func><span class=keyword>release</span>(milliseconds);</p>
  1761. <p class=desc>Set the release time. The default is 30 millisecond.
  1762. </p>
  1763. <h3>Examples</h3>
  1764. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  1765. </p>
  1766. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; pulseWidth
  1767. </p>
  1768. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  1769. </p>
  1770. <h3>Notes</h3>
  1771. <p>To achieve the more common ADSR shape, simply
  1772. set delay and hold to zero.</p>
  1773. <p>The recommended range for each of the 5 timing inputs is 0 to 50
  1774. milliseconds. Up to 200 ms can be used, with somewhat reduced
  1775. accuracy</p>
  1776. </script>
  1777. <script type="text/x-red" data-template-name="AudioEffectEnvelope">
  1778. <div class="form-row">
  1779. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1780. <input type="text" id="node-input-name" placeholder="Name">
  1781. </div>
  1782. </script>
  1783. <script type="text/javascript">
  1784. RED.nodes.registerType('AudioEffectMultiply',{
  1785. shortName: "multiply",
  1786. inputs:2,
  1787. outputs:1,
  1788. category: 'effect-function',
  1789. color:"#E6E0F8",
  1790. icon: "arrow-in.png"
  1791. });
  1792. </script>
  1793. <script type="text/x-red" data-help-name="AudioEffectMultiply">
  1794. <h3>Summary</h3>
  1795. <div>
  1796. <p>Multiply two signals together, useful for amplitude modulation
  1797. or "voltage controlled amplification".
  1798. </p>
  1799. <p align=center><img src="img/multiply.png"><br><small>56 Hz and 1 kHz sine waves multiplied.</small></p>
  1800. </div>
  1801. <h3>Audio Connections</h3>
  1802. <table class=doc align=center cellpadding=3>
  1803. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1804. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1805. <tr class=odd><td align=center>In 1</td><td>Signal Input</td></tr>
  1806. <tr class=odd><td align=center>Out 0</td><td>Signal with Envelope Applied</td></tr>
  1807. </table>
  1808. <h3>Functions</h3>
  1809. <p>There are no functions to call from the Arduino sketch.
  1810. This object simply multiplies the 2 signals to create
  1811. a continuous output
  1812. </p>
  1813. <!--<h3>Examples</h3>
  1814. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1815. </p>-->
  1816. <h3>Notes</h3>
  1817. <p>
  1818. </p>
  1819. </script>
  1820. <script type="text/x-red" data-template-name="AudioEffectMultiply">
  1821. <div class="form-row">
  1822. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1823. <input type="text" id="node-input-name" placeholder="Name">
  1824. </div>
  1825. </script>
  1826. <script type="text/javascript">
  1827. RED.nodes.registerType('AudioEffectDelay',{
  1828. shortName: "delay",
  1829. inputs:1,
  1830. outputs:8,
  1831. category: 'effect-function',
  1832. color:"#E6E0F8",
  1833. icon: "arrow-in.png"
  1834. });
  1835. </script>
  1836. <script type="text/x-red" data-help-name="AudioEffectDelay">
  1837. <h3>Summary</h3>
  1838. <div>
  1839. <p>Delay a signal. Up to 8 separate delay taps can be used.</p>
  1840. <p align=center><img src="img/delay.png"><br><small>1 kHz burst, delayed 5.2 ms.</small></p>
  1841. </div>
  1842. <h3>Audio Connections</h3>
  1843. <table class=doc align=center cellpadding=3>
  1844. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1845. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1846. <tr class=odd><td align=center>Out 0</td><td>Delay Tap #1</td></tr>
  1847. <tr class=odd><td align=center>Out 1</td><td>Delay Tap #2</td></tr>
  1848. <tr class=odd><td align=center>Out 2</td><td>Delay Tap #3</td></tr>
  1849. <tr class=odd><td align=center>Out 3</td><td>Delay Tap #4</td></tr>
  1850. <tr class=odd><td align=center>Out 4</td><td>Delay Tap #5</td></tr>
  1851. <tr class=odd><td align=center>Out 5</td><td>Delay Tap #6</td></tr>
  1852. <tr class=odd><td align=center>Out 6</td><td>Delay Tap #7</td></tr>
  1853. <tr class=odd><td align=center>Out 7</td><td>Delay Tap #8</td></tr>
  1854. </table>
  1855. <h3>Functions</h3>
  1856. <p class=func><span class=keyword>delay</span>(channel, milliseconds);</p>
  1857. <p class=desc>Set output channel (0 to 7) to delay the signals by
  1858. milliseconds. The maximum delay is approx 333 ms. The actual delay
  1859. is rounded to the nearest sample. Each channel can be configured for
  1860. any delay. There is no requirement to configure the "taps" in increasing
  1861. delay order.
  1862. </p>
  1863. <p class=func><span class=keyword>disable</span>(channel);</p>
  1864. <p class=desc>Disable a channel. The output of this channel becomes
  1865. silent. If this channel is the longest delay, memory usage is
  1866. automatically reduced to accomodate only the remaining channels used.
  1867. </p>
  1868. <h3>Examples</h3>
  1869. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Delay
  1870. </p>
  1871. <h3>Notes</h3>
  1872. <p>Memory for the delayed signal is take from the memory pool allocated by
  1873. <a href="http://www.pjrc.com/teensy/td_libs_AudioConnection.html" target="_blank">AudioMemory()</a>.
  1874. Each block allows about 3 milliseconds of delay, so AudioMemory
  1875. should be increased to allow for the longest delay tap.
  1876. </p>
  1877. </script>
  1878. <script type="text/x-red" data-template-name="AudioEffectDelay">
  1879. <div class="form-row">
  1880. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1881. <input type="text" id="node-input-name" placeholder="Name">
  1882. </div>
  1883. </script>
  1884. <script type="text/javascript">
  1885. RED.nodes.registerType('AudioEffectDelayExternal',{
  1886. shortName: "delayExt",
  1887. inputs:1,
  1888. outputs:8,
  1889. category: 'effect-function',
  1890. color:"#E6E0F8",
  1891. icon: "arrow-in.png"
  1892. });
  1893. </script>
  1894. <script type="text/x-red" data-help-name="AudioEffectDelayExternal">
  1895. <h3>Summary</h3>
  1896. <div>
  1897. <p>Delay a signal, using external memory for longer delay times! Up to 8 separate delay taps can be used.</p>
  1898. <p align=center><img src="img/delay.png"><br><small>1 kHz burst, delayed 5.2 ms.</small></p>
  1899. </div>
  1900. <h3>Audio Connections</h3>
  1901. <table class=doc align=center cellpadding=3>
  1902. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1903. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1904. <tr class=odd><td align=center>Out 0</td><td>Delay Tap #1</td></tr>
  1905. <tr class=odd><td align=center>Out 1</td><td>Delay Tap #2</td></tr>
  1906. <tr class=odd><td align=center>Out 2</td><td>Delay Tap #3</td></tr>
  1907. <tr class=odd><td align=center>Out 3</td><td>Delay Tap #4</td></tr>
  1908. <tr class=odd><td align=center>Out 4</td><td>Delay Tap #5</td></tr>
  1909. <tr class=odd><td align=center>Out 5</td><td>Delay Tap #6</td></tr>
  1910. <tr class=odd><td align=center>Out 6</td><td>Delay Tap #7</td></tr>
  1911. <tr class=odd><td align=center>Out 7</td><td>Delay Tap #8</td></tr>
  1912. </table>
  1913. <h3>Functions</h3>
  1914. <p class=func><span class=keyword>delay</span>(channel, milliseconds);</p>
  1915. <p class=desc>Set output channel (0 to 7) to delay the signals by
  1916. milliseconds. The maximum delay is approx 333 ms. The actual delay
  1917. is rounded to the nearest sample. Each channel can be configured for
  1918. any delay. There is no requirement to configure the "taps" in increasing
  1919. delay order.
  1920. </p>
  1921. <p class=func><span class=keyword>disable</span>(channel);</p>
  1922. <p class=desc>Disable a channel. The output of this channel becomes
  1923. silent. If this channel is the longest delay, memory usage is
  1924. automatically reduced to accomodate only the remaining channels used.
  1925. </p>
  1926. <h3>Hardware</h3>
  1927. <p>By default, or when <span class=literal>AUDIO_MEMORY_23LC1024</span> is used (see below),
  1928. a single 23LC1024 RAM chip is used, with these pins:
  1929. <table class=doc align=center cellpadding=3>
  1930. <tr class=top><th>Pin</th><th>Signal</th></tr>
  1931. <tr class=odd><td align=center>6</td><td>CS</td></tr>
  1932. <tr class=odd><td align=center>7</td><td>MOSI</td></tr>
  1933. <tr class=odd><td align=center>12</td><td>MISO</td></tr>
  1934. <tr class=odd><td align=center>14</td><td>SCK</td></tr>
  1935. </table>
  1936. </p>
  1937. <p>When <span class=literal>AUDIO_MEMORY_MEMORYBOARD</span> is used, up to six
  1938. 23LC1024 chips are used.
  1939. </p>
  1940. <p align=center><img src="img/memoryboard.jpg"><br><small><a href="https://oshpark.com/shared_projects/KZt5PaU7" target="_blank">Memoryboard 4</a></small></p>
  1941. <p>
  1942. <table class=doc align=center cellpadding=3>
  1943. <tr class=top><th>Pin</th><th>Signal</th></tr>
  1944. <tr class=odd><td align=center>2</td><td>CS0 (encoded)</td></tr>
  1945. <tr class=odd><td align=center>3</td><td>CS1 (encoded)</td></tr>
  1946. <tr class=odd><td align=center>4</td><td>CS2 (encoded)</td></tr>
  1947. <tr class=odd><td align=center>7</td><td>MOSI</td></tr>
  1948. <tr class=odd><td align=center>12</td><td>MISO</td></tr>
  1949. <tr class=odd><td align=center>14</td><td>SCK</td></tr>
  1950. </table>
  1951. </p>
  1952. <p>
  1953. If fewer than 6 chips are soldered, the optional parameter for maximum delay
  1954. must be used. See below for details. Each chip provides 1485 ms of delay
  1955. memory, so the total of all objects using AUDIO_MEMORY_MEMORYBOARD must not
  1956. exceed the amount of memory physically present.
  1957. </p>
  1958. <h3>Examples</h3>
  1959. <p>
  1960. <a href="https://www.youtube.com/watch?v=d80d1HWy5_s" target="_blank">Demo Video</a> (YouTube)
  1961. </p>
  1962. <!-- <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Delay
  1963. </p> -->
  1964. <p>
  1965. <a href="https://forum.pjrc.com/threads/29276-Limits-of-delay-effect-in-audio-library?p=79436&viewfull=1#post79436" target="_blank">Forum Conversaton</a> (with sample code)
  1966. </p>
  1967. <h3>Notes</h3>
  1968. <p>External RAM allows for longer delays without consuming
  1969. limited internal RAM. However, SPI communication is required,
  1970. which consumes much more CPU time. The
  1971. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html">AudioProcessorUsageMax</a>
  1972. function may be used to monitor how much CPU time is consumed.
  1973. </p>
  1974. <p>You may specify the type of hardware to be used by editing the code. AUDIO_MEMORY_23LC1024
  1975. specifies a single 23LC1024 chip. AUDIO_MEMORY_MEMORYBOARD allows using up to 6 of these
  1976. chips.
  1977. </p>
  1978. <p class=desc><span class=keyword>AudioEffectDelayExternal</span> delayExt1(<span class=literal>AUDIO_MEMORY_23LC1024</span>);
  1979. </p>
  1980. <p>You may also create more than one delay using the same hardware, where the memory is partitioned
  1981. by specifying a maximum delay in milliseconds. This can be useful if you wish to delay both
  1982. channels of a stereo signal.
  1983. <p class=desc><span class=keyword>AudioEffectDelayExternal</span> delayExt1(<span class=literal>AUDIO_MEMORY_23LC1024</span>, 700);<br><span class=keyword>AudioEffectDelayExternal</span> delayExt2(<span class=literal>AUDIO_MEMORY_23LC1024</span>, 700);
  1984. </p>
  1985. </script>
  1986. <script type="text/x-red" data-template-name="AudioEffectDelayExternal">
  1987. <div class="form-row">
  1988. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1989. <input type="text" id="node-input-name" placeholder="Name">
  1990. </div>
  1991. </script>
  1992. <script type="text/javascript">
  1993. RED.nodes.registerType('AudioEffectBitcrusher',{
  1994. shortName: "bitcrusher",
  1995. inputs:1,
  1996. outputs:1,
  1997. category: 'effect-function',
  1998. color:"#E6E0F8",
  1999. icon: "arrow-in.png"
  2000. });
  2001. </script>
  2002. <script type="text/x-red" data-help-name="AudioEffectBitcrusher">
  2003. <h3>Summary</h3>
  2004. <p>Reduce the samplerate and/or bitdepth of a source signal, resulting in
  2005. a distorted sound.</p>
  2006. <h3>Audio Connections</h3>
  2007. <table class=doc align=center cellpadding=3>
  2008. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2009. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2010. <tr class=odd><td align=center>Out 0</td><td>Signal Output</td></tr>
  2011. </table>
  2012. <h3>Parameters</h3>
  2013. <p class=func><span class=keyword>bits</span>(xcrushBits);</p>
  2014. <p class=desc>xcrushBits sets the bitdepth, from 1 to 16. A Value of 16
  2015. does not crush the bitdepth, and is effectively a passthru for this part
  2016. of the function.</p>
  2017. <p class=func><span class=keyword>sampleRate</span>(xsampleRate);</p>
  2018. <p class=desc>xsampleRate sets the frequency, from 1 to 44100Hz, however it
  2019. works in integer steps so you will only really get a handful of results from
  2020. the many samplerates you can pass. 44100 is passthru.</p>
  2021. <p class=desc>set xbitDepth to 16 and xsampleRate to 44100 to pass audio
  2022. through without any Bitcrush effect.</p>
  2023. <h3>Examples</h3>
  2024. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Bitcrusher
  2025. </p>
  2026. <h3>Notes</h3>
  2027. <p>Needs a lot of improvement. Options for anti-aliasing would be nice in
  2028. the future, but for now, it's rough, it's dirty and it sounds a bit like
  2029. Nine Inch Nails.
  2030. </p>
  2031. <p><a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  2032. should be used when changing
  2033. settings on multiple objects, so all changes always take effect
  2034. at the same moment.
  2035. </p>
  2036. </script>
  2037. <script type="text/x-red" data-template-name="AudioEffectBitcrusher">
  2038. <div class="form-row">
  2039. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2040. <input type="text" id="node-input-name" placeholder="Name">
  2041. </div>
  2042. </script>
  2043. <script type="text/javascript">
  2044. RED.nodes.registerType('AudioFilterBiquad',{
  2045. shortName: "biquad",
  2046. inputs:1,
  2047. outputs:1,
  2048. category: 'filter-function',
  2049. color:"#E6E0F8",
  2050. icon: "arrow-in.png"
  2051. });
  2052. </script>
  2053. <script type="text/x-red" data-help-name="AudioFilterBiquad">
  2054. <h3>Summary</h3>
  2055. <div>
  2056. <p>Biquadratic cascaded filter, useful for all sorts of filtering.
  2057. Up to 4 stages may be cascaded.
  2058. </p>
  2059. <p align=center><img src="img/biquad.png"></p>
  2060. </div>
  2061. <h3>Audio Connections</h3>
  2062. <table class=doc align=center cellpadding=3>
  2063. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2064. <tr class=odd><td align=center>In 0</td><td>Signal to be filtered</td></tr>
  2065. <tr class=odd><td align=center>Out 0</td><td>Filtered Signal Output</td></tr>
  2066. </table>
  2067. <h3>Functions</h3>
  2068. <p class=func><span class=keyword>setLowpass</span>(stage, frequency, Q);</p>
  2069. <p class=desc>Configure one stage of the filter (0 to 3) with low pass
  2070. response, with the specified corner frequency and Q shape. If Q is
  2071. higher that 0.7071, be careful of filter gain (see below).
  2072. </p>
  2073. <p class=func><span class=keyword>setHighpass</span>(stage, frequency, Q);</p>
  2074. <p class=desc>Configure one stage of the filter (0 to 3) with high pass
  2075. response, with the specified corner frequency and Q shape. If Q is
  2076. higher that 0.7071, be careful of filter gain (see below).
  2077. </p>
  2078. <p class=func><span class=keyword>setBandpass</span>(stage, frequency, Q);</p>
  2079. <p class=desc>Configure one stage of the filter (0 to 3) with band pass
  2080. response. The filter has unity gain at the specified frequency. Q
  2081. controls the width of frequencies allowed to pass.
  2082. </p>
  2083. <p class=func><span class=keyword>setNotch</span>(stage, frequency, Q);</p>
  2084. <p class=desc>Configure one stage of the filter (0 to 3) with band reject (notch)
  2085. response. Q controls the width of rejected frequencies.
  2086. </p>
  2087. <p class=func><span class=keyword>setCoefficients</span>(stage, array[5]);</p>
  2088. <p class=desc>Configure one stage of the filter (0 to 3) with an arbitrary
  2089. filter response. The array of coefficients is in order: B0, B1, B2, A1, A2.
  2090. Each coefficient must be less than 2.0 and greater than -2.0. The array
  2091. should be type double. Alternately, it may be type int, where 1.0 is
  2092. represented with 1073741824 (2<sup>30</sup>).
  2093. </p>
  2094. <h3>Examples</h3>
  2095. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter
  2096. </p>
  2097. <h3>Notes</h3>
  2098. <p>Filters can with gain must have their input signals attenuated, so the
  2099. signal does not exceed 1.0.
  2100. </p>
  2101. <p>This object implements up to 4 cascaded stages. Unconfigured stages will
  2102. not pass any signal.
  2103. </p>
  2104. <p>Biquad filters with low corner frequency (under about 400 Hz) can run into
  2105. trouble with limited numerical precision, causing the filter to perform
  2106. poorly. For very low corner frequency, the State Variable (Chamberlin)
  2107. filter should be used.
  2108. </p>
  2109. </script>
  2110. <script type="text/x-red" data-template-name="AudioFilterBiquad">
  2111. <div class="form-row">
  2112. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2113. <input type="text" id="node-input-name" placeholder="Name">
  2114. </div>
  2115. </script>
  2116. <script type="text/javascript">
  2117. RED.nodes.registerType('AudioFilterFIR',{
  2118. shortName: "fir",
  2119. inputs:1,
  2120. outputs:1,
  2121. category: 'filter-function',
  2122. color:"#E6E0F8",
  2123. icon: "arrow-in.png"
  2124. });
  2125. </script>
  2126. <script type="text/x-red" data-help-name="AudioFilterFIR">
  2127. <h3>Summary</h3>
  2128. <div>
  2129. <p>Finite impulse response filter, useful for all sorts of filtering.
  2130. </p>
  2131. <p align=center><img src="img/fir_filter.png"></p>
  2132. </div>
  2133. <h3>Audio Connections</h3>
  2134. <table class=doc align=center cellpadding=3>
  2135. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2136. <tr class=odd><td align=center>In 0</td><td>Signal to be filtered</td></tr>
  2137. <tr class=odd><td align=center>Out 0</td><td>Filtered Signal Output</td></tr>
  2138. </table>
  2139. <h3>Functions</h3>
  2140. <p class=func><span class=keyword>begin</span>(array, length);</p>
  2141. <p class=desc>Initialize the filter. The array must be 16 bit integers (the
  2142. filter's impulse response), and
  2143. length indicates the number of points in the array. Array may also be
  2144. FIR_PASSTHRU (length = 0), to directly pass the input to output without
  2145. filtering.
  2146. </p>
  2147. <p class=func><span class=keyword>end</span>();</p>
  2148. <p class=desc>Turn the filter off.
  2149. </p>
  2150. <h3>Examples</h3>
  2151. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter_FIR
  2152. </p>
  2153. <h3>Notes</h3>
  2154. <p>FIR filters requires more CPU time than Biquad (IIR), but they can
  2155. implement filters with better phase response.
  2156. </p>
  2157. <p>A 100 point filter requires 9% CPU time on Teensy 3.1. The maximum
  2158. supported filter length is 200 points.
  2159. </p>
  2160. <p>The free
  2161. <a href="http://t-filter.appspot.com/fir/index.html" target="_blank"> TFilter Design Tool</a>
  2162. can be used to create the impulse response array. Be sure to set the sampling
  2163. frequency to 44117 HZ (it defaults to only 2000 Hz) and the output type to "int" (16 bit).
  2164. </p>
  2165. <p>
  2166. If you use TFilter Design's "C/C++ array" option, it's output has "int" definition, which
  2167. is 32 bits on Teensy 3.1. Edit "int" to "short" for an array of 16 bit numbers,
  2168. and add "const" to avoid consuming extra RAM.
  2169. </p>
  2170. </script>
  2171. <script type="text/x-red" data-template-name="AudioFilterFIR">
  2172. <div class="form-row">
  2173. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2174. <input type="text" id="node-input-name" placeholder="Name">
  2175. </div>
  2176. </script>
  2177. <script type="text/javascript">
  2178. RED.nodes.registerType('AudioFilterStateVariable',{
  2179. shortName: "filter",
  2180. inputs:2,
  2181. outputs:3,
  2182. category: 'filter-function',
  2183. color:"#E6E0F8",
  2184. icon: "arrow-in.png"
  2185. });
  2186. </script>
  2187. <script type="text/x-red" data-help-name="AudioFilterStateVariable">
  2188. <h3>Summary</h3>
  2189. <p>A State Variable (Chamberlin) Filter with 12 dB/octave roll-off,
  2190. adjustable resonance, and optional signal control of corner
  2191. frequency.</p>
  2192. <h3>Audio Connections</h3>
  2193. <table class=doc align=center cellpadding=3>
  2194. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2195. <tr class=odd><td align=center>In 0</td><td>Signal to Filter</td></tr>
  2196. <tr class=odd><td align=center>In 1</td><td>Frequency Control</td></tr>
  2197. <tr class=odd><td align=center>Out 0</td><td>Low Pass Output</td></tr>
  2198. <tr class=odd><td align=center>Out 1</td><td>Band Pass Output</td></tr>
  2199. <tr class=odd><td align=center>Out 2</td><td>High Pass Output</td></tr>
  2200. </table>
  2201. <h3>Functions</h3>
  2202. <p class=func><span class=keyword>frequency</span>(freq);</p>
  2203. <p class=desc>Set the filter's corner frequency. When a signal is
  2204. connected to the control input, the filter will implement this
  2205. frequency when the signal is zero.
  2206. </p>
  2207. <p class=func><span class=keyword>resonance</span>(Q);</p>
  2208. <p class=desc>Set the filter's resonance. Q ranges from 0.7 to 5.0.
  2209. Resonance greater than 0.707 will amplify the signal near the
  2210. corner frequency. You must attenuate the signal before input
  2211. to this filter, to prevent clipping.
  2212. </p>
  2213. <p class=func><span class=keyword>octaveControl</span>(octaves);</p>
  2214. <p class=desc>Set how much (in octaves) the control signal can alter
  2215. the filter's corner freqency. Range is 0 to 7 octaves. For
  2216. example, when set to 2.5, a full scale positive signal (1.0) will
  2217. shift the filter frequency up 2.5 octaves, and a full scale negative
  2218. signal will shift it down 2.5 octaves.
  2219. </p>
  2220. <!--<h3>Examples</h3>
  2221. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2222. </p>-->
  2223. <h3>Notes</h3>
  2224. <p>
  2225. When controlled by a signal, the equation for the filter
  2226. frequency is:
  2227. </p>
  2228. <p>
  2229. F = Fcenter * 2^<sup>(signal * octaves)</sup>
  2230. <br><small>If anyone knows how to do HTML equations, please
  2231. help me improve this.....</small>
  2232. </p>
  2233. <p>When operating with signal control of corner frequency, this
  2234. object uses approximately 4% of the CPU time on Teensy 3.1.
  2235. </p>
  2236. </script>
  2237. <script type="text/x-red" data-template-name="AudioFilterFIR">
  2238. <div class="form-row">
  2239. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2240. <input type="text" id="node-input-name" placeholder="Name">
  2241. </div>
  2242. </script>
  2243. <script type="text/javascript">
  2244. RED.nodes.registerType('AudioAnalyzePeak',{
  2245. shortName: "peak",
  2246. inputs:1,
  2247. outputs:0,
  2248. category: 'analyze-function',
  2249. color:"#E6E0F8",
  2250. icon: "arrow-in.png"
  2251. });
  2252. </script>
  2253. <script type="text/x-red" data-help-name="AudioAnalyzePeak">
  2254. <h3>Summary</h3>
  2255. <p>Track the signal peak amplitude. Very useful for simple
  2256. audio level response projects, and general troubleshooting.</p>
  2257. <h3>Audio Connections</h3>
  2258. <table class=doc align=center cellpadding=3>
  2259. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2260. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  2261. </table>
  2262. <h3>Functions</h3>
  2263. <p class=func><span class=keyword>available</span>();</p>
  2264. <p class=desc>Returns true each time new peak data is available.
  2265. </p>
  2266. <p class=func><span class=keyword>read</span>();</p>
  2267. <p class=desc>Read the highest peak value since the last read.
  2268. Return is from 0.0 to 1.0.
  2269. </p>
  2270. <h3>Examples</h3>
  2271. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterMono
  2272. </p>
  2273. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterStereo
  2274. </p>
  2275. <h3>Notes</h3>
  2276. <p></p>
  2277. </script>
  2278. <script type="text/x-red" data-template-name="AudioAnalyzePeak">
  2279. <div class="form-row">
  2280. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2281. <input type="text" id="node-input-name" placeholder="Name">
  2282. </div>
  2283. </script>
  2284. <script type="text/javascript">
  2285. RED.nodes.registerType('AudioAnalyzeFFT256',{
  2286. shortName: "fft256",
  2287. inputs:1,
  2288. outputs:0,
  2289. category: 'analyze-function',
  2290. color:"#E6E0F8",
  2291. icon: "arrow-in.png"
  2292. });
  2293. </script>
  2294. <script type="text/x-red" data-help-name="AudioAnalyzeFFT256">
  2295. <h3>Summary</h3>
  2296. <p>Compute a 256 point Fast Fourier Transform (FFT) frequency analysis,
  2297. with real value (magnitude) output. The frequency resolution is
  2298. 172 Hz, useful for simple audio visualization.</p>
  2299. <h3>Audio Connections</h3>
  2300. <table class=doc align=center cellpadding=3>
  2301. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2302. <tr class=odd><td align=center>In 0</td><td>Signal to convert to frequency bins</td></tr>
  2303. </table>
  2304. <h3>Functions</h3>
  2305. <p class=func><span class=keyword>available</span>();</p>
  2306. <p class=desc>Returns true each time the FFT analysis produces new output data.
  2307. </p>
  2308. <p class=func><span class=keyword>read</span>(binNumber);</p>
  2309. <p class=desc>Read a single frequency bin, from 0 to 127. The result is scaled
  2310. so 1.0 represents a full scale sine wave.
  2311. </p>
  2312. <p class=func><span class=keyword>read</span>(firstBin, lastBin);</p>
  2313. <p class=desc>Read several frequency bins, returning their sum. The higher
  2314. audio octaves are represented by many bins, which are typically read
  2315. as a group for audio visualization.
  2316. </p>
  2317. <p class=func><span class=keyword>averageTogether</span>(number);</p>
  2318. <p class=desc>New data is produced very radidly, approximately 344 times
  2319. per second. Multiple outputs can be averaged together, so available()
  2320. returns true at a slower rate.
  2321. </p>
  2322. <p class=func><span class=keyword>windowFunction</span>(window);</p>
  2323. <p class=desc>Set the window function to be used. AudioWindowHanning256
  2324. is the default. Windowing may be disabled by NULL, but windowing
  2325. should be used for all non-periodic (music) signals, and all periodic
  2326. signals that are not exact integer division of the sample rate.
  2327. </p>
  2328. <h3>Examples</h3>
  2329. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  2330. </p>
  2331. <h3>Notes</h3>
  2332. <p>The raw 16 bit output data bins may be access with myFFT.output[num], where
  2333. num is 0 to 127.</p>
  2334. <p>TODO: caveats about spectral leakage vs frequency precision for arbitrary signals</p>
  2335. <p>Window Types:
  2336. <ul>
  2337. <li><span class=literal>AudioWindowHanning256</span> (default)</li>
  2338. <li><span class=literal>AudioWindowBartlett256</span></li>
  2339. <li><span class=literal>AudioWindowBlackman256</span></li>
  2340. <li><span class=literal>AudioWindowFlattop256</span></li>
  2341. <li><span class=literal>AudioWindowBlackmanHarris256</span></li>
  2342. <li><span class=literal>AudioWindowNuttall256</span></li>
  2343. <li><span class=literal>AudioWindowBlackmanNuttall256</span></li>
  2344. <li><span class=literal>AudioWindowWelch256</span></li>
  2345. <li><span class=literal>AudioWindowHamming256</span></li>
  2346. <li><span class=literal>AudioWindowCosine256</span></li>
  2347. <li><span class=literal>AudioWindowTukey256</span></li>
  2348. </ul>
  2349. </p>
  2350. </script>
  2351. <script type="text/x-red" data-template-name="AudioAnalyzeFFT256">
  2352. <div class="form-row">
  2353. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2354. <input type="text" id="node-input-name" placeholder="Name">
  2355. </div>
  2356. </script>
  2357. <script type="text/javascript">
  2358. RED.nodes.registerType('AudioAnalyzeFFT1024',{
  2359. shortName: "fft1024",
  2360. inputs:1,
  2361. outputs:0,
  2362. category: 'analyze-function',
  2363. color:"#E6E0F8",
  2364. icon: "arrow-in.png"
  2365. });
  2366. </script>
  2367. <script type="text/x-red" data-help-name="AudioAnalyzeFFT1024">
  2368. <h3>Summary</h3>
  2369. <p>Compute a 1024 point Fast Fourier Transform (FFT) frequency analysis,
  2370. with real value (magnitude) output. The frequency resolution is
  2371. 43 Hz, useful detailed for audio visualization.</p>
  2372. <h3>Audio Connections</h3>
  2373. <table class=doc align=center cellpadding=3>
  2374. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2375. <tr class=odd><td align=center>In 0</td><td>Signal to convert to frequency bins</td></tr>
  2376. </table>
  2377. <h3>Functions</h3>
  2378. <p class=func><span class=keyword>available</span>();</p>
  2379. <p class=desc>Returns true each time the FFT analysis produces new output data.
  2380. </p>
  2381. <p class=func><span class=keyword>read</span>(binNumber);</p>
  2382. <p class=desc>Read a single frequency bin, from 0 to 511. The result is scaled
  2383. so 1.0 represents a full scale sine wave.
  2384. </p>
  2385. <p class=func><span class=keyword>read</span>(firstBin, lastBin);</p>
  2386. <p class=desc>Read several frequency bins, returning their sum. The higher
  2387. audio octaves are represented by many bins, which are typically read
  2388. as a group for audio visualization.
  2389. </p>
  2390. <p class=func><span class=keyword>averageTogether</span>(number);</p>
  2391. <p class=desc>This function does nothing. The 1024 point FFT always
  2392. updates at approximately 86 times per second.
  2393. </p>
  2394. <p class=func><span class=keyword>windowFunction</span>(window);</p>
  2395. <p class=desc>Set the window function to be used. AudioWindowHanning1024
  2396. is the default. Windowing may be disabled by NULL, but windowing
  2397. should be used for all non-periodic (music) signals, and all periodic
  2398. signals that are not exact integer division of the sample rate.
  2399. </p>
  2400. <h3>Examples</h3>
  2401. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; FFT
  2402. </p>
  2403. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; SpectrumAnalyzerBasic
  2404. </p>
  2405. <h3>Notes</h3>
  2406. <p>The raw 16 bit output data bins may be access with myFFT.output[num], where
  2407. num is 0 to 511.</p>
  2408. <p>TODO: caveats about spectral leakage vs frequency precision for arbitrary signals</p>
  2409. <p>Window Types:
  2410. <ul>
  2411. <li><span class=literal>AudioWindowHanning1024</span> (default)</li>
  2412. <li><span class=literal>AudioWindowBartlett1024</span></li>
  2413. <li><span class=literal>AudioWindowBlackman1024</span></li>
  2414. <li><span class=literal>AudioWindowFlattop1024</span></li>
  2415. <li><span class=literal>AudioWindowBlackmanHarris1024</span></li>
  2416. <li><span class=literal>AudioWindowNuttall1024</span></li>
  2417. <li><span class=literal>AudioWindowBlackmanNuttall1024</span></li>
  2418. <li><span class=literal>AudioWindowWelch1024</span></li>
  2419. <li><span class=literal>AudioWindowHamming1024</span></li>
  2420. <li><span class=literal>AudioWindowCosine1024</span></li>
  2421. <li><span class=literal>AudioWindowTukey1024</span></li>
  2422. </ul>
  2423. </p>
  2424. <p>1024 point FFT has a peak CPU usage of approx 52% on Teensy 3.1.
  2425. Average usage is much lower. Future versions might distribute the
  2426. load more evenly over time....
  2427. </p>
  2428. </script>
  2429. <script type="text/x-red" data-template-name="AudioAnalyzeFFT1024">
  2430. <div class="form-row">
  2431. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2432. <input type="text" id="node-input-name" placeholder="Name">
  2433. </div>
  2434. </script>
  2435. <script type="text/javascript">
  2436. RED.nodes.registerType('AudioAnalyzeToneDetect',{
  2437. shortName: "tone",
  2438. inputs:1,
  2439. outputs:0,
  2440. category: 'analyze-function',
  2441. color:"#E6E0F8",
  2442. icon: "arrow-in.png"
  2443. });
  2444. </script>
  2445. <script type="text/x-red" data-help-name="AudioAnalyzeToneDetect">
  2446. <h3>Summary</h3>
  2447. <p>Detect the level of a single tone</p>
  2448. <h3>Audio Connections</h3>
  2449. <table class=doc align=center cellpadding=3>
  2450. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2451. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  2452. </table>
  2453. <h3>Functions</h3>
  2454. <p class=func><span class=keyword>frequency</span>(freq);</p>
  2455. <p class=desc>Set the frequency to detect. The default detection time
  2456. will be 10 cycles of this frequency.
  2457. </p>
  2458. <p class=func><span class=keyword>frequency</span>(freq, cycles);</p>
  2459. <p class=desc>Set the frequency to detect, and the number of cycles.
  2460. Longer detection time (more cycles) will give higher precision,
  2461. but of course slower response.
  2462. </p>
  2463. <p class=func><span class=keyword>available</span>();</p>
  2464. <p class=desc>Returns true (non-zero) each time a detection interval
  2465. (number of cycles) completed and a new level is detected.
  2466. </p>
  2467. <p class=func><span class=keyword>read</span>();</p>
  2468. <p class=desc>Read the detected signal level. Range is 0 to 1.0.
  2469. </p>
  2470. <p class=func><span class=keyword>threshold</span>(level);</p>
  2471. <p class=desc>Set a detection threshold, where the bool test operation
  2472. will return true if at or above this level, or false when below.
  2473. </p>
  2474. <p class=func>(bool)</p>
  2475. <p class=desc>By testing the object as a boolean value, you can respond
  2476. to detection of a tone.
  2477. </p>
  2478. <h3>Examples</h3>
  2479. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_Serial
  2480. </p>
  2481. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_7segment
  2482. </p>
  2483. <h3>Notes</h3>
  2484. <p>Low frequency detection has trouble with numerical precision.
  2485. Works really well for all 8 DTMF frequencies, but fails for
  2486. detecting "sub audible tones" used in some control applications.</p>
  2487. <p>The (bool) test continues to return true until the next detection
  2488. interval (the configured number of cycles). This behavior may
  2489. change in future versions, for a single true each time the signal
  2490. is detected, and then false for the remainder of that interval.</p>
  2491. </script>
  2492. <script type="text/x-red" data-template-name="AudioAnalyzeToneDetect">
  2493. <div class="form-row">
  2494. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2495. <input type="text" id="node-input-name" placeholder="Name">
  2496. </div>
  2497. </script>
  2498. <script type="text/javascript">
  2499. RED.nodes.registerType('AudioAnalyzePrint',{
  2500. shortName: "print",
  2501. inputs:1,
  2502. outputs:0,
  2503. category: 'analyze-function',
  2504. color:"#E6E0F8",
  2505. icon: "arrow-in.png"
  2506. });
  2507. </script>
  2508. <script type="text/x-red" data-help-name="AudioAnalyzePrint">
  2509. <h3>Summary</h3>
  2510. <p>Print raw audio data to the Arduino Serial Monitor. This
  2511. object creates massive output quickly, and should not normally be used.</p>
  2512. <h3>Audio Connections</h3>
  2513. <table class=doc align=center cellpadding=3>
  2514. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2515. <tr class=odd><td align=center>In 0</td><td>Signal to print</td></tr>
  2516. </table>
  2517. <h3>Functions</h3>
  2518. <p class=func><span class=keyword>name</span>(string);</p>
  2519. <p class=desc>blah blah blah blah
  2520. </p>
  2521. <p class=func><span class=keyword>trigger</span>();</p>
  2522. <p class=desc>blah blah blah blah
  2523. </p>
  2524. <p class=func><span class=keyword>trigger</span>(level, edge);</p>
  2525. <p class=desc>blah blah blah blah
  2526. </p>
  2527. <p class=func><span class=keyword>delay</span>(samples);</p>
  2528. <p class=desc>blah blah blah blah
  2529. </p>
  2530. <p class=func><span class=keyword>length</span>(samples);</p>
  2531. <p class=desc>blah blah blah blah
  2532. </p>
  2533. <!--<h3>Examples</h3>
  2534. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2535. </p>-->
  2536. <h3>Notes</h3>
  2537. <p>This object doesn't work very well and probably should not be used.</p>
  2538. </script>
  2539. <script type="text/x-red" data-template-name="AudioAnalyzePrint">
  2540. <div class="form-row">
  2541. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2542. <input type="text" id="node-input-name" placeholder="Name">
  2543. </div>
  2544. </script>
  2545. <script type="text/javascript">
  2546. RED.nodes.registerType('AudioControlSGTL5000',{
  2547. shortName: "sgtl5000",
  2548. inputs:0,
  2549. outputs:0,
  2550. category: 'control-function',
  2551. color:"#E6E0F8",
  2552. icon: "arrow-in.png"
  2553. });
  2554. </script>
  2555. <script type="text/x-red" data-help-name="AudioControlSGTL5000">
  2556. <h3>Summary</h3>
  2557. <p>Control the SGTL5000 chip on the
  2558. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>.
  2559. SGTL5000 is always used in slave mode, where Teensy controls
  2560. all I2S timing.
  2561. </p>
  2562. <p align=center><img src="img/sgtl5000closeup.jpg"></p>
  2563. <h3>Audio Connections</h3>
  2564. <p>This object has no audio inputs or outputs. Separate i2s objects
  2565. are used to send and receive audio data. I2S master mode objects
  2566. must be used, because this object configures the SGTL5000 in slave
  2567. mode, where it depends on Teensy to provide all I2S clocks.
  2568. This object controls
  2569. how the SGTL5000 will use those I2S audio streams.</p>
  2570. <h3>Functions</h3>
  2571. <p>These are the most commonly used SGTL5000 functions.</p>
  2572. <p class=func><span class=keyword>enable</span>();</p>
  2573. <p class=desc>Start the SGTL5000. This function should be called first.
  2574. </p>
  2575. <p class=func><span class=keyword>volume</span>(level);</p>
  2576. <p class=desc>Set the headphone volume level. Range is 0 to 1.0, but
  2577. 0.8 corresponds to the maximum undistorted output for a full scale
  2578. signal. Usually 0.5 is a comfortable listening level. The line
  2579. level outputs are <em>not</em> changed by this function.
  2580. </p>
  2581. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  2582. <p class=desc>Select which input to use: AUDIO_INPUT_LINEIN or AUDIO_INPUT_MIC.
  2583. </p>
  2584. <p class=func><span class=keyword>micGain</span>(dB);</p>
  2585. <p class=desc>When using the microphone input, set the amplifier gain.
  2586. The input number is in decibels, from 0 to 63.
  2587. </p>
  2588. <h3>Signal Levels</h3>
  2589. <p>The default signal levels should be used for most applications,
  2590. but these functions allow you to customize the analog signals.</p>
  2591. <p class=func><span class=keyword>muteHeadphone</span>();</p>
  2592. <p class=desc>Silence the headphone output.
  2593. </p>
  2594. <p class=func><span class=keyword>unmuteHeadphone</span>();</p>
  2595. <p class=desc>Turn the headphone output on.
  2596. </p>
  2597. <p class=func><span class=keyword>muteLineout</span>();</p>
  2598. <p class=desc>Silence the line level outputs.
  2599. </p>
  2600. <p class=func><span class=keyword>unmuteLineout</span>();</p>
  2601. <p class=desc>Turn the line level outputs on.
  2602. </p>
  2603. <p class=func><span class=keyword>lineInLevel</span>(both);</p>
  2604. <p class=desc style="padding-bottom:0.2em;">Adjust the sensitivity of the line-level inputs.
  2605. Fifteen settings are possible:
  2606. </p>
  2607. <pre class="desc">
  2608. 0: 3.12 Volts p-p
  2609. 1: 2.63 Volts p-p
  2610. 2: 2.22 Volts p-p
  2611. 3: 1.87 Volts p-p
  2612. 4: 1.58 Volts p-p
  2613. 5: 1.33 Volts p-p (default)
  2614. 6: 1.11 Volts p-p
  2615. 7: 0.94 Volts p-p
  2616. 8: 0.79 Volts p-p
  2617. 9: 0.67 Volts p-p
  2618. 10: 0.56 Volts p-p
  2619. 11: 0.48 Volts p-p
  2620. 12: 0.40 Volts p-p
  2621. 13: 0.34 Volts p-p
  2622. 14: 0.29 Volts p-p
  2623. 15: 0.24 Volts p-p
  2624. </pre>
  2625. <p class=func><span class=keyword>lineInLevel</span>(left, right);</p>
  2626. <p class=desc>Adjust the sensitivity of the line-level inputs, with different
  2627. settings for left and right. The same 15 settings are available.
  2628. </p>
  2629. <p class=func><span class=keyword>lineOutLevel</span>(both);</p>
  2630. <p class=desc style="padding-bottom:0.2em;">Adjust the line level output
  2631. voltage range. The following settings are possible:
  2632. </p>
  2633. <pre class="desc">
  2634. 13: 3.16 Volts p-p
  2635. 14: 2.98 Volts p-p
  2636. 15: 2.83 Volts p-p
  2637. 16: 2.67 Volts p-p
  2638. 17: 2.53 Volts p-p
  2639. 18: 2.39 Volts p-p
  2640. 19: 2.26 Volts p-p
  2641. 20: 2.14 Volts p-p
  2642. 21: 2.02 Volts p-p
  2643. 22: 1.91 Volts p-p
  2644. 23: 1.80 Volts p-p
  2645. 24: 1.71 Volts p-p
  2646. 25: 1.62 Volts p-p
  2647. 26: 1.53 Volts p-p
  2648. 27: 1.44 Volts p-p
  2649. 28: 1.37 Volts p-p
  2650. 29: 1.29 Volts p-p (default)
  2651. 30: 1.22 Volts p-p
  2652. 31: 1.16 Volts p-p
  2653. </pre>
  2654. <p class=func><span class=keyword>lineOutLevel</span>(left, right);</p>
  2655. <p class=desc>Adjust the line level outout voltage range, with separate
  2656. settings for left and right. The same settings (13 to 31) are available.
  2657. </p>
  2658. <h3>Signal Conditioning</h3>
  2659. <p>Usually these digital signal conditioning features should be left at their
  2660. default settings.
  2661. </p>
  2662. <p class=func><span class=keyword>adcHighPassFilterFreeze</span>();</p>
  2663. <p class=desc>By default, the analog input (either line-level inputs or mic)
  2664. is high-pass filtered, to remove any DC component. This function
  2665. freezes the filter, so the current DC component is still substracted, but
  2666. the filter stops tracking any DC or low frequency changes.
  2667. </p>
  2668. <p class=func><span class=keyword>adcHighPassFilterDisable</span>();</p>
  2669. <p class=desc>Completely disable the analog input filter. DC and sub-audible
  2670. low frequencies are allowed to enter the digital signal.
  2671. </p>
  2672. <p class=func><span class=keyword>adcHighPassFilterEnable</span>();</p>
  2673. <p class=desc>Turn the DC-blocking filter back on, if disabled, or
  2674. allows it to resume tracking DC and low frequency changes, if
  2675. previously frozen. This is the default setting.
  2676. </p>
  2677. <p class=func><span class=keyword>dacVolume</span>(both);</p>
  2678. <p class=desc>Normally output volume should be used with volume(), which
  2679. changes the analog gain in the headphone amplifier. This function
  2680. on the other hand controls digital attenuation before conversion to analog, which
  2681. reduces resolution, but allows another fine control of output
  2682. signal level. The ranges is 0 to 1.0, with the default (no digital attenuation)
  2683. at 1.0.
  2684. </p>
  2685. <p class=desc>dacVolume uses zero-crossing detect to avoid clicks, and ramping is handled by
  2686. the chip so that a new volume may be set directly in a single call.
  2687. </p>
  2688. <p class=func><span class=keyword>dacVolume</span>(left, right);</p>
  2689. <p class=desc>Adjust the digital output volume separately on left and
  2690. right channels.
  2691. </p>
  2692. <h3>Audio Processor</h3>
  2693. <p>The optional digital audio processor is capable of implementing
  2694. one or more of: automatic volume control, surround sound control,
  2695. bass enhancement, and tonal adjustments (either a
  2696. simple tone control, or a parametric equalizer, or a graphic equalizer),
  2697. in that order.
  2698. </p>
  2699. <p>These signal processing features are implemented in the SGTL5000 chip,
  2700. so they do not consume CPU time on Teensy. However, the order of
  2701. these processes is fixed in the hardware.
  2702. </p>
  2703. <p>It is good practice to mute the outputs before enabling or disabling
  2704. the Audio Processor, to avoid clicks or thumps.
  2705. </p>
  2706. <p class=func><span class=keyword>audioPreProcessorEnable</span>();</p>
  2707. <p class=desc>Enable the audio processor to pre-process the input
  2708. (from either line-level inputs or microphone) before it's sent
  2709. to Teensy by I2S.
  2710. </p>
  2711. <p class=func><span class=keyword>audioPostProcessorEnable</span>();</p>
  2712. <p class=desc>Enable the audio processor to post-process Teensy's
  2713. I2S output before it's turned into analog signals for the
  2714. headphones and/or line level outputs.
  2715. </p>
  2716. <p class=func><span class=keyword>audioProcessorDisable</span>();</p>
  2717. <p class=desc>Disable the audio processor.
  2718. </p>
  2719. <p class=func><span class=keyword>autoVolumeControl</span>(maxGain, response, hardLimit, threshold, attack, decay);</p>
  2720. <p class=desc>Configures the auto volume control, which is implemented as a compressor/expander
  2721. or hard limiter. <em>maxGain</em> is the maximum gain that can be applied for expanding, and
  2722. can take one of three values: 0 (0dB), 1 (6.0dB) and 2 (12dB). Values greater than 2 are treated
  2723. as 2. <em>response</em> controls the integration time for the compressor and can take
  2724. four values: 0 (0ms), 1 (25ms), 2 (50ms) or 3 (100ms). Larger values average the volume
  2725. over a longer time, allowing short-term peaks through.
  2726. </p>
  2727. <p class=desc>If <em>hardLimit</em> is 0, a 'soft
  2728. knee' compressor is used to progressively compress louder values which are near to or above the
  2729. threashold (the louder they are, the greater the compression). If it is 1, a hard compressor
  2730. is used (all values above the threashold are the same loudness). The <em>threashold</em> is specified
  2731. as a float in the range 0dBFS to -96dBFS, where -18dBFS is a typical value.
  2732. <em>attack</em> is a float controlling the rate of decrease in gain when the signal is over
  2733. threashold, in dB/s. <em>decay</em> controls how fast gain is restored once the level
  2734. drops below threashold, again in dB/s. It is typically set to a longer value than attack.
  2735. </p>
  2736. <p class=func><span class=keyword>autoVolumeEnable</span>();</p>
  2737. <p class=desc>Enables auto volume control, using the previously specified settings.
  2738. </p>
  2739. <p class=func><span class=keyword>autoVolumeDisable</span>();</p>
  2740. <p class=desc>Disables auto volume control.
  2741. </p>
  2742. <p class=func><span class=keyword>surroundSoundEnable</span>();</p>
  2743. <p class=desc>Enable virtual surround processing, to give a broader and
  2744. deeper stereo image (even with mono input).
  2745. </p>
  2746. <p class=func><span class=keyword>surroundSoundDisable</span>();</p>
  2747. <p class=desc>Disable virtual surround processing. Before disabling, ramp up
  2748. the width to maximum to avoid pops.
  2749. </p>
  2750. <p class=func><span class=keyword>surroundSound</span>(width);</p>
  2751. <p class=desc>Configures virtual surround width from 0 (mono) to 7 (widest).
  2752. </p>
  2753. <p class=func><span class=keyword>surroundSound</span>(width, select);</p>
  2754. <p class=desc>Configures virtual surround width from 0 (mono) to 7 (widest).
  2755. <em>select</em> may be set to 1 (disable), 2 (mono input) or 3 (stereo input).
  2756. </p>
  2757. <p class=func><span class=keyword>enhanceBassEnable</span>();</p>
  2758. <p class=desc>Enable bass enhancement. A mono, low-pass filtered copy of
  2759. the original stereo signal has bass levels boosted and is then mixed back into
  2760. the stereo signal, which is then optionally high pass filtered (to remove
  2761. inaudible subsonic frequencies).
  2762. </p>
  2763. <p class=func><span class=keyword>enhanceBassDisable</span>();</p>
  2764. <p class=desc>Disable bass enhancement. Before disabling, ramp down the bass
  2765. enhancement level to zero.
  2766. </p>
  2767. <p class=func><span class=keyword>enhanceBass</span>(lr_lev, bass_lev);</p>
  2768. <p class=desc>Configures the bass enhancement by setting the levels of the
  2769. original stereo signal and the bass-enhanced mono level which will be mixed together.
  2770. There is no high-pass filter.
  2771. </p>
  2772. <p class=desc>When changing bass level, call this function repeatedly to ramp up or down the bass in
  2773. steps of 0.5dB, to avoid pops.
  2774. </p>
  2775. <p class=func><span class=keyword>enhanceBass</span>(lr_lev, bass_lev, hpf_bypass, cutoff);</p>
  2776. <p class=desc>Configures the bass enhancement by setting the levels of the
  2777. original stereo signal and the bass-enhanced mono level which will be mixed together.
  2778. The high-pass filter may be enabled (0) or bypassed (1). The cutoff frequency is specified
  2779. as follows:
  2780. </p>
  2781. <pre class="desc">
  2782. value frequency
  2783. 0 80Hz
  2784. 1 100Hz
  2785. 2 125Hz
  2786. 3 150Hz
  2787. 4 175Hz
  2788. 5 200Hz
  2789. 6 225Hz
  2790. </pre>
  2791. <p class=desc>When changing bass level, call this function repeatedly to ramp up or down the bass in
  2792. steps of 0.5dB, to avoid pops.
  2793. </p>
  2794. <p class=func><span class=keyword>eqSelect</span>(n);</p>
  2795. <p class=desc>Selects the type of frequency control, where <em>n</em> is
  2796. one of</p>
  2797. <p class=desc><b>FLAT_FREQUENCY (0)</b><br>
  2798. Equalizers and tone controls disabled, flat frequency response.</p>
  2799. <p class=desc><b>PARAMETRIC_EQUALIZER (1)</b><br>
  2800. Enables the 7-band parametric equalizer, thus disabling the
  2801. tone controls and graphic equalizer.</p>
  2802. <p class=desc><b>TONE_CONTROLS (2)</b><br>
  2803. Enables bass and treble tone controls, disabling the parametric
  2804. equalization and graphic equalizer.</p>
  2805. <p class=desc><b>GRAPHIC_EQUALIZER (3)</b><br>
  2806. Enables the five-band graphic equalizer, disabling the parametric
  2807. equalization and tone controls.</p>
  2808. <p class=func><span class=keyword>eqBands</span>(bass, treble);</p>
  2809. <p class=desc>Configures bass and treble tone controls, which are
  2810. implemented as one second order low pass filter (bass) in parallel with
  2811. one second order high pass filter (treble).
  2812. </p>
  2813. <p class=desc>When changing bass or treble level, call this function repeatedly to ramp
  2814. up or down the level in steps of 0.04 (=0.5dB) or so, to avoid pops.
  2815. </p>
  2816. <p class=func><span class=keyword>eqBands</span>(bass, mid_bass, midrange, mid_treble, treble);</p>
  2817. <p class=desc>Configures the graphic equalizer. It is implemented by five parallel,
  2818. second order biquad filters with fixed frequencies of 115Hz, 330Hz, 990Hz, 3kHz,
  2819. and 9.9kHz. Each band has a range of adjustment from 1.00 (+12dB) to -1.00 (-11.75dB).
  2820. </p>
  2821. <p class=func><span class=keyword>eqBand</span>(bandNum, n);</p>
  2822. <p class=desc>Configures the gain or cut on one band in the graphic equalizer.
  2823. <em>bandnum</em> can range from 1 to 5; <em>n</em> is a float in the range 1.00 to -1.00.
  2824. </p>
  2825. <p class=desc>When changing a band, call this function repeatedly to ramp up the gain in steps of 0.5dB,
  2826. to avoid pops.
  2827. </p>
  2828. <p class=func><span class=keyword>eqFilter</span>(filterNum, filterParameters);</p>
  2829. <p class=desc>Configurs the parametric equalizer. The number of filters (1 to 7)
  2830. is specified along with a pointer to an array of filter coefficients.
  2831. The parametric equalizer is implemented using 7 cascaded, second order bi-quad
  2832. filters whose frequencies, gain, and Q may be freely configured, but each filter
  2833. can only be specified as a set of filter coefficients.
  2834. </p>
  2835. <p class=func><span class=keyword>eqFilterCount</span>(n);</p>
  2836. <p class=desc>Enables zero or more of the already enabled parametric filters.
  2837. </p>
  2838. <h3>Examples</h3>
  2839. <p>Nearly all of the library's examples use this object. These
  2840. examples demonstrate its special features.
  2841. </p>
  2842. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughStereo
  2843. </p>
  2844. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; dap_bass_enhance
  2845. </p>
  2846. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; dap_avc_agc
  2847. </p>
  2848. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; balanceDAC
  2849. </p>
  2850. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; balanceHP
  2851. </p>
  2852. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; CalcBiquadToneControlDAP
  2853. </p>
  2854. <h3>Notes</h3>
  2855. <p>TODO: add example with rock/classical/speech presets, where rock uses bass boost
  2856. and surround enhancement while speech uses bandpass filtering and auto volume control
  2857. compression.
  2858. </p>
  2859. <p>TODO: add example with two analogRead pots for bass and treble to demonstrate ramping.
  2860. </p>
  2861. </script>
  2862. <script type="text/x-red" data-template-name="AudioControlSGTL5000">
  2863. <div class="form-row">
  2864. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2865. <input type="text" id="node-input-name" placeholder="Name">
  2866. </div>
  2867. </script>
  2868. <script type="text/javascript">
  2869. RED.nodes.registerType('AudioControlWM8731',{
  2870. shortName: "wm8731",
  2871. inputs:0,
  2872. outputs:0,
  2873. category: 'control-function',
  2874. color:"#E6E0F8",
  2875. icon: "arrow-in.png"
  2876. });
  2877. </script>
  2878. <script type="text/x-red" data-help-name="AudioControlWM8731">
  2879. <h3>Summary</h3>
  2880. <p>Control a WM8731 chip in slave mode, where it receives all clocks from Teensy</p>
  2881. <h3>Audio Connections</h3>
  2882. <p>This object has no audio inputs or outputs. Separate i2s objects
  2883. are used to send and receive audio data. I2S master mode objects
  2884. must be used, since this control object configures the WM8731 into
  2885. slave mode.
  2886. </p>
  2887. <h3>Functions</h3>
  2888. <p class=func><span class=keyword>enable</span>();</p>
  2889. <p class=desc>blah blah blah blah
  2890. </p>
  2891. <p class=func><span class=keyword>disable</span>();</p>
  2892. <p class=desc>not implemented
  2893. </p>
  2894. <p class=func><span class=keyword>volume</span>(level);</p>
  2895. <p class=desc>blah blah blah blah
  2896. </p>
  2897. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  2898. <p class=desc>not implemented
  2899. </p>
  2900. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  2901. <p class=desc>not implemented
  2902. </p>
  2903. <!--<h3>Examples</h3>
  2904. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2905. </p>-->
  2906. <h3>Notes</h3>
  2907. <p></p>
  2908. </script>
  2909. <script type="text/x-red" data-template-name="AudioControlWM8731">
  2910. <div class="form-row">
  2911. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2912. <input type="text" id="node-input-name" placeholder="Name">
  2913. </div>
  2914. </script>
  2915. <script type="text/javascript">
  2916. RED.nodes.registerType('AudioControlWM8731master',{
  2917. shortName: "wm8731m",
  2918. inputs:0,
  2919. outputs:0,
  2920. category: 'control-function',
  2921. color:"#E6E0F8",
  2922. icon: "arrow-in.png"
  2923. });
  2924. </script>
  2925. <script type="text/x-red" data-help-name="AudioControlWM8731master">
  2926. <h3>Summary</h3>
  2927. <p>Control a WM8731 chip in master mode, where it controls all I2S timing.</p>
  2928. <h3>Audio Connections</h3>
  2929. <p>This object has no audio inputs or outputs. Separate i2s objects
  2930. are used to send and receive audio data. I2S slave mode objects
  2931. must be used, since this control object configures the WM8731 into
  2932. master mode.
  2933. </p>
  2934. <h3>Functions</h3>
  2935. <p class=func><span class=keyword>enable</span>();</p>
  2936. <p class=desc>blah blah blah blah
  2937. </p>
  2938. <p class=func><span class=keyword>disable</span>();</p>
  2939. <p class=desc>not implemented
  2940. </p>
  2941. <p class=func><span class=keyword>volume</span>(level);</p>
  2942. <p class=desc>blah blah blah blah
  2943. </p>
  2944. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  2945. <p class=desc>not implemented
  2946. </p>
  2947. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  2948. <p class=desc>not implemented
  2949. </p>
  2950. <h3>Examples</h3>
  2951. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WM8731MikroSine
  2952. </p>
  2953. <h3>Notes</h3>
  2954. <p></p>
  2955. </script>
  2956. <script type="text/x-red" data-template-name="AudioControlWM8731master">
  2957. <div class="form-row">
  2958. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2959. <input type="text" id="node-input-name" placeholder="Name">
  2960. </div>
  2961. </script>
  2962. </body>
  2963. </html>