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.

2682 lines
113KB

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