You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3125 line
121KB

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