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.

3874 lines
173KB

  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-dialog-error-deploy" class="hide">
  154. <form class="form-horizontal">
  155. <div id="node-dialog-error-deploy-noio" style="text-align: center; padding-top: 10px;">
  156. <p>The workspace contains no input/output nodes!</p>
  157. <p>You need an input or an output to export the data!</p>
  158. <p>Without such a input/output function the exported
  159. code will not run properly!</p>
  160. </div>
  161. </form>
  162. </div>
  163. <div id="node-help" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="node-help-label" aria-hidden="true">
  164. <div class="modal-header">
  165. <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>
  166. </div>
  167. <div class="modal-body">
  168. <table>
  169. <tr>
  170. <td><span class="help-key">?</span></td><td>Help</td>
  171. <td><span class="help-key">Ctrl</span> <span class="help-key">a</span></td><td>Select all nodes</td>
  172. </tr>
  173. <tr>
  174. <td><span class="help-key">Ctrl</span> <span class="help-key">Space</span></td><td>Toggle sidebar</td>
  175. <td><span class="help-key">Shift</span> <span class="help-key">Click</span></td><td>Select all connected nodes</td>
  176. </tr>
  177. <tr>
  178. <td><span class="help-key">Ctrl</span> <span class="help-key">z</span></td><td>Undo</td>
  179. <td><span class="help-key">Ctrl</span> <span class="help-key">Click</span></td><td>Add/remove node from selection</td>
  180. </tr>
  181. <tr>
  182. <td></td><td></td>
  183. <td><span class="help-key">Delete</span></td><td>Delete selected nodes or link</td>
  184. </tr>
  185. <tr>
  186. <td><span class="help-key">Ctrl</span> <span class="help-key">x</span></td><td>Cut selected nodes</td>
  187. <td></td><td></td>
  188. </tr>
  189. <tr>
  190. <td><span class="help-key">Ctrl</span> <span class="help-key">c</span></td><td>Copy selected nodes</td>
  191. <td><span class="help-key">Ctrl</span> <span class="help-key">v</span></td><td>Paste nodes</td>
  192. </tr>
  193. <tr>
  194. <td><span class="help-key">Ctrl</span> <span class="help-key">i</span></td><td>Import nodes</td>
  195. <td><span class="help-key">Ctrl</span> <span class="help-key">e</span></td><td>Export selected nodes</td>
  196. </tr>
  197. <tr>
  198. <td colspan="2"></td>
  199. </tr>
  200. <tr>
  201. <td><span class="help-key">Ctrl</span> <span class="help-key">+</span></td><td>Zoom in</td>
  202. <td><span class="help-key">Ctrl</span> <span class="help-key">-</span></td><td>Zoom out</td>
  203. </tr>
  204. </table>
  205. </div>
  206. <div class="modal-footer">
  207. <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
  208. </div>
  209. </div>
  210. <div id="node-dialog-library-save-confirm" class="hide">
  211. <form class="form-horizontal">
  212. <div style="text-align: center; padding-top: 30px;">
  213. A <span id="node-dialog-library-save-type"></span> called <span id="node-dialog-library-save-name"></span> already exists. Overwrite?
  214. </div>
  215. </form>
  216. </div>
  217. <div id="node-dialog-library-save" class="hide">
  218. <form class="form-horizontal">
  219. <div class="form-row">
  220. <label for="node-dialog-library-save-folder"><i class="icon-folder-open"></i> Folder</label>
  221. <input type="text" id="node-dialog-library-save-folder" placeholder="Folder">
  222. </div>
  223. <div class="form-row">
  224. <label for="node-dialog-library-save-filename"><i class="icon-file"></i> Filename</label>
  225. <input type="text" id="node-dialog-library-save-filename" placeholder="Filename">
  226. </div>
  227. </form>
  228. </div>
  229. <div id="node-dialog-library-lookup" class="hide">
  230. <form class="form-horizontal">
  231. <div class="form-row">
  232. <ul id="node-dialog-library-breadcrumbs" class="breadcrumb">
  233. <li class="active"><a href="#">Library</a></li>
  234. </ul>
  235. </div>
  236. <div class="form-row">
  237. <div style="vertical-align: top; display: inline-block; height: 100%; width: 30%; padding-right: 20px;">
  238. <div id="node-select-library" style="border: 1px solid #999; width: 100%; height: 100%; overflow:scroll;"><ul></ul></div>
  239. </div>
  240. <div style="vertical-align: top; display: inline-block;width: 65%; height: 100%;">
  241. <div style="height: 100%; width: 95%;" class="node-text-editor" id="node-select-library-text" ></div>
  242. </div>
  243. </div>
  244. </form>
  245. </div>
  246. <div id="node-dialog-rename-workspace" class="hide">
  247. <form class="form-horizontal">
  248. <div class="form-row">
  249. <label for="node-input-workspace-name" ><i class="icon-tag"></i> Name:</label>
  250. <input type="text" id="node-input-workspace-name">
  251. </div>
  252. </form>
  253. </div>
  254. <div id="node-dialog-delete-workspace" class="hide">
  255. <form class="form-horizontal">
  256. <div style="text-align: center; padding-top: 30px;">
  257. Are you sure you want to delete '<span id="node-dialog-delete-workspace-name"></span>'?
  258. </div>
  259. </form>
  260. </div>
  261. <script type="text/x-red" data-template-name="export-clipboard-dialog">
  262. <div class="form-row">
  263. <label for="node-input-export" style="display: block; width:100%;"><i class="icon-share"></i> Source Code:</label>
  264. <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>
  265. </div>
  266. <div class="form-tips">
  267. Select the text above and copy to the clipboard with Ctrl-A Ctrl-C.
  268. </div>
  269. </script>
  270. <script type="text/x-red" data-template-name="export-library-dialog">
  271. <div class="form-row">
  272. <label for="node-input-filename" ><i class="icon-tag"></i> Filename:</label>
  273. <input type="text" id="node-input-filename" placeholder="Filename">
  274. </div>
  275. </script>
  276. <script type="text/x-red" data-template-name="import-dialog">
  277. <div class="form-row">
  278. <label for="node-input-import"><i class="icon-share"></i>Nodes:</label>
  279. <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>
  280. </div>
  281. <div class="form-tips">
  282. <label for="node-input-arduino" style="font-size: 13px; padding: 2px 0px 0px 4px;">
  283. <input style="margin-bottom: 4px; margin-right: 4px;" type="checkbox" id="node-input-arduino" checked="checked" class="input-block-level" />
  284. &nbsp;Import copied code from the Arduino IDE
  285. </label>
  286. </div>
  287. </script>
  288. <script src="jquery/js/jquery-1.9.1.js"></script>
  289. <script src="bootstrap/js/bootstrap.min.js"></script>
  290. <script src="jquery/js/jquery-ui-1.10.3.custom.min.js"></script>
  291. <script src="jquery/js/jquery.ui.touch-punch.min.js"></script>
  292. <script src="orion/built-editor.min.js"></script>
  293. <script src="red/d3/d3.v3.min.js"></script>
  294. <script src="red/main.js"></script>
  295. <script src="red/ui/state.js"></script>
  296. <script src="red/nodes.js"></script>
  297. <script src="red/storage.js"></script>
  298. <script src="red/history.js"></script>
  299. <script src="red/ui/keyboard.js"></script>
  300. <script src="red/ui/tabs.js"></script>
  301. <script src="red/ui/view.js"></script>
  302. <script src="red/ui/sidebar.js"></script>
  303. <script src="red/ui/palette.js"></script>
  304. <script src="red/ui/tab-info.js"></script>
  305. <script src="red/ui/tab-config.js"></script>
  306. <script src="red/ui/editor.js"></script>
  307. <script src="red/ui/library.js"></script>
  308. <script src="red/ui/notifications.js"></script>
  309. <script src="red/ui/touch/radialMenu.js"></script>
  310. <!--
  311. TODO: generate some or all of this automatically from the C++ source
  312. -->
  313. <!--
  314. TODO: add a field for maximum instance count
  315. -->
  316. <!--
  317. TODO: add a field for exclusive to other objects (not allowed if they're used)
  318. -->
  319. <!--
  320. TODO: add "parameters" fields, to replace the form html stuff
  321. -->
  322. <script type="text/x-red" data-container-name="NodeDefinitions">
  323. {"nodes":[
  324. {"type":"AudioInputI2S","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2s","inputs":0,"outputs":2,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  325. {"type":"AudioInputI2SQuad","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2s_quad","inputs":0,"outputs":4,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  326. {"type":"AudioInputAnalog","data":{"defaults":{"name":{"value":"new"}},"shortName":"adc","inputs":0,"outputs":1,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  327. {"type":"AudioInputAnalogStereo","data":{"defaults":{"name":{"value":"new"}},"shortName":"adcs","inputs":0,"outputs":2,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  328. {"type":"AudioInputI2Sslave","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2sslave","inputs":0,"outputs":2,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  329. {"type":"AudioInputTDM","data":{"defaults":{"name":{"value":"new"}},"shortName":"tdm","inputs":0,"outputs":16,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  330. {"type":"AudioInputUSB","data":{"defaults":{"name":{"value":"new"}},"shortName":"usb","inputs":0,"outputs":2,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  331. {"type":"AudioOutputI2S","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2s","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  332. {"type":"AudioOutputI2SQuad","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2s_quad","inputs":4,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  333. {"type":"AudioOutputSPDIF","data":{"defaults":{"name":{"value":"new"}},"shortName":"spdif","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  334. {"type":"AudioOutputPT8211","data":{"defaults":{"name":{"value":"new"}},"shortName":"pt8211","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  335. {"type":"AudioOutputAnalog","data":{"defaults":{"name":{"value":"new"}},"shortName":"dac","inputs":1,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  336. {"type":"AudioOutputAnalogStereo","data":{"defaults":{"name":{"value":"new"}},"shortName":"dacs","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  337. {"type":"AudioOutputPWM","data":{"defaults":{"name":{"value":"new"}},"shortName":"pwm","inputs":1,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  338. {"type":"AudioOutputI2Sslave","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2sslave","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  339. {"type":"AudioOutputTDM","data":{"defaults":{"name":{"value":"new"}},"shortName":"tdm","inputs":16,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  340. {"type":"AudioOutputUSB","data":{"defaults":{"name":{"value":"new"}},"shortName":"usb","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  341. {"type":"AudioMixer4","data":{"defaults":{"name":{"value":"new"}},"shortName":"mixer","inputs":4,"outputs":1,"category":"mixer-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  342. {"type":"AudioPlayMemory","data":{"defaults":{"name":{"value":"new"}},"shortName":"playMem","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  343. {"type":"AudioPlaySdWav","data":{"defaults":{"name":{"value":"new"}},"shortName":"playSdWav","inputs":0,"outputs":2,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  344. {"type":"AudioPlaySdRaw","data":{"defaults":{"name":{"value":"new"}},"shortName":"playSdRaw","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  345. {"type":"AudioPlaySerialflashRaw","data":{"defaults":{"name":{"value":"new"}},"shortName":"playFlashRaw","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  346. {"type":"AudioPlayQueue","data":{"defaults":{"name":{"value":"new"}},"shortName":"queue","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  347. {"type":"AudioRecordQueue","data":{"defaults":{"name":{"value":"new"}},"shortName":"queue","inputs":1,"outputs":0,"category":"record-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  348. {"type":"AudioSynthSimpleDrum","data":{"defaults":{"name":{"value":"new"}},"shortName":"drum","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  349. {"type":"AudioSynthKarplusStrong","data":{"defaults":{"name":{"value":"new"}},"shortName":"string","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  350. {"type":"AudioSynthWaveformSine","data":{"defaults":{"name":{"value":"new"}},"shortName":"sine","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  351. {"type":"AudioSynthWaveformSineHires","data":{"defaults":{"name":{"value":"new"}},"shortName":"sine_hires","inputs":0,"outputs":2,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  352. {"type":"AudioSynthWaveformSineModulated","data":{"defaults":{"name":{"value":"new"}},"shortName":"sine_fm","inputs":1,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  353. {"type":"AudioSynthWaveform","data":{"defaults":{"name":{"value":"new"}},"shortName":"waveform","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  354. {"type":"AudioSynthWaveformPWM","data":{"defaults":{"name":{"value":"new"}},"shortName":"pwm","inputs":1,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  355. {"type":"AudioSynthToneSweep","data":{"defaults":{"name":{"value":"new"}},"shortName":"tonesweep","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  356. {"type":"AudioSynthWaveformDc","data":{"defaults":{"name":{"value":"new"}},"shortName":"dc","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  357. {"type":"AudioSynthNoiseWhite","data":{"defaults":{"name":{"value":"new"}},"shortName":"noise","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  358. {"type":"AudioSynthNoisePink","data":{"defaults":{"name":{"value":"new"}},"shortName":"pink","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  359. {"type":"AudioEffectFade","data":{"defaults":{"name":{"value":"new"}},"shortName":"fade","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  360. {"type":"AudioEffectChorus","data":{"defaults":{"name":{"value":"new"}},"shortName":"chorus","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  361. {"type":"AudioEffectFlange","data":{"defaults":{"name":{"value":"new"}},"shortName":"flange","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  362. {"type":"AudioEffectReverb","data":{"defaults":{"name":{"value":"new"}},"shortName":"reverb","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  363. {"type":"AudioEffectEnvelope","data":{"defaults":{"name":{"value":"new"}},"shortName":"envelope","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  364. {"type":"AudioEffectMultiply","data":{"defaults":{"name":{"value":"new"}},"shortName":"multiply","inputs":2,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  365. {"type":"AudioEffectDelay","data":{"defaults":{"name":{"value":"new"}},"shortName":"delay","inputs":1,"outputs":8,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  366. {"type":"AudioEffectDelayExternal","data":{"defaults":{"name":{"value":"new"}},"shortName":"delayExt","inputs":1,"outputs":8,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  367. {"type":"AudioEffectBitcrusher","data":{"shortName":"bitcrusher","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  368. {"type":"AudioEffectMidSide","data":{"shortName":"midside","inputs":2,"outputs":2,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  369. {"type":"AudioFilterBiquad","data":{"defaults":{"name":{"value":"new"}},"shortName":"biquad","inputs":1,"outputs":1,"category":"filter-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  370. {"type":"AudioFilterFIR","data":{"defaults":{"name":{"value":"new"}},"shortName":"fir","inputs":1,"outputs":1,"category":"filter-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  371. {"type":"AudioFilterStateVariable","data":{"defaults":{"name":{"value":"new"}},"shortName":"filter","inputs":2,"outputs":3,"category":"filter-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  372. {"type":"AudioAnalyzePeak","data":{"defaults":{"name":{"value":"new"}},"shortName":"peak","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  373. {"type":"AudioAnalyzeRMS","data":{"defaults":{"name":{"value":"new"}},"shortName":"rms","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  374. {"type":"AudioAnalyzeFFT256","data":{"defaults":{"name":{"value":"new"}},"shortName":"fft256","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  375. {"type":"AudioAnalyzeFFT1024","data":{"defaults":{"name":{"value":"new"}},"shortName":"fft1024","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  376. {"type":"AudioAnalyzeToneDetect","data":{"defaults":{"name":{"value":"new"}},"shortName":"tone","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  377. {"type":"AudioAnalyzeNoteFrequency","data":{"defaults":{"name":{"value":"new"}},"shortName":"notefreq","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  378. {"type":"AudioAnalyzePrint","data":{"defaults":{"name":{"value":"new"}},"shortName":"print","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  379. {"type":"AudioControlSGTL5000","data":{"defaults":{"name":{"value":"new"}},"shortName":"sgtl5000","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  380. {"type":"AudioControlAK4558","data":{"defaults":{"name":{"value":"new"}},"shortName":"ak4558","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  381. {"type":"AudioControlCS4272","data":{"defaults":{"name":{"value":"new"}},"shortName":"cs4272","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  382. {"type":"AudioControlWM8731","data":{"defaults":{"name":{"value":"new"}},"shortName":"wm8731","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  383. {"type":"AudioControlWM8731master","data":{"defaults":{"name":{"value":"new"}},"shortName":"wm8731m","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
  384. {"type":"AudioControlCS42448","data":{"defaults":{"name":{"value":"new"}},"shortName":"cs42448","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}}
  385. ]}
  386. </script>
  387. <script type="text/x-red" data-help-name="AudioInputI2S">
  388. <h3>Summary</h3>
  389. <div class=tooltipinfo>
  390. <p>Receive 16 bit stereo audio from the
  391. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  392. or another I2S device, using I2S master mode.</p>
  393. <p align=center><img src="img/audioshield_inputs.jpg"></p>
  394. </div>
  395. <h3>Audio Connections</h3>
  396. <table class=doc align=center cellpadding=3>
  397. <tr class=top><th>Port</th><th>Purpose</th></tr>
  398. <tr class=odd><td align=center>Out 0</td><td>Left Channel</td></tr>
  399. <tr class=odd><td align=center>Out 1</td><td>Right Channel</td></tr>
  400. </table>
  401. <h3>Functions</h3>
  402. <p>This object has no functions to call from the Arduino sketch. It
  403. simply streams data from the I2S hardware to its 2 output ports.</p>
  404. <h3>Hardware</h3>
  405. <p align=center><img src="img/audioshield_backside.jpg"></p>
  406. <p>The I2S signals are used in "master" mode, where Teensy creates
  407. all 3 clock signals and controls all data timing.</p>
  408. <table class=doc align=center cellpadding=3>
  409. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  410. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  411. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  412. <tr class=odd><td align=center>13</td><td>RX</td><td>Input</td></tr>
  413. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  414. </table>
  415. <p>Audio from
  416. master mode I2S may be used in the same project as ADC, DAC and
  417. PWM signals, because all remain in sync to Teensy's timing</p>
  418. <h3>Examples</h3>
  419. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughStereo
  420. </p>
  421. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  422. </p>
  423. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterStereo
  424. </p>
  425. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; FFT
  426. </p>
  427. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; SpectrumAnalyzerBasic
  428. </p>
  429. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Chorus
  430. </p>
  431. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Flange
  432. </p>
  433. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter
  434. </p>
  435. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter_FIR
  436. </p>
  437. <h3>Notes</h3>
  438. <p>Normally, this object is used with the Audio Shield, which
  439. is controlled separately by the "sgtl5000" object.</p>
  440. <p>Only one I2S input and one I2S output object may be used. Master
  441. and slave modes may not be mixed (both must be of the same type).
  442. </p>
  443. <p>I2S master objects can be used together with non-I2S input and output
  444. objects, for simultaneous audio streaming on different hardware.</p>
  445. </script>
  446. <script type="text/x-red" data-template-name="AudioInputI2S">
  447. <div class="form-row">
  448. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  449. <input type="text" id="node-input-name" placeholder="Name">
  450. </div>
  451. </script>
  452. <script type="text/x-red" data-help-name="AudioInputI2SQuad">
  453. <h3>Summary</h3>
  454. <div class=tooltipinfo>
  455. <p>Receive 16 bit quad (4) channel audio from two
  456. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shields</a>
  457. or another I2S devices, using I2S master mode.</p>
  458. <p align=center><img src="img/audioshield_quad_in.jpg"></p>
  459. </div>
  460. <h3>Audio Connections</h3>
  461. <table class=doc align=center cellpadding=3>
  462. <tr class=top><th>Port</th><th>Purpose</th></tr>
  463. <tr class=odd><td align=center>Out 0</td><td>Channel #1</td></tr>
  464. <tr class=odd><td align=center>Out 1</td><td>Channel #2</td></tr>
  465. <tr class=odd><td align=center>Out 2</td><td>Channel #3</td></tr>
  466. <tr class=odd><td align=center>Out 3</td><td>Channel #4</td></tr>
  467. </table>
  468. <h3>Functions</h3>
  469. <p>This object has no functions to call from the Arduino sketch. It
  470. simply streams data from the I2S hardware to its 4 output ports.</p>
  471. <h3>Hardware</h3>
  472. <p>See this Sparkfun blog for <a href="https://www.sparkfun.com/news/2055" target="_blank">how
  473. to connect two audio adaptors for 4 channel audio</a>.
  474. <p>The I2S signals are used in "master" mode, where Teensy creates
  475. all 3 clock signals and controls all data timing.</p>
  476. <table class=doc align=center cellpadding=3>
  477. <tr class=top><th>Teensy<br>3.2 Pin</th><th>Teensy<br>3.5/3.6 Pin</th><th>Signal</th><th>Direction</th></tr>
  478. <tr class=odd><td align=center>9</td><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  479. <tr class=odd><td align=center>11</td><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  480. <tr class=odd><td align=center>13</td><td align=center>13</td><td>RX</td><td>Input</td></tr>
  481. <tr class=odd><td align=center>30</td><td align=center>38</td><td>RX</td><td>Input</td></tr>
  482. <tr class=odd><td align=center>23</td><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  483. </table>
  484. <p>Audio from
  485. master mode I2S may be used in the same project as ADC, DAC and
  486. PWM signals, because all remain in sync to Teensy's timing</p>
  487. <h3>Examples</h3>
  488. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughQuad
  489. </p>
  490. <h3>Notes</h3>
  491. <p>Normally, this object is used with two Audio Shield, which
  492. are controlled separately by a pair "sgtl5000" object.</p>
  493. </script>
  494. <script type="text/x-red" data-template-name="AudioInputI2SQuad">
  495. <div class="form-row">
  496. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  497. <input type="text" id="node-input-name" placeholder="Name">
  498. </div>
  499. </script>
  500. <script type="text/x-red" data-help-name="AudioInputAnalog">
  501. <h3>Summary</h3>
  502. <div class=tooltipinfo>
  503. <p>Receive audio using the built-in analog to digital converter.</p>
  504. </div>
  505. <h3>Audio Connections</h3>
  506. <table class=doc align=center cellpadding=3>
  507. <tr class=top><th>Port</th><th>Purpose</th></tr>
  508. <tr class=odd><td align=center>Out 0</td><td>Audio Channel</td></tr>
  509. </table>
  510. <h3>Functions</h3>
  511. <p>This object has no functions to call from the Arduino sketch. It
  512. simply streams data from the ADC to its output port.</p>
  513. <h3>Hardware</h3>
  514. <p>Pin A2 is used for audio input. This circuitry is recommended.</p>
  515. <p align=center><img src="img/adccircuit.png"></p>
  516. <p>Signal range is 0 to 1.2V</p>
  517. <p>With a <a href="https://forum.pjrc.com/threads/40468-Help-with-Basic-Audio-Lib-results?p=126317&viewfull=1#post126317">small modification</a> Adafruit's <a href="https://www.adafruit.com/products/1063">MAX4466 microphone</a> can be used</p>
  518. <p align=center><a href="https://forum.pjrc.com/threads/40468-Help-with-Basic-Audio-Lib-results?p=126317&viewfull=1#post126317"><img src="img/adccircuitmic.jpg" border=0></a></p>
  519. <p>Control Voltage (CV) from +5V to -5V can be adapted with a
  520. <a href="https://www.dorkbotpdx.org/blog/paul/control_voltage_cv_to_analog_input_pin">simple circuit</a>
  521. or better <a href="https://forum.pjrc.com/threads/28423?p=71257&viewfull=1#post71257">opamp-based circuity</a>
  522. to Teensy's 0-1.2V analog input range.</p>
  523. <h3>Examples</h3>
  524. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  525. </p>
  526. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterMono
  527. </p>
  528. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_7segment
  529. </p>
  530. <p class=exam>File &gt; Examples &gt; OctoWS2811 &gt; SpectrumAnalyzer
  531. </p>
  532. <h3>Notes</h3>
  533. <p><b>analogRead() must not be used</b>, because AudioInputAnalog is regularly
  534. accessing the ADC hardware. If both access the hardware at the same
  535. moment, analogRead() can end up waiting forever, which effectively
  536. crashes your program.
  537. </p>
  538. <p>A different pin may be used, but adding it as an parameter
  539. to the AudioInputAnalog object definition.
  540. </p>
  541. <p>For example, to use pin A3:
  542. </p>
  543. <p class=desc><span class=keyword>AudioInputAnalog</span> adc1(<span class=literal>A3</span>);
  544. </p>
  545. <p>Noise due to high source impedance, which allows rapidly switching digital signals
  546. to capacitively couple... avoiding higher analog impedance is the solution.</p>
  547. <p>Power Supply rejection issue with simple DC bias (bigger capacitor may be needed if 3.3V has low frequency noise)</p>
  548. <p>Algorithm for automatic DC bias tracking</p>
  549. <p>TODO: actual noise measurements with different input circuitry
  550. (it's not as quiet as the audio shield)</p>
  551. </script>
  552. <script type="text/x-red" data-template-name="AudioInputAnalog">
  553. <div class="form-row">
  554. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  555. <input type="text" id="node-input-name" placeholder="Name">
  556. </div>
  557. </script>
  558. <script type="text/x-red" data-help-name="AudioInputAnalogStereo">
  559. <h3>Summary</h3>
  560. <div class=tooltipinfo>
  561. <p>Receive stereo audio using the built-in analog to digital converters.</p>
  562. </div>
  563. <h3>Audio Connections</h3>
  564. <table class=doc align=center cellpadding=3>
  565. <tr class=top><th>Port</th><th>Purpose</th></tr>
  566. <tr class=odd><td align=center>Out 0</td><td>Audio Channel (Left)</td></tr>
  567. <tr class=odd><td align=center>Out 1</td><td>Audio Channel (Right)</td></tr>
  568. </table>
  569. <h3>Functions</h3>
  570. <p>This object has no functions to call from the Arduino sketch. It
  571. simply streams data from both ADCs to its output ports.</p>
  572. <h3>Hardware</h3>
  573. <p>By default, pins A2 & A3 are used for audio input. This circuitry is recommended.</p>
  574. <p align=center><img src="img/adccircuit2.png"></p>
  575. <p>Signal range is 0 to 1.2V</p>
  576. <p>Control Voltage (CV) from +5V to -5V can be adapted with a
  577. <a href="https://www.dorkbotpdx.org/blog/paul/control_voltage_cv_to_analog_input_pin">simple circuit</a>
  578. or better <a href="https://forum.pjrc.com/threads/28423?p=71257&viewfull=1#post71257">opamp-based circuity</a>
  579. to Teensy's 0-1.2V analog input range.</p>
  580. <h3>Examples</h3>
  581. <!--
  582. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  583. </p>
  584. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterMono
  585. </p>
  586. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_7segment
  587. </p>
  588. <p class=exam>File &gt; Examples &gt; OctoWS2811 &gt; SpectrumAnalyzer
  589. </p>
  590. -->
  591. <h3>Notes</h3>
  592. <p><b>analogRead() must not be used</b>, because AudioInputAnalogStereo is regularly
  593. accessing the ADC hardware. If both access the hardware at the same
  594. moment, analogRead() can end up waiting forever, which effectively
  595. crashes your program.
  596. </p>
  597. <p>A different pin may be used, but adding it as an parameter
  598. to the AudioInputAnalog object definition.
  599. </p>
  600. <p>For example:
  601. </p>
  602. <p class=desc><span class=keyword>AudioInputAnalogStereo</span> adc1(<span class=literal>A3</span>, <span class=literal>A2</span>);
  603. </p>
  604. <p>TODO: add info here about which pins work for input 0 and 1.
  605. </p>
  606. <p>Noise due to high source impedance, which allows rapidly switching digital signals
  607. to capacitively couple... avoiding higher analog impedance is the solution.</p>
  608. <p>Power Supply rejection issue with simple DC bias (bigger capacitor may be needed if 3.3V has low frequency noise)</p>
  609. <p>Algorithm for automatic DC bias tracking</p>
  610. <p>TODO: actual noise measurements with different input circuitry
  611. (it's not as quiet as the audio shield)</p>
  612. </script>
  613. <script type="text/x-red" data-template-name="AudioInputAnalogStereo">
  614. <div class="form-row">
  615. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  616. <input type="text" id="node-input-name" placeholder="Name">
  617. </div>
  618. </script>
  619. <script type="text/x-red" data-help-name="AudioInputI2Sslave">
  620. <h3>Summary</h3>
  621. <div class=tooltipinfo>
  622. <p>Receive 16 bit stereo audio from an I2S device using I2S slave mode
  623. (where the ADC or codec chip, not Teensy, controls audio timing).</p>
  624. </div>
  625. <h3>Audio Connections</h3>
  626. <table class=doc align=center cellpadding=3>
  627. <tr class=top><th>Port</th><th>Purpose</th></tr>
  628. <tr class=odd><td align=center>Out 0</td><td>Left Channel</td></tr>
  629. <tr class=odd><td align=center>Out 1</td><td>Right Channel</td></tr>
  630. </table>
  631. <h3>Functions</h3>
  632. <p>This object has no functions to call from the Arduino sketch. It
  633. simply streams data from the I2S hardware to its 2 output ports.</p>
  634. <h3>Hardware</h3>
  635. <p>The I2S signals are used in "slave" mode, where the I2S device controls
  636. data timing.</p>
  637. <table class=doc align=center cellpadding=3>
  638. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  639. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Input</td></tr>
  640. <tr class=odd><td align=center>13</td><td>RX</td><td>Input</td></tr>
  641. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Input</td></tr>
  642. </table>
  643. <!--
  644. <h3>Examples</h3>
  645. <p class=exam>File &gt; Examples &gt; Audio &gt;
  646. </p>
  647. -->
  648. <h3>Notes</h3>
  649. <p>Slave mode I2S <b>should not used in the same project as ADC, DAC and
  650. PWM</b> signals. Differences in timing between the I2S device and
  651. Teensy's clock can cause occasional audio glitches when I2S slave mode
  652. is used together with other input or output objects based on Teensy's
  653. timing.</p>
  654. <p>Only one I2S input and one I2S output object may be used. Master
  655. and slave modes may not be mixed (both must be of the same type).
  656. </p>
  657. </script>
  658. <script type="text/x-red" data-template-name="AudioInputI2Sslave">
  659. <div class="form-row">
  660. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  661. <input type="text" id="node-input-name" placeholder="Name">
  662. </div>
  663. </script>
  664. <script type="text/x-red" data-help-name="AudioInputTDM">
  665. <h3>Summary</h3>
  666. <div class=tooltipinfo>
  667. <p>Receive a 256 bit Time Division Multiplexed frame containing
  668. many audio channels.</p>
  669. <p align=center><img src="img/tdm.jpg"></p>
  670. </div>
  671. <h3>Audio Connections</h3>
  672. <table class=doc align=center cellpadding=3>
  673. <tr class=top><th>Port</th><th>Purpose</th></tr>
  674. <tr class=odd><td align=center>Out 0</td><td>Bits 0 to 15</td></tr>
  675. <tr class=odd><td align=center>Out 1</td><td>Bits 16 to 31</td></tr>
  676. <tr class=odd><td align=center>Out 2</td><td>Bits 32 to 47</td></tr>
  677. <tr class=odd><td align=center>Out 3</td><td>Bits 48 to 63</td></tr>
  678. <tr class=odd><td align=center>Out 4</td><td>Bits 64 to 79</td></tr>
  679. <tr class=odd><td align=center>Out 5</td><td>Bits 80 to 95</td></tr>
  680. <tr class=odd><td align=center>Out 6</td><td>Bits 96 to 111</td></tr>
  681. <tr class=odd><td align=center>Out 7</td><td>Bits 112 to 127</td></tr>
  682. <tr class=odd><td align=center>Out 8</td><td>Bits 128 to 143</td></tr>
  683. <tr class=odd><td align=center>Out 9</td><td>Bits 144 to 159</td></tr>
  684. <tr class=odd><td align=center>Out 10</td><td>Bits 160 to 175</td></tr>
  685. <tr class=odd><td align=center>Out 11</td><td>Bits 176 to 191</td></tr>
  686. <tr class=odd><td align=center>Out 12</td><td>Bits 192 to 207</td></tr>
  687. <tr class=odd><td align=center>Out 13</td><td>Bits 208 to 223</td></tr>
  688. <tr class=odd><td align=center>Out 14</td><td>Bits 224 to 239</td></tr>
  689. <tr class=odd><td align=center>Out 15</td><td>Bits 240 to 255</td></tr>
  690. </table>
  691. <h3>Functions</h3>
  692. <p>This object has no functions to call from the Arduino sketch. It
  693. simply streams data from the TDM hardware to its 16 output ports.</p>
  694. <h3>Hardware</h3>
  695. <p>TDM has been tested with this <a href="https://oshpark.com/shared_projects/2Yj6rFaW">
  696. CS42448 Circuit Board</a>. It may also work with
  697. <a href="https://forum.pjrc.com/threads/42894">Invensense ICS-52000 microphones</a>.
  698. </p>
  699. <table class=doc align=center cellpadding=3>
  700. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  701. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output, 11.3 MHz</td></tr>
  702. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output, 22.6 MHz</td></tr>
  703. <tr class=odd><td align=center>13</td><td>RX</td><td>Input, 11.3 Mbit/sec</td></tr>
  704. <tr class=odd><td align=center>23</td><td>FS</td><td>Output</td></tr>
  705. </table>
  706. <p>Audio from
  707. master mode TDM may be used in the same project as ADC, DAC and
  708. PWM signals, because all remain in sync to Teensy's timing</p>
  709. <!--<h3>Examples</h3>-->
  710. <h3>Notes</h3>
  711. <p>Only one TDM input and one TDM output object may be used. The
  712. I2S hardware is used by TDM, so TDM objects may not be used
  713. together with I2S, SPDIF or PT8211.</p>
  714. <p>When used with TDM devices which transmit 32 bit audio, the
  715. even numbered channels will contain the useful upper 16
  716. bits of audio data.</p>
  717. <p>AudioMemory should be at least 16. Even if most channels are
  718. unused, this TDM object will need to allocate 16 blocks of
  719. memory.</p>
  720. </script>
  721. <script type="text/x-red" data-template-name="AudioInputTDM">
  722. <div class="form-row">
  723. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  724. <input type="text" id="node-input-name" placeholder="Name">
  725. </div>
  726. </script>
  727. <script type="text/x-red" data-help-name="AudioInputUSB">
  728. <h3>Summary</h3>
  729. <div class=tooltipinfo>
  730. <p>Receive stereo audio from a PC or Mac. Teensy appears as a USB
  731. sound device.</p>
  732. <p align=center><img src="img/usbtype_audio_in.png"></p>
  733. </div>
  734. <h3>Audio Connections</h3>
  735. <table class=doc align=center cellpadding=3>
  736. <tr class=top><th>Port</th><th>Purpose</th></tr>
  737. <tr class=odd><td align=center>Out 0</td><td>Left Channel</td></tr>
  738. <tr class=odd><td align=center>Out 1</td><td>Right Channel</td></tr>
  739. </table>
  740. <h3>Functions</h3>
  741. <p>This object has no functions to call from the Arduino sketch. It
  742. simply streams data from the USB to its 2 output ports.</p>
  743. <!--
  744. <h3>Hardware</h3>
  745. -->
  746. <h3>Examples</h3>
  747. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughUSB</p>
  748. </p>
  749. <h3>Notes</h3>
  750. <p>Arduino's <b>Tools &gt; USB Type</b> menu must be set to <b>Audio</b>.
  751. </p>
  752. <p align=center><img src="img/usbtype_audio.png"></p>
  753. <p>USB input &amp; output does not cause the Teensy Audio Library to
  754. update. At least one non-USB input or output object must be
  755. present for the entire library to update properly.</p>
  756. <p>A known problem exists with USB audio from Macintosh computers.
  757. An imperfect <a href="https://forum.pjrc.com/threads/34855-Distorted-audio-when-using-USB-input-on-Teensy-3-1?p=110392&viewfull=1#post110392">workaround
  758. can be enabled by editing usb_audio.cpp</a>.
  759. Find and uncomment "#define MACOSX_ADAPTIVE_LIMIT".</p>
  760. </script>
  761. <script type="text/x-red" data-template-name="AudioInputUSB">
  762. <div class="form-row">
  763. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  764. <input type="text" id="node-input-name" placeholder="Name">
  765. </div>
  766. </script>
  767. <script type="text/x-red" data-help-name="AudioOutputI2S">
  768. <h3>Summary</h3>
  769. <div class=tooltipinfo>
  770. <p>Transmit 16 bit stereo audio to the
  771. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  772. or another I2S device, using I2S master mode.</p>
  773. <p align=center><img src="img/audioshield_outputs.jpg"></p>
  774. </div>
  775. <h3>Audio Connections</h3>
  776. <table class=doc align=center cellpadding=3>
  777. <tr class=top><th>Port</th><th>Purpose</th></tr>
  778. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  779. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  780. </table>
  781. <h3>Functions</h3>
  782. <p>This object has no functions to call from the Arduino sketch. It
  783. simply streams data from its 2 input ports to the I2S hardware.</p>
  784. <h3>Hardware</h3>
  785. <p align=center><img src="img/audioshield_backside.jpg"></p>
  786. <p>The I2S signals are used in "master" mode, where Teensy creates
  787. all 3 clock signals and controls all data timing.</p>
  788. <table class=doc align=center cellpadding=3>
  789. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  790. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  791. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  792. <tr class=odd><td align=center>22</td><td>TX</td><td>Output</td></tr>
  793. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  794. </table>
  795. <p>Audio from
  796. master mode I2S may be used in the same project as ADC, DAC and
  797. PWM signals, because all remain in sync to Teensy's timing</p>
  798. <h3>Examples</h3>
  799. <p>Nearly all the examples use this object. Here are some of the highlights:</p>
  800. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughStereo
  801. </p>
  802. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  803. </p>
  804. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  805. </p>
  806. <p class=exam>File &gt; Examples &gt; Audio &gt; WavFilePlayer
  807. </p>
  808. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Chorus
  809. </p>
  810. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  811. </p>
  812. <h3>Notes</h3>
  813. <p>Normally, this object is used with the Audio Shield, which
  814. is controlled separately by the "sgtl5000" object.</p>
  815. <p>Only one I2S input and one I2S output object may be used. Master
  816. and slave modes may not be mixed (both must be of the same type).
  817. </p>
  818. </script>
  819. <script type="text/x-red" data-template-name="AudioOutputI2S">
  820. <div class="form-row">
  821. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  822. <input type="text" id="node-input-name" placeholder="Name">
  823. </div>
  824. </script>
  825. <script type="text/x-red" data-help-name="AudioOutputI2SQuad">
  826. <h3>Summary</h3>
  827. <div class=tooltipinfo>
  828. <p>Transmit quad (4) channel 16 bit audio, using I2S master mode.</p>
  829. <p align=center><img src="img/audioshield_quad_out.jpg"></p>
  830. </div>
  831. <h3>Audio Connections</h3>
  832. <table class=doc align=center cellpadding=3>
  833. <tr class=top><th>Port</th><th>Purpose</th></tr>
  834. <tr class=odd><td align=center>In 0</td><td>Channel #1</td></tr>
  835. <tr class=odd><td align=center>In 1</td><td>Channel #2</td></tr>
  836. <tr class=odd><td align=center>In 2</td><td>Channel #3</td></tr>
  837. <tr class=odd><td align=center>In 3</td><td>Channel #4</td></tr>
  838. </table>
  839. <h3>Functions</h3>
  840. <p>This object has no functions to call from the Arduino sketch. It
  841. simply streams data from its 4 input ports to the I2S hardware.</p>
  842. <h3>Hardware</h3>
  843. <p>See this Sparkfun blog for <a href="https://www.sparkfun.com/news/2055" target="_blank">how
  844. to connect two audio adaptors for 4 channel audio</a>. More
  845. <a href="https://forum.pjrc.com/threads/29373-Bit-bang-multiple-I2S-inputs-simultaneously?p=79606#post79606" target="_blank">details</a> are also available.
  846. <p>The I2S signals are used in "master" mode, where Teensy creates
  847. all 3 clock signals and controls all data timing.</p>
  848. <table class=doc align=center cellpadding=3>
  849. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  850. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  851. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  852. <tr class=odd><td align=center>22</td><td>TX (ch 1+2)</td><td>Output</td></tr>
  853. <tr class=odd><td align=center>15</td><td>TX (ch 3+4)</td><td>Output</td></tr>
  854. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  855. </table>
  856. <p>Audio from
  857. master mode I2S may be used in the same project as ADC, DAC and
  858. PWM signals, because all remain in sync to Teensy's timing</p>
  859. <h3>Examples</h3>
  860. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughQuad
  861. </p>
  862. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; QuadChannelOutput
  863. </p>
  864. <h3>Notes</h3>
  865. <p>Normally, this object is used with two Audio Shields, which
  866. are controlled separately by a pair of "sgtl5000" objects.</p>
  867. </script>
  868. <script type="text/x-red" data-template-name="AudioOutputI2SQuad">
  869. <div class="form-row">
  870. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  871. <input type="text" id="node-input-name" placeholder="Name">
  872. </div>
  873. </script>
  874. <script type="text/x-red" data-help-name="AudioOutputSPDIF">
  875. <h3>Summary</h3>
  876. <div class=tooltipinfo>
  877. <p>Transmit 16 bit stereo audio as Digital S/PDIF.</p>
  878. <p align=center><img src="img/spdif_proto.jpg"></p>
  879. </div>
  880. <h3>Audio Connections</h3>
  881. <table class=doc align=center cellpadding=3>
  882. <tr class=top><th>Port</th><th>Purpose</th></tr>
  883. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  884. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  885. </table>
  886. <h3>Functions</h3>
  887. <p>This object has no functions to call from the Arduino sketch. It
  888. simply streams data from its 2 input ports S/PDIF encoded digital
  889. audio on pin 22.</p>
  890. <h3>Hardware</h3>
  891. <p>The S/PDIF output signal can be used to drive an optical TOSLINK
  892. cable, or a standard (usually orange) RCA jack.</p>
  893. <table class=doc align=center cellpadding=3>
  894. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  895. <tr class=odd><td align=center>22</td><td>S/PDIF</td><td>Output</td></tr>
  896. </table>
  897. <p>For optical TOSLINK output, this
  898. <a href="https://www.oshpark.com/shared_projects/KcDBKHta" target="_blank">OSH Park board</a>
  899. can be used with the inexpensive Everlight PLT133/T6A connector, available
  900. at Digikey, 1080-1434-ND.
  901. </p>
  902. <h3>Examples</h3>
  903. <p>The AudioOutputSPDIF object can be used in place of the AudioOutputI2S object,
  904. <p>used in nearly all the examples. The WavFilePlayer shows how to substitute
  905. output objects for different hardware types.
  906. </p>
  907. <p class=exam>File &gt; Examples &gt; Audio &gt; WavFilePlayer
  908. </p>
  909. <h3>Credits</h3>
  910. <p><a href="https://github.com/FrankBoesing" target="_blank">Frank Boesing</a>
  911. developed the AudioOutputSPDIF code. The original
  912. <a href="https://forum.pjrc.com/threads/28639-S-pdif" target="_blank">forum disussion</a>
  913. included valuable input and code from "kpc".
  914. <h3>Notes</h3>
  915. <p>S/PDIF output uses the I2S hardware. This object can not be used
  916. together with any of the I2S objects, because it requires the I2S
  917. hardware with different internal settings.</p>
  918. </p>
  919. </script>
  920. <script type="text/x-red" data-template-name="AudioOutputSPDIF">
  921. <div class="form-row">
  922. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  923. <input type="text" id="node-input-name" placeholder="Name">
  924. </div>
  925. </script>
  926. <script type="text/x-red" data-help-name="AudioOutputPT8211">
  927. <h3>Summary</h3>
  928. <div class=tooltipinfo>
  929. <p>Transmit 16 bit stereo audio to a low-cost PT8211 DAC chip. 4X oversampling
  930. and filtering are automatically used to improve output quality.</p>
  931. <p align=center><img src="img/pt8211.jpg"></p>
  932. </div>
  933. <h3>Audio Connections</h3>
  934. <table class=doc align=center cellpadding=3>
  935. <tr class=top><th>Port</th><th>Purpose</th></tr>
  936. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  937. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  938. </table>
  939. <h3>Functions</h3>
  940. <p>This object has no functions to call from the Arduino sketch. It
  941. simply streams data from its 2 input ports to a PT8211 chip. 4X
  942. oversampling and filtering is automatically used to improve quality.</p>
  943. <h3>Hardware</h3>
  944. <table class=doc align=center cellpadding=3>
  945. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  946. <tr class=odd><td align=center>9</td><td>BCK</td><td>Output</td></tr>
  947. <tr class=odd><td align=center>22</td><td>DIN</td><td>Output</td></tr>
  948. <tr class=odd><td align=center>23</td><td>FS</td><td>Output</td></tr>
  949. </table>
  950. <p>More information can be found in the PT8211 datasheet.
  951. </p>
  952. <h3>Examples</h3>
  953. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PT8211Sine
  954. </p>
  955. <h3>Credits</h3>
  956. <p>Frank Boesing and Benjamin developed this PT8211 object. Details can be
  957. found on this
  958. <a href="https://forum.pjrc.com/threads/29284-Dual-channel-16bit-dac-PT8211/page3" target="_blank">forum disussion</a>.
  959. <h3>Notes</h3>
  960. <p>
  961. </p>
  962. </script>
  963. <script type="text/x-red" data-template-name="AudioOutputPT8211">
  964. <div class="form-row">
  965. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  966. <input type="text" id="node-input-name" placeholder="Name">
  967. </div>
  968. </script>
  969. <script type="text/x-red" data-help-name="AudioOutputAnalog">
  970. <h3>Summary</h3>
  971. <div class=tooltipinfo>
  972. <p>Transmit 12 bit audio using Teensy's built-in digital to analog converter.</p>
  973. <p align=center><img src="img/dac_speaker.jpg"><br>
  974. <small><a href="http://www.pjrc.com/store/prop_shield.html" target="_blank_">Prop Shield with 4&ohm; Speaker</a></small></p>
  975. </div>
  976. <h3>Audio Connections</h3>
  977. <table class=doc align=center cellpadding=3>
  978. <tr class=top><th>Port</th><th>Purpose</th></tr>
  979. <tr class=odd><td align=center>In 0</td><td>Audio Channel</td></tr>
  980. </table>
  981. <h3>Functions</h3>
  982. <p class=func><span class=keyword>analogReference</span>(ref);</p>
  983. <p class=desc>Configure output voltage range:<br>
  984. <span class=literal>INTERNAL</span> selects 1.2 volt peak-to-peak output.<br>
  985. <span class=literal>EXTERNAL</span> selects 3.3 volt peak-to-peak output.
  986. </p>
  987. <h3>Hardware</h3>
  988. <p align=center><img src="img/dacpin.jpg"></p>
  989. <p>Signal range default is 0 to 1.2V</p>
  990. <p>The output voltage has DC level. Some applications require a DC-blocking capacitor. If unsure, a 10&micro;F is usually a safe value to use. If an aluminum or tantalum capacitor is used, the positive terminal should connect to Teensy's DAC pin.</p>
  991. <p>The DAC pin is used with the
  992. <a href="http://www.pjrc.com/store/prop_shield.html" target="_blank_">Prop Shield</a>
  993. to drive speakers.</p>
  994. <h3>Examples</h3>
  995. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  996. </p>
  997. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  998. </p>
  999. <p class=exam><a href="https://github.com/PaulStoffregen/TouchGuitar" target="_blank">TouchGuitar</a>
  1000. </p>
  1001. <p class=exam><a href="https://community.arm.com/groups/embedded/blog/2014/05/23/led-video-panel-at-maker-faire-2014" target="_blank">LED Video Board</a>
  1002. </p>
  1003. <p class=exam>File &gt; Examples &gt; OctoWS2811 &gt; VideoSDcard
  1004. </p>
  1005. <p class=exam>File &gt; Examples &gt; SerialFlash &gt; MP3Player
  1006. </p>
  1007. <h3>Notes</h3>
  1008. <p>The output rate is 44.1 kHz (no oversampling). Ultrasonic noise present if
  1009. not filtered. This may not
  1010. be an issue for many uses, but care should be used if amplified and driven
  1011. to high power tweeters.</p>
  1012. <p>When using 3.3V output, the power supply is used for the analog reference. Noise
  1013. present on the 3.3V power can couple to the DAC output signal.
  1014. </p>
  1015. </script>
  1016. <script type="text/x-red" data-template-name="AudioOutputAnalog">
  1017. <div class="form-row">
  1018. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1019. <input type="text" id="node-input-name" placeholder="Name">
  1020. </div>
  1021. </script>
  1022. <script type="text/x-red" data-help-name="AudioOutputAnalogStereo">
  1023. <h3>Summary</h3>
  1024. <div class=tooltipinfo>
  1025. <p>Transmit 12 bit stereo audio using Teensy 3.5 or 3.6 built-in digital to analog converters.</p>
  1026. <!--<p align=center><img src="img/dac_speaker.jpg"><br>
  1027. <small><a href="http://www.pjrc.com/store/prop_shield.html" target="_blank_">Prop Shield with 4&ohm; Speaker</a></small></p>-->
  1028. </div>
  1029. <h3>Audio Connections</h3>
  1030. <table class=doc align=center cellpadding=3>
  1031. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1032. <tr class=odd><td align=center>In 0</td><td>Audio Channel (Left)</td></tr>
  1033. <tr class=odd><td align=center>In 1</td><td>Audio Channel (Right)</td></tr>
  1034. </table>
  1035. <h3>Functions</h3>
  1036. <p class=func><span class=keyword>analogReference</span>(ref);</p>
  1037. <p class=desc>Configure output voltage range:<br>
  1038. <span class=literal>INTERNAL</span> selects 1.2 volt peak-to-peak output.<br>
  1039. <span class=literal>EXTERNAL</span> selects 3.3 volt peak-to-peak output.
  1040. </p>
  1041. <h3>Hardware</h3>
  1042. <p align=center><img src="img/dacpins.png"></p>
  1043. <p>Signal range default is 0 to 1.2V</p>
  1044. <p>The output voltage has DC level. Some applications require a DC-blocking capacitor. If unsure, a 10&micro;F is usually a safe value to use. If an aluminum or tantalum capacitor is used, the positive terminal should connect to Teensy's DAC pin.</p>
  1045. <p>The DAC pin is used with the
  1046. <a href="http://www.pjrc.com/store/prop_shield.html" target="_blank_">Prop Shield</a>
  1047. to drive speakers.</p>
  1048. <h3>Examples</h3>
  1049. <!--<p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  1050. </p>
  1051. <p class=exam>File &gt; Examples &gt; SerialFlash &gt; MP3Player
  1052. </p>-->
  1053. <h3>Notes</h3>
  1054. <p>The output rate is 44.1 kHz (no oversampling). Ultrasonic noise present if
  1055. not filtered. This may not
  1056. be an issue for many uses, but care should be used if amplified and driven
  1057. to high power tweeters.</p>
  1058. <p>When using 3.3V output, the power supply is used for the analog reference. Noise
  1059. present on the 3.3V power can couple to the DAC output signal.
  1060. </p>
  1061. </script>
  1062. <script type="text/x-red" data-template-name="AudioOutputAnalogStereo">
  1063. <div class="form-row">
  1064. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1065. <input type="text" id="node-input-name" placeholder="Name">
  1066. </div>
  1067. </script>
  1068. <script type="text/x-red" data-help-name="AudioOutputPWM">
  1069. <h3>Summary</h3>
  1070. <div class=tooltipinfo>
  1071. <p>Transmit audio using Teensy 3.1's PWM pins. Two pins are
  1072. used for coarse and fine pulses, to be combined by scaled
  1073. resistors.</p>
  1074. </div>
  1075. <h3>Audio Connections</h3>
  1076. <table class=doc align=center cellpadding=3>
  1077. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1078. <tr class=odd><td align=center>In 0</td><td>Audio Channel</td></tr>
  1079. </table>
  1080. <h3>Functions</h3>
  1081. <p>This object has no functions to call from the Arduino sketch. It
  1082. simply streams data from the its input port to the PWM pins.</p>
  1083. <h3>Hardware</h3>
  1084. <p>The following circuit is recommended.</p>
  1085. <p align=center><img src="img/pwmdualcircuit.jpg"></p>
  1086. <p>Signal range is approx 1.55 Vp-p.</p>
  1087. <p>These resistor values assume approx 20 ohms output impedance
  1088. on the digital pins. The 127K resistor may be adjusted or
  1089. trimmed for variation in output drive and tolerance on the
  1090. 475 ohm resistor.</p>
  1091. <p>A plastic film (Polypropylene, Polyethylene, Polyester, etc) or
  1092. C0G/NPO ceramic capacitor should be used for filtering. Low
  1093. quality ceramic (X7R, Y5V, Z5U, etc) can cause signal distortion.</p>
  1094. <h3>Examples</h3>
  1095. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughMono
  1096. </p>
  1097. <h3>Notes</h3>
  1098. <p>This object only works properly when Tools &gt; CPU_Speed is set to
  1099. 48 or 96 MHz. Other speeds aren't supported and will likely fail
  1100. in strange ways.</p>
  1101. <p>The PWM carrier frequency is 88.2 kHz. The suggested circuit
  1102. will only slightly filter the carrier. Extra filtering will be
  1103. required for a clean signal without the ultrasonic PWM carrier.
  1104. </p>
  1105. <p>Analog signals created by filtering PWM waveforms use the digital
  1106. power supply as their reference voltage. Any noise on the digital
  1107. power line can directly couple to the output signal. The built-in DAC or
  1108. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  1109. should be used when higher quality signals are needed.</p>
  1110. </script>
  1111. <script type="text/x-red" data-template-name="AudioOutputPWM">
  1112. <div class="form-row">
  1113. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1114. <input type="text" id="node-input-name" placeholder="Name">
  1115. </div>
  1116. </script>
  1117. <script type="text/x-red" data-help-name="AudioOutputI2Sslave">
  1118. <h3>Summary</h3>
  1119. <div class=tooltipinfo>
  1120. <p>Transmit 16 bit stereo audio to an I2S device using I2S slave mode
  1121. (where the DAC or codec chip, not Teensy, controls audio timing).</p>
  1122. </div>
  1123. <h3>Audio Connections</h3>
  1124. <table class=doc align=center cellpadding=3>
  1125. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1126. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  1127. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  1128. </table>
  1129. <h3>Functions</h3>
  1130. <p>This object has no functions to call from the Arduino sketch. It
  1131. simply streams data from its 2 input ports to the I2S hardware.</p>
  1132. <h3>Hardware</h3>
  1133. <p>The I2S signals are used in "slave" mode, where the I2S device controls
  1134. data timing.</p>
  1135. <table class=doc align=center cellpadding=3>
  1136. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  1137. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Input</td></tr>
  1138. <tr class=odd><td align=center>22</td><td>TX</td><td>Output</td></tr>
  1139. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Input</td></tr>
  1140. </table>
  1141. <h3>Examples</h3>
  1142. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WM8731MikroSine
  1143. </p>
  1144. <h3>Notes</h3>
  1145. <p>Slave mode I2S <b>should not used in the same project as ADC, DAC and
  1146. PWM</b> signals. Differences in timing between the I2S device and
  1147. Teensy's clock can cause occasional audio glitches when I2S slave mode
  1148. is used together with other input or output objects based on Teensy's
  1149. timing.</p>
  1150. <p>Only one I2S input and one I2S output object may be used. Master
  1151. and slave modes may not be mixed (both must be of the same type).
  1152. </p>
  1153. </script>
  1154. <script type="text/x-red" data-template-name="AudioOutputI2Sslave">
  1155. <div class="form-row">
  1156. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1157. <input type="text" id="node-input-name" placeholder="Name">
  1158. </div>
  1159. </script>
  1160. <script type="text/x-red" data-help-name="AudioOutputTDM">
  1161. <h3>Summary</h3>
  1162. <div class=tooltipinfo>
  1163. <p>Transmit a 256 bit Time Division Multiplexed frame containing
  1164. many audio channels.</p>
  1165. <p align=center><img src="img/tdm.jpg"></p>
  1166. </div>
  1167. <h3>Audio Connections</h3>
  1168. <table class=doc align=center cellpadding=3>
  1169. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1170. <tr class=odd><td align=center>In 0</td><td>Bits 0 to 15</td></tr>
  1171. <tr class=odd><td align=center>In 1</td><td>Bits 16 to 31</td></tr>
  1172. <tr class=odd><td align=center>In 2</td><td>Bits 32 to 47</td></tr>
  1173. <tr class=odd><td align=center>In 3</td><td>Bits 48 to 63</td></tr>
  1174. <tr class=odd><td align=center>In 4</td><td>Bits 64 to 79</td></tr>
  1175. <tr class=odd><td align=center>In 5</td><td>Bits 80 to 95</td></tr>
  1176. <tr class=odd><td align=center>In 6</td><td>Bits 96 to 111</td></tr>
  1177. <tr class=odd><td align=center>In 7</td><td>Bits 112 to 127</td></tr>
  1178. <tr class=odd><td align=center>In 8</td><td>Bits 128 to 143</td></tr>
  1179. <tr class=odd><td align=center>In 9</td><td>Bits 144 to 159</td></tr>
  1180. <tr class=odd><td align=center>In 10</td><td>Bits 160 to 175</td></tr>
  1181. <tr class=odd><td align=center>In 11</td><td>Bits 176 to 191</td></tr>
  1182. <tr class=odd><td align=center>In 12</td><td>Bits 192 to 207</td></tr>
  1183. <tr class=odd><td align=center>In 13</td><td>Bits 208 to 223</td></tr>
  1184. <tr class=odd><td align=center>In 14</td><td>Bits 224 to 239</td></tr>
  1185. <tr class=odd><td align=center>In 15</td><td>Bits 240 to 255</td></tr>
  1186. </table>
  1187. <h3>Functions</h3>
  1188. <p>This object has no functions to call from the Arduino sketch. It
  1189. simply streams data from its 16 input ports to the TDM hardware.</p>
  1190. <h3>Hardware</h3>
  1191. <p>TDM has been tested with this <a href="https://oshpark.com/shared_projects/2Yj6rFaW">
  1192. CS42448 Circuit Board</a>.
  1193. </p>
  1194. <table class=doc align=center cellpadding=3>
  1195. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  1196. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output, 11.3 MHz</td></tr>
  1197. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output, 22.6 MHz</td></tr>
  1198. <tr class=odd><td align=center>22</td><td>TX</td><td>Input, 11.3 Mbit/sec</td></tr>
  1199. <tr class=odd><td align=center>23</td><td>WS</td><td>Output</td></tr>
  1200. </table>
  1201. <p>Audio from
  1202. master mode TDM may be used in the same project as ADC, DAC and
  1203. PWM signals, because all remain in sync to Teensy's timing</p>
  1204. <!--<h3>Examples</h3>-->
  1205. <h3>Notes</h3>
  1206. <p>Only one TDM input and one TDM output object may be used. The
  1207. I2S hardware is used by TDM, so TDM objects may not be used
  1208. together with I2S, SPDIF or PT8211.</p>
  1209. <p>When used with TDM devices which receive 32 bit audio, the
  1210. even numbered channels are used for the top 16 bits.</p>
  1211. </script>
  1212. <script type="text/x-red" data-template-name="AudioOutputTDM">
  1213. <div class="form-row">
  1214. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1215. <input type="text" id="node-input-name" placeholder="Name">
  1216. </div>
  1217. </script>
  1218. <script type="text/x-red" data-help-name="AudioOutputUSB">
  1219. <h3>Summary</h3>
  1220. <div class=tooltipinfo>
  1221. <p>Send stereo audio to a PC or Mac. Teensy appears as a USB
  1222. sound device.</p>
  1223. <p align=center><img src="img/usbtype_audio_out.png"></p>
  1224. </div>
  1225. <h3>Audio Connections</h3>
  1226. <table class=doc align=center cellpadding=3>
  1227. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1228. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  1229. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  1230. </table>
  1231. <h3>Functions</h3>
  1232. <p>This object has no functions to call from the Arduino sketch. It
  1233. simply streams from it's 2 input ports to the USB.</p>
  1234. <!--
  1235. <h3>Hardware</h3>
  1236. -->
  1237. <h3>Examples</h3>
  1238. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WavFilePlayerUSB</p>
  1239. </p>
  1240. <h3>Notes</h3>
  1241. <p>Arduino's <b>Tools &gt; USB Type</b> menu must be set to <b>Audio</b>.
  1242. </p>
  1243. <p align=center><img src="img/usbtype_audio.png"></p>
  1244. <p>USB input &amp; output does not cause the Teensy Audio Library to
  1245. update. At least one non-USB input or output object must be
  1246. present for the entire library to update properly.</p>
  1247. <p>A known problem exists with USB audio from Macintosh computers.
  1248. An imperfect <a href="https://forum.pjrc.com/threads/34855-Distorted-audio-when-using-USB-input-on-Teensy-3-1?p=110392&viewfull=1#post110392">workaround
  1249. can be enabled by editing usb_audio.cpp</a>.
  1250. Find and uncomment "#define MACOSX_ADAPTIVE_LIMIT".</p>
  1251. </script>
  1252. <script type="text/x-red" data-template-name="AudioOutputUSB">
  1253. <div class="form-row">
  1254. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1255. <input type="text" id="node-input-name" placeholder="Name">
  1256. </div>
  1257. </script>
  1258. <script type="text/x-red" data-help-name="AudioMixer4">
  1259. <h3>Summary</h3>
  1260. <div class=tooltipinfo>
  1261. <p>Combine up to 4 audio signals together, each with adjustable gain.
  1262. All channels support signal attenuation or amplification.</p>
  1263. </div>
  1264. <h3>Audio Connections</h3>
  1265. <table class=doc align=center cellpadding=3>
  1266. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1267. <tr class=odd><td align=center>In 0</td><td>Input signal #1</td></tr>
  1268. <tr class=odd><td align=center>In 1</td><td>Input signal #2</td></tr>
  1269. <tr class=odd><td align=center>In 2</td><td>Input signal #3</td></tr>
  1270. <tr class=odd><td align=center>In 3</td><td>Input signal #4</td></tr>
  1271. <tr class=odd><td align=center>Out 0</td><td>Sum of all inputs</td></tr>
  1272. </table>
  1273. <h3>Functions</h3>
  1274. <p class=func><span class=keyword>gain</span>(channel, level);</p>
  1275. <p class=desc>Adjust the amplification or attenuation. "channel" must
  1276. be 0 to 3. "level" may be any floating point number from 0 to 32767.0.
  1277. 1.0 passes the signal through directly. Level of 0 shuts the channel
  1278. off completely. Between 0 to 1.0 attenuates the signal, and above
  1279. 1.0 amplifies it. Negative numbers may also be used, to invert the
  1280. signal. All 4 channels have separate gain settings.
  1281. </p>
  1282. <h3>Examples</h3>
  1283. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  1284. </p>
  1285. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  1286. </p>
  1287. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; SpectrumAnalyzerBasic
  1288. </p>
  1289. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_Serial
  1290. </p>
  1291. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  1292. </p>
  1293. <h3>Notes</h3>
  1294. <p>Signal clipping can occur when any channel has gain greater than 1.0,
  1295. or when multiple signals add together to greater than 1.0.</p>
  1296. <p>More than 4 channels may be combined by connecting multiple mixers
  1297. in tandem. For example, a 16 channel mixer may be built using 5
  1298. mixers, where the fifth mixer combines the outputs of the first 4.
  1299. </p>
  1300. </script>
  1301. <script type="text/x-red" data-template-name="AudioMixer4">
  1302. <div class="form-row">
  1303. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1304. <input type="text" id="node-input-name" placeholder="Name">
  1305. </div>
  1306. </script>
  1307. <script type="text/x-red" data-help-name="AudioPlayMemory">
  1308. <h3>Summary</h3>
  1309. <div class=tooltipinfo>
  1310. <p>Play a short sound clip, stored directly in memory.
  1311. Data files are created with the
  1312. <a href="https://github.com/PaulStoffregen/Audio/tree/master/extras/wav2sketch" target="_blank">wav2sketch program</a>,
  1313. and copied to the sketch folder to become part of your sketch.</p>
  1314. </div>
  1315. <h3>Audio Connections</h3>
  1316. <table class=doc align=center cellpadding=3>
  1317. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1318. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1319. </table>
  1320. <h3>Functions</h3>
  1321. <p class=func><span class=keyword>play</span>(data);</p>
  1322. <p class=desc>Begin playing a sound clip. If already playing, the
  1323. currently playing clip is stopped and this new data begins
  1324. playing from the beginning.
  1325. </p>
  1326. <p class=func><span class=keyword>stop</span>();</p>
  1327. <p class=desc>Stop playing. If not playing, this function has no effect.
  1328. </p>
  1329. <p class=func><span class=keyword>isPlaying</span>();</p>
  1330. <p class=desc>Return true (non-zero) if playing, or false (zero)
  1331. when not playing.
  1332. </p>
  1333. <p class=func><span class=keyword>positionMillis</span>();</p>
  1334. <p class=desc>While playing, return the current time offset, in
  1335. milliseconds. When not playing, the return from this function
  1336. is undefined.
  1337. </p>
  1338. <p class=func><span class=keyword>lengthMillis</span>();</p>
  1339. <p class=desc>Return the total length of the current sound clip,
  1340. in milliseconds. When not playing, the return from this function
  1341. is undefined.
  1342. </p>
  1343. <h3>Examples</h3>
  1344. <p class=exam>File &gt; Examples &gt; Audio &gt; SamplePlayer
  1345. </p>
  1346. <h3>Notes</h3>
  1347. <p><a href="https://forum.pjrc.com/threads/42401-Instructions-or-tutorials-for-using-wav2sketch?p=135069&viewfull=1#post135069">Step by step instructions for wav2sketch</a>
  1348. running in Terminal on Macintosh.</p>
  1349. <p>TODO: supported sample rates: 11.025, 22.05, 44.1</p>
  1350. <p>TODO: ulaw vs uncompressed encoding</p>
  1351. <p>Polyphonic playback can be built by creating multiple
  1352. objects, with their output combined by mixers.</p>
  1353. </script>
  1354. <script type="text/x-red" data-template-name="AudioPlayMemory">
  1355. <div class="form-row">
  1356. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1357. <input type="text" id="node-input-name" placeholder="Name">
  1358. </div>
  1359. </script>
  1360. <script type="text/x-red" data-help-name="AudioPlaySdWav">
  1361. <h3>Summary</h3>
  1362. <div class=tooltipinfo>
  1363. <p>Play a WAV file, stored on a SD card.</p>
  1364. </div>
  1365. <h3>Audio Connections</h3>
  1366. <table class=doc align=center cellpadding=3>
  1367. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1368. <tr class=odd><td align=center>Out 0</td><td>Left Channel Output</td></tr>
  1369. <tr class=odd><td align=center>Out 1</td><td>Right Channel Output</td></tr>
  1370. </table>
  1371. <h3>Functions</h3>
  1372. <p class=func><span class=keyword>play</span>(filename);</p>
  1373. <p class=desc>Begin playing a WAV file. If a file is already playing,
  1374. it is stopped and this file starts playing from the beginning.
  1375. </p>
  1376. <p class=func><span class=keyword>stop</span>();</p>
  1377. <p class=desc>Stop playing. If not playing, this function has no effect.
  1378. </p>
  1379. <p class=func><span class=keyword>isPlaying</span>();</p>
  1380. <p class=desc>Return true (non-zero) if playing, or false (zero)
  1381. when not playing. See the note below about delayed start.
  1382. </p>
  1383. <p class=func><span class=keyword>positionMillis</span>();</p>
  1384. <p class=desc>While playing, return the current time offset, in
  1385. milliseconds. When not playing, the return from this function
  1386. is undefined.
  1387. </p>
  1388. <p class=func><span class=keyword>lengthMillis</span>();</p>
  1389. <p class=desc>Return the total length of the current sound clip,
  1390. in milliseconds. When not playing, the return from this function
  1391. is undefined.
  1392. </p>
  1393. <h3>Examples</h3>
  1394. <p class=exam>File &gt; Examples &gt; Audio &gt; WavFilePlayer
  1395. </p>
  1396. <h3>Notes</h3>
  1397. <p>Only 16 bit PCM, 44100 Hz WAV files are supported. When mono
  1398. files are played, both output ports transmit a copy of the
  1399. single sound. Of course, stereo WAV files play with the left
  1400. channel on port 0 and the right channel on port 1.
  1401. </p>
  1402. <p>A brief delay after calling play() will usually occur before
  1403. isPlaying() returns true and positionMillis() returns valid
  1404. time offset. WAV files have a header at the beginning of the
  1405. file, which the audio library must read and parse before
  1406. playing can begin.
  1407. </p>
  1408. <p>While playing, the audio library accesses the SD card automatically.
  1409. If card access is required, you must
  1410. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">use AudioNoInterrupts()</a>
  1411. to prevent the library from accessing the SD card while you use it.
  1412. Disabling the audio library interrupt for too long may cause audible
  1413. dropouts or glitches.
  1414. </p>
  1415. <p>An experimental SD library optimization exists, which can remove these
  1416. SD library restrictions. It also allows reliable playback of more
  1417. files at the same time. To enable this special code, find and edit
  1418. the SD_t3.h file within your Arduino folder. See the comments within
  1419. that file for details.
  1420. </p>
  1421. </script>
  1422. <script type="text/x-red" data-template-name="AudioPlaySdWav">
  1423. <div class="form-row">
  1424. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1425. <input type="text" id="node-input-name" placeholder="Name">
  1426. </div>
  1427. </script>
  1428. <script type="text/x-red" data-help-name="AudioPlaySdRaw">
  1429. <h3>Summary</h3>
  1430. <div class=tooltipinfo>
  1431. <p>Play a RAW data file, stored on a SD card. RAW format is simpler
  1432. than WAV and begins playing immediately, without parsing WAV file
  1433. header info.</p>
  1434. </div>
  1435. <h3>Audio Connections</h3>
  1436. <table class=doc align=center cellpadding=3>
  1437. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1438. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1439. </table>
  1440. <h3>Functions</h3>
  1441. <p class=func><span class=keyword>play</span>(filename);</p>
  1442. <p class=desc>Begin playing a RAW data file. If a file is already playing,
  1443. it is stopped and this file starts playing from the beginning.
  1444. </p>
  1445. <p class=func><span class=keyword>stop</span>();</p>
  1446. <p class=desc>Stop playing. If not playing, this function has no effect.
  1447. </p>
  1448. <p class=func><span class=keyword>isPlaying</span>();</p>
  1449. <p class=desc>Return true (non-zero) if playing, or false (zero)
  1450. when not playing.
  1451. </p>
  1452. <p class=func><span class=keyword>positionMillis</span>();</p>
  1453. <p class=desc>While playing, return the current time offset, in
  1454. milliseconds. When not playing, the return from this function
  1455. is undefined.
  1456. </p>
  1457. <p class=func><span class=keyword>lengthMillis</span>();</p>
  1458. <p class=desc>Return the total length of the current sound clip,
  1459. in milliseconds. When not playing, the return from this function
  1460. is undefined.
  1461. </p>
  1462. <h3>Examples</h3>
  1463. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  1464. </p>
  1465. <h3>Notes</h3>
  1466. <p>The data file must be RAW 16 bit signed integers in LSB-first format.
  1467. </p>
  1468. <p>While playing, the audio library accesses the SD card automatically.
  1469. If card access is required, you must
  1470. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1471. to prevent the library from accessing the SD card while you use it.
  1472. Disabling the audio library interrupt for too long may cause audible
  1473. dropouts or glitches.
  1474. </p>
  1475. </script>
  1476. <script type="text/x-red" data-template-name="AudioPlaySdRaw">
  1477. <div class="form-row">
  1478. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1479. <input type="text" id="node-input-name" placeholder="Name">
  1480. </div>
  1481. </script>
  1482. <script type="text/x-red" data-help-name="AudioPlaySerialflashRaw">
  1483. <h3>Summary</h3>
  1484. <div class=tooltipinfo>
  1485. <p>Play a RAW data file, stored on a Serial Flash chip. These chips
  1486. are far more efficient than SD cards, allowing many files to be
  1487. played simultaneously by copies of this object.
  1488. </p>
  1489. <p align=center><img src="img/w25q128fv.jpg"><br><small>W25Q128FV Serial Flash</small></p>
  1490. </div>
  1491. <h3>Audio Connections</h3>
  1492. <table class=doc align=center cellpadding=3>
  1493. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1494. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1495. </table>
  1496. <h3>Functions</h3>
  1497. <p class=func><span class=keyword>play</span>(filename);</p>
  1498. <p class=desc>Begin playing a RAW data file. If a file is already playing,
  1499. it is stopped and this file starts playing from the beginning.
  1500. </p>
  1501. <p class=func><span class=keyword>stop</span>();</p>
  1502. <p class=desc>Stop playing. If not playing, this function has no effect.
  1503. </p>
  1504. <p class=func><span class=keyword>isPlaying</span>();</p>
  1505. <p class=desc>Return true (non-zero) if playing, or false (zero)
  1506. when not playing.
  1507. </p>
  1508. <p class=func><span class=keyword>positionMillis</span>();</p>
  1509. <p class=desc>While playing, return the current time offset, in
  1510. milliseconds. When not playing, the return from this function
  1511. is undefined.
  1512. </p>
  1513. <p class=func><span class=keyword>lengthMillis</span>();</p>
  1514. <p class=desc>Return the total length of the current sound clip,
  1515. in milliseconds. When not playing, the return from this function
  1516. is undefined.
  1517. </p>
  1518. <h3>Examples</h3>
  1519. <!--
  1520. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  1521. -->
  1522. <p class=exam>TODO: play example needed....
  1523. </p>
  1524. <p class=exam>File &gt; Examples &gt; SerialFlash &gt; CopyFromSD
  1525. </p>
  1526. <h3>Notes</h3>
  1527. <p>The data file must be RAW 16 bit signed integers in LSB-first format.
  1528. </p>
  1529. <p>The <a href="https://github.com/PaulStoffregen/SerialFlash" target="_blank">SerialFlash library</a>
  1530. is used to access the flash chip. You can also use SerialFlash's functions
  1531. to access the stored files, or add data to the flash chip.
  1532. </p>
  1533. <p>File names are case sensitive with SerialFlash. If your sound does
  1534. not play, use <b>File &gt; Examples &gt; SerialFlash &gt; ListFiles</b> to
  1535. check the exact file names stored in the flash memory chip.
  1536. </script>
  1537. <script type="text/x-red" data-template-name="AudioPlaySerialflashRaw">
  1538. <div class="form-row">
  1539. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1540. <input type="text" id="node-input-name" placeholder="Name">
  1541. </div>
  1542. </script>
  1543. <script type="text/x-red" data-help-name="AudioPlayQueue">
  1544. <h3>Summary</h3>
  1545. <div class=tooltipinfo>
  1546. <p>Play audio data provided by the Arduino sketch. This object provides
  1547. functions to allow the sketch code to push data into the audio system.</p>
  1548. </div>
  1549. <h3>Audio Connections</h3>
  1550. <table class=doc align=center cellpadding=3>
  1551. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1552. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1553. </table>
  1554. <h3>Functions</h3>
  1555. <p class=func><span class=keyword>play</span>(int16);</p>
  1556. <p class=desc>not yet implemented
  1557. </p>
  1558. <p class=func><span class=keyword>play</span>(int16[], length);</p>
  1559. <p class=desc>not yet implemented
  1560. </p>
  1561. <p class=func><span class=keyword>getBuffer</span>();</p>
  1562. <p class=desc>Returns a pointer to an array of 128 int16. This buffer
  1563. is within the audio library memory pool, providing the most efficient
  1564. way to input data to the audio system. The buffer is likely to be
  1565. populated by previously used data, so the entire 128 words should be
  1566. written before calling playBuffer(). Only a single buffer should be
  1567. requested at a time. This function may return NULL if no memory is
  1568. available.
  1569. </p>
  1570. <p class=func><span class=keyword>playBuffer</span>();</p>
  1571. <p class=desc>Transmit the buffer previously obtained from getBuffer().
  1572. </p>
  1573. <h3>Examples</h3>
  1574. <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>
  1575. </p>
  1576. <!--
  1577. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1578. </p>
  1579. -->
  1580. <h3>Notes</h3>
  1581. <p>TODO: many caveats....</p>
  1582. <p>
  1583. </p>
  1584. </script>
  1585. <script type="text/x-red" data-template-name="AudioPlayQueue">
  1586. <div class="form-row">
  1587. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1588. <input type="text" id="node-input-name" placeholder="Name">
  1589. </div>
  1590. </script>
  1591. <script type="text/x-red" data-help-name="AudioRecordQueue">
  1592. <h3>Summary</h3>
  1593. <div class=tooltipinfo>
  1594. <p>Record audio data by sending to the Arduino sketch. This object allows
  1595. sketch code to receive audio packets.</p>
  1596. </div>
  1597. <h3>Audio Connections</h3>
  1598. <table class=doc align=center cellpadding=3>
  1599. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1600. <tr class=odd><td align=center>In 0</td><td>Sound To Access</td></tr>
  1601. </table>
  1602. <h3>Functions</h3>
  1603. <p class=func><span class=keyword>begin</span>();</p>
  1604. <p class=desc>Begin capturing incoming audio to the queue. After calling
  1605. begin, readBuffer() and freeBuffer(), or clear() must be used frequently
  1606. to prevent the queue from filling up.
  1607. </p>
  1608. <p class=func><span class=keyword>available</span>();</p>
  1609. <p class=desc>Returns the number of audio packets available to read.
  1610. </p>
  1611. <p class=func><span class=keyword>readBuffer</span>();</p>
  1612. <p class=desc>Read a single audio packet. A pointer to a 128 sample
  1613. array of 16 bit integers is returned. NULL is returned if no packets
  1614. are available.
  1615. </p>
  1616. <p class=func><span class=keyword>freeBuffer</span>();</p>
  1617. <p class=desc>Release the memory from the previously read packet returned
  1618. from readBuffer(). Only a single packet at a time may be read, and
  1619. each packet must be freed with this function, to return the memory to
  1620. the audio library.
  1621. </p>
  1622. <p class=func><span class=keyword>clear</span>();</p>
  1623. <p class=desc>Discard all audio held in the queue.
  1624. </p>
  1625. <p class=func><span class=keyword>end</span>();</p>
  1626. <p class=desc>Stop capturing incoming audio into the queue. Data already
  1627. captured remains in the queue and may be read with readBuffer().
  1628. </p>
  1629. <h3>Examples</h3>
  1630. <p class=exam>File &gt; Examples &gt; Audio &gt; Recorder
  1631. </p>
  1632. <h3>Notes</h3>
  1633. <p>
  1634. Up to 52 packets may be queued by this object, which allows approximately
  1635. 150 ms of audio to be held in the queue, to allow time for the Arduino
  1636. sketch to write data to media or do other high-latency tasks.
  1637. The actual packets are taken
  1638. from the pool created by AudioMemory().
  1639. </p>
  1640. </script>
  1641. <script type="text/x-red" data-template-name="AudioRecordQueue">
  1642. <div class="form-row">
  1643. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1644. <input type="text" id="node-input-name" placeholder="Name">
  1645. </div>
  1646. </script>
  1647. <script type="text/x-red" data-help-name="AudioSynthSimpleDrum">
  1648. <h3>Summary</h3>
  1649. <div class=tooltipinfo>
  1650. <p>Generate a synthesised drum sound. Also useful for laser pistol and bursting
  1651. bubble sound effects.</p>
  1652. </div>
  1653. <h3>Audio Connections</h3>
  1654. <table class=doc align=center cellpadding=3>
  1655. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1656. <tr class=odd><td align=center>Out 0</td><td>Drum Tone Output</td></tr>
  1657. </table>
  1658. <h3>Functions</h3>
  1659. <p class=func><span class=keyword>noteOn</span>();</p>
  1660. <p class=desc>Trigger the drum.
  1661. </p>
  1662. <p class=func><span class=keyword>frequency</span>(frequency);</p>
  1663. <p class=desc>Set the base frequency of the drum.
  1664. </p>
  1665. <p class=func><span class=keyword>length</span>(milliseconds);</p>
  1666. <p class=desc>Set the duration of the envelope, in milliseconds.
  1667. </p>
  1668. <p class=func><span class=keyword>secondMix</span>(level);</p>
  1669. <p class=desc>Emulates a two-headed tom, by adding a second sine wave that is
  1670. harmonized a perfect fifth above
  1671. the base frequency. Using this involves a slight CPU penalty.
  1672. </p>
  1673. <p class=func><span class=keyword>pitchMod</span>(depth);</p>
  1674. <p class=desc>Set the depth of envelope of the pitch, by a maximum of two octaves.
  1675. Default is 0.5, with no modulation. Values above 0.5 cause the pitch to sweep
  1676. downwards, values lower than 0.5 cause the pitch to sweep upwards.
  1677. </p>
  1678. <h3>Examples</h3>
  1679. <p class=exam>File &gt; Examples &gt; Synthesis &gt; SimpleDrum
  1680. </p>
  1681. <h3>Notes</h3>
  1682. <p></p>
  1683. </script>
  1684. <script type="text/x-red" data-template-name="AudioSynthSimpleDrum">
  1685. <div class="form-row">
  1686. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1687. <input type="text" id="node-input-name" placeholder="Name">
  1688. </div>
  1689. </script>
  1690. <script type="text/x-red" data-help-name="AudioSynthKarplusStrong">
  1691. <h3>Summary</h3>
  1692. <div class=tooltipinfo>
  1693. <p>Synthesize a plucked string sound, such as a guitar string.
  1694. </p>
  1695. <p align=center><img src="img/touchguitar.jpg"></p>
  1696. </div>
  1697. <h3>Audio Connections</h3>
  1698. <table class=doc align=center cellpadding=3>
  1699. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1700. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  1701. </table>
  1702. <h3>Functions</h3>
  1703. <p class=func><span class=keyword>noteOn</span>(frequency, velocity);</p>
  1704. <p class=desc>Begin a new string note. Velocity can be from 0 to 1.0,
  1705. indicating how hard the string is plucked.
  1706. </p>
  1707. <p class=func><span class=keyword>noteOff</span>(velocity);</p>
  1708. <p class=desc>Stop the sound output.
  1709. </p>
  1710. <h3>Examples</h3>
  1711. <p class=exam>File &gt; Examples &gt; Synthesis &gt; Guitar
  1712. </p>
  1713. <p class=exam><a href="https://github.com/PaulStoffregen/TouchGuitar" target="_blank">TouchGuitar</a>
  1714. </p>
  1715. <h3>Notes</h3>
  1716. <p></p>
  1717. </script>
  1718. <script type="text/x-red" data-template-name="AudioSynthSimpleDrum">
  1719. <div class="form-row">
  1720. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1721. <input type="text" id="node-input-name" placeholder="Name">
  1722. </div>
  1723. </script>
  1724. <script type="text/x-red" data-help-name="AudioSynthWaveformSine">
  1725. <h3>Summary</h3>
  1726. <div class=tooltipinfo>
  1727. <p>Create a sine wave signal</p>
  1728. </div>
  1729. <h3>Audio Connections</h3>
  1730. <table class=doc align=center cellpadding=3>
  1731. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1732. <tr class=odd><td align=center>Out 0</td><td>Sine Wave Output</td></tr>
  1733. </table>
  1734. <h3>Functions</h3>
  1735. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1736. <p class=desc>Set the amplitude, from 0 to 1.0.
  1737. </p>
  1738. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1739. <p class=desc>Set the frequency, from 0 to 22000. Very low values may
  1740. be used to create a LFO (Low Frequency Oscillator) for objects
  1741. with modulation signal inputs.
  1742. </p>
  1743. <p class=func><span class=keyword>phase</span>(angle);</p>
  1744. <p class=desc>
  1745. Cause the generated waveform to jump to a specific point within
  1746. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1747. are configured,
  1748. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1749. should be used to guarantee all new settings take effect together.
  1750. </p>
  1751. <h3>Examples</h3>
  1752. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  1753. </p>
  1754. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_Serial
  1755. </p>
  1756. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; FFT
  1757. </p>
  1758. <h3>Notes</h3>
  1759. <p></p>
  1760. </script>
  1761. <script type="text/x-red" data-template-name="AudioSynthWaveformSine">
  1762. <div class="form-row">
  1763. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1764. <input type="text" id="node-input-name" placeholder="Name">
  1765. </div>
  1766. </script>
  1767. <script type="text/x-red" data-help-name="AudioSynthWaveformSineHires">
  1768. <h3>Summary</h3>
  1769. <div class=tooltipinfo>
  1770. <p>Create a highly precise, low distortion sine wave signal.
  1771. Mainly useful for codec &amp; analog circuitry testing.</p>
  1772. </div>
  1773. <h3>Audio Connections</h3>
  1774. <table class=doc align=center cellpadding=3>
  1775. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1776. <tr class=odd><td align=center>Out 0</td><td>Sine Wave, upper bits</td></tr>
  1777. <tr class=odd><td align=center>Out 1</td><td>Sine Wave, lower bits</td></tr>
  1778. </table>
  1779. <h3>Functions</h3>
  1780. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1781. <p class=desc>Set the amplitude, from 0 to 1.0.
  1782. </p>
  1783. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1784. <p class=desc>Set the frequency, from 0 to 22000. Very low values may
  1785. be used to create a LFO (Low Frequency Oscillator) for objects
  1786. with modulation signal inputs.
  1787. </p>
  1788. <p class=func><span class=keyword>phase</span>(angle);</p>
  1789. <p class=desc>
  1790. Cause the generated waveform to jump to a specific point within
  1791. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1792. are configured,
  1793. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1794. should be used to guarantee all new settings take effect together.
  1795. </p>
  1796. <h3>Notes</h3>
  1797. <p>An 11th order Taylor series approximation is used to generate
  1798. a very accurate sine wave. At least the upper 25 bits are believe
  1799. to be perfect. This is mainly intended for testing 24 bit codec chips!</p>
  1800. </script>
  1801. <script type="text/x-red" data-template-name="AudioSynthWaveformSine">
  1802. <div class="form-row">
  1803. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1804. <input type="text" id="node-input-name" placeholder="Name">
  1805. </div>
  1806. </script>
  1807. <script type="text/x-red" data-help-name="AudioSynthWaveformSineModulated">
  1808. <h3>Summary</h3>
  1809. <div class=tooltipinfo>
  1810. <p>Create a modulated sine wave, using any audio signal to continuously
  1811. modulate the sine wave frequency.</p>
  1812. </div>
  1813. <h3>Audio Connections</h3>
  1814. <table class=doc align=center cellpadding=3>
  1815. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1816. <tr class=odd><td align=center>In 0</td><td>Modulation Signal</td></tr>
  1817. <tr class=odd><td align=center>Out 0</td><td>Sine Wave Output</td></tr>
  1818. </table>
  1819. <h3>Functions</h3>
  1820. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1821. <p class=desc>Set the amplitude, from 0 to 1.0.
  1822. </p>
  1823. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1824. <p class=desc>Set the center frequency, from 0 to 11000. The output will
  1825. be this center frequency when the input modulation signal is zero.
  1826. Modulation input 1.0 causes the frequency to double, and input -1.0
  1827. causes zero Hz (DC) output. For less modulation, attenuate the input
  1828. signal (perhaps with a mixer object) before it arrives here.
  1829. </p>
  1830. <p class=func><span class=keyword>phase</span>(angle);</p>
  1831. <p class=desc>
  1832. Cause the generated waveform to jump to a specific point within
  1833. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1834. are configured,
  1835. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1836. should be used to guarantee all new settings take effect together.
  1837. </p>
  1838. <!--
  1839. <h3>Examples</h3>
  1840. <p class=exam>File &gt; Examples &gt; Audio &gt;
  1841. </p>
  1842. -->
  1843. <h3>Notes</h3>
  1844. <p></p>
  1845. </script>
  1846. <script type="text/x-red" data-template-name="AudioSynthWaveformSineModulated">
  1847. <div class="form-row">
  1848. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1849. <input type="text" id="node-input-name" placeholder="Name">
  1850. </div>
  1851. </script>
  1852. <script type="text/x-red" data-help-name="AudioSynthWaveform">
  1853. <h3>Summary</h3>
  1854. <div class=tooltipinfo>
  1855. <p>Create a waveform: sine, sawtooth, square, triangle, pulse or arbitrary.</p>
  1856. </div>
  1857. <h3>Audio Connections</h3>
  1858. <table class=doc align=center cellpadding=3>
  1859. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1860. <tr class=odd><td align=center>Out 0</td><td>Waveform Output</td></tr>
  1861. </table>
  1862. <h3>Functions</h3>
  1863. <p class=func><span class=keyword>begin</span>(waveform);</p>
  1864. <p class=desc>Configure the waveform type to create.
  1865. </p>
  1866. <p class=func><span class=keyword>begin</span>(level, frequency, waveform);</p>
  1867. <p class=desc>Output a waveform, and set the amplitude and frequency.
  1868. </p>
  1869. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1870. <p class=desc>Change the frequency.
  1871. </p>
  1872. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1873. <p class=desc>Change the amplitude. Set to 0 to turn the signal off.
  1874. </p>
  1875. <p class=func><span class=keyword>phase</span>(angle);</p>
  1876. <p class=desc>
  1877. Cause the generated waveform to jump to a specific point within
  1878. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  1879. are configured,
  1880. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  1881. should be used to guarantee all new settings take effect together.
  1882. </p>
  1883. <p class=func><span class=keyword>pulseWidth</span>(amount);</p>
  1884. <p class=desc>Change the width (duty cycle) of the pulse.</p>
  1885. <p class=func><span class=keyword>arbitraryWaveform</span>(array, maxFreq);</p>
  1886. <p class=desc>
  1887. Configure the waveform to be used with WAVEFORM_ARBITRARY. Array
  1888. must be an array of 256 samples. Currently, the data is used
  1889. without any filtering, which can cause aliasing with frequencies
  1890. above 172 Hz. For higher frequency output, you must bandwidth
  1891. limit your waveform data. Someday, "maxFreq" will be used to
  1892. do this automatically.
  1893. </p>
  1894. <h3>Examples</h3>
  1895. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  1896. </p>
  1897. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; pulseWidth
  1898. </p>
  1899. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WM8731MikroSine
  1900. </p>
  1901. <h3>Notes</h3>
  1902. <p>Supported Waveforms:<br>
  1903. <ul>
  1904. <li><span class=literal>WAVEFORM_SINE</span></li>
  1905. <li><span class=literal>WAVEFORM_SAWTOOTH</span></li>
  1906. <li><span class=literal>WAVEFORM_SAWTOOTH_REVERSE</span></li>
  1907. <li><span class=literal>WAVEFORM_SQUARE</span></li>
  1908. <li><span class=literal>WAVEFORM_TRIANGLE</span></li>
  1909. <li><span class=literal>WAVEFORM_ARBITRARY</span></li>
  1910. <li><span class=literal>WAVEFORM_PULSE</span></li>
  1911. <li><span class=literal>WAVEFORM_SAMPLE_HOLD</span></li>
  1912. </ul>
  1913. </p>
  1914. </script>
  1915. <script type="text/x-red" data-template-name="AudioSynthWaveform">
  1916. <div class="form-row">
  1917. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1918. <input type="text" id="node-input-name" placeholder="Name">
  1919. </div>
  1920. </script>
  1921. <script type="text/x-red" data-help-name="AudioSynthWaveformPWM">
  1922. <h3>Summary</h3>
  1923. <div class=tooltipinfo>
  1924. <p>Create a Pulse Width Modulated waveform, with an audio signal
  1925. controlling the pulse width duty cycle.</p>
  1926. <p align=center><img src="img/pwm.png"></p>
  1927. </div>
  1928. <h3>Audio Connections</h3>
  1929. <table class=doc align=center cellpadding=3>
  1930. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1931. <tr class=odd><td align=center>In 0</td><td>Control Signal Output</td></tr>
  1932. <tr class=odd><td align=center>Out 0</td><td>Waveform Output</td></tr>
  1933. </table>
  1934. <p>The duty cycle is 50% when the control waveform is zero.
  1935. As the control input causes a linear changes in PWM duty
  1936. cycle, from nearly 0 to 100% over -1.0 to +1.0 range.
  1937. See the notes below for minimum and maximum limitations.
  1938. </p>
  1939. <h3>Functions</h3>
  1940. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1941. <p class=desc>Change the frequency.
  1942. </p>
  1943. <p class=func><span class=keyword>amplitude</span>(level);</p>
  1944. <p class=desc>Change the amplitude. Set to 0 to turn the signal off.
  1945. </p>
  1946. <h3>Examples</h3>
  1947. <p class=exam>TODO, examples needed
  1948. </p>
  1949. <h3>Notes</h3>
  1950. <p>The maximum duty cycle is 65536 samples high followed by
  1951. one sample low (99.9985%) and the minimum duty cycle is
  1952. 1 sample high followed by 65536 samples low (0.00153%).
  1953. </p>
  1954. </script>
  1955. <script type="text/x-red" data-template-name="AudioSynthWaveformPWM">
  1956. <div class="form-row">
  1957. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1958. <input type="text" id="node-input-name" placeholder="Name">
  1959. </div>
  1960. </script>
  1961. <script type="text/x-red" data-help-name="AudioSynthToneSweep">
  1962. <h3>Summary</h3>
  1963. <div class=tooltipinfo>
  1964. <p>Create a continuously varying (in frequency) sine wave</p>
  1965. </div>
  1966. <h3>Audio Connections</h3>
  1967. <table class=doc align=center cellpadding=3>
  1968. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1969. <tr class=odd><td align=center>Out 0</td><td>Continuously varying tone</td></tr>
  1970. </table>
  1971. <h3>Functions</h3>
  1972. <p class=func><span class=keyword>play</span>(level, lowFreq, highFreq, time);</p>
  1973. <p class=desc>Start generating frequency sweep output. The time is specified
  1974. in milliseconds. Level is 0 to 1.0.
  1975. </p>
  1976. <p class=func><span class=keyword>isPlaying</span>();</p>
  1977. <p class=desc>Returns true (non-zero) while the output is active.
  1978. </p>
  1979. <h3>Examples</h3>
  1980. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; ToneSweep
  1981. </p>
  1982. <h3>Notes</h3>
  1983. <p>Uses excessive CPU time</p>
  1984. </script>
  1985. <script type="text/x-red" data-template-name="AudioSynthToneSweep">
  1986. <div class="form-row">
  1987. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1988. <input type="text" id="node-input-name" placeholder="Name">
  1989. </div>
  1990. </script>
  1991. <script type="text/x-red" data-help-name="AudioSynthWaveformDc">
  1992. <h3>Summary</h3>
  1993. <div class=tooltipinfo>
  1994. <p>Create constant (DC) signal, useful for control of objects that take
  1995. a modulation or control input signal. This constant level can be
  1996. used to modify other waveforms using mixer or multiplier objects</p>
  1997. </div>
  1998. <h3>Audio Connections</h3>
  1999. <table class=doc align=center cellpadding=3>
  2000. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2001. <tr class=odd><td align=center>Out 0</td><td>Output constant DC level</td></tr>
  2002. </table>
  2003. <h3>Functions</h3>
  2004. <p class=func><span class=keyword>amplitude</span>(level);</p>
  2005. <p class=desc>Set the output. Level is -1.0 to 1.0. The output is
  2006. changed immediately.
  2007. </p>
  2008. <p class=func><span class=keyword>amplitude</span>(level, milliseconds);</p>
  2009. <p class=desc>Set the output. Level is -1.0 to 1.0. The output is
  2010. gradually changed over a "milliseconds" time period. Any time may
  2011. be specified, but periods longer than 1 second may be automatically
  2012. shortened for small level changes, due to numerical precision limits.
  2013. </p>
  2014. <!--
  2015. <h3>Examples</h3>
  2016. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2017. </p>
  2018. -->
  2019. <h3>Notes</h3>
  2020. <p>Of course, the term "DC", for Direct Current, doesn't properly apply
  2021. to a pure digital stream of numerical values. But the term is widely
  2022. understood in audio applications, so hopefully it's not too confusing?</p>
  2023. </script>
  2024. <script type="text/x-red" data-template-name="AudioSynthWaveformDc">
  2025. <div class="form-row">
  2026. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2027. <input type="text" id="node-input-name" placeholder="Name">
  2028. </div>
  2029. </script>
  2030. <script type="text/x-red" data-help-name="AudioSynthNoiseWhite">
  2031. <h3>Summary</h3>
  2032. <div class=tooltipinfo>
  2033. <p>Create white noise.
  2034. </p>
  2035. <p align=center><img src="img/whitenoise.png"></p>
  2036. </div>
  2037. <h3>Audio Connections</h3>
  2038. <table class=doc align=center cellpadding=3>
  2039. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2040. <tr class=odd><td align=center>Out 0</td><td>White Noise</td></tr>
  2041. </table>
  2042. <h3>Functions</h3>
  2043. <p class=func><span class=keyword>amplitude</span>(level);</p>
  2044. <p class=desc>Set the output peak level, from 0 (off) to 1.0.
  2045. The default is off. Noise is generated only after setting
  2046. to a non-zero level.
  2047. </p>
  2048. <h3>Examples</h3>
  2049. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2050. </p>
  2051. <h3>Notes</h3>
  2052. <p>Setting the amplitude to zero causes this object to stop using
  2053. CPU time to generate random numbers.
  2054. </p>
  2055. </script>
  2056. <script type="text/x-red" data-template-name="AudioSynthNoiseWhite">
  2057. <div class="form-row">
  2058. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2059. <input type="text" id="node-input-name" placeholder="Name">
  2060. </div>
  2061. </script>
  2062. <script type="text/x-red" data-help-name="AudioSynthNoisePink">
  2063. <h3>Summary</h3>
  2064. <div class=tooltipinfo>
  2065. <p>Create pink noise, using Stefan Stenzel's "New Shade Of Pink" algorithm.
  2066. </p>
  2067. <!--
  2068. <p align=center><img src="img/whitenoise.png"></p>
  2069. -->
  2070. </div>
  2071. <h3>Audio Connections</h3>
  2072. <table class=doc align=center cellpadding=3>
  2073. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2074. <tr class=odd><td align=center>Out 0</td><td>Pink Noise</td></tr>
  2075. </table>
  2076. <h3>Functions</h3>
  2077. <p class=func><span class=keyword>amplitude</span>(level);</p>
  2078. <p class=desc>Set the output peak level, from 0 (off) to 1.0.
  2079. The default is off. Noise is generated only after setting
  2080. to a non-zero level.
  2081. </p>
  2082. <h3>Examples</h3>
  2083. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  2084. </p>
  2085. <h3>Notes</h3>
  2086. <p>Setting the amplitude to zero causes this object to stop using
  2087. CPU time. CPU usage is approx 3% on Teensy 3.1.
  2088. </p>
  2089. <p>Stefan Stenzel's
  2090. <a href="http://stenzel.waldorfmusic.de/post/pink/" target="_blank">New Shade Of Pink</a>
  2091. algorithm. Stefan's terms of use are "Use for any purpose. If used
  2092. in a commercial product, you should give me one."
  2093. </p>
  2094. </script>
  2095. <script type="text/x-red" data-template-name="AudioSynthNoisePink">
  2096. <div class="form-row">
  2097. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2098. <input type="text" id="node-input-name" placeholder="Name">
  2099. </div>
  2100. </script>
  2101. <script type="text/x-red" data-help-name="AudioEffectFade">
  2102. <h3>Summary</h3>
  2103. <div class=tooltipinfo>
  2104. <p>Gradually increase or decrease audio level.</p>
  2105. </div>
  2106. <h3>Audio Connections</h3>
  2107. <table class=doc align=center cellpadding=3>
  2108. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2109. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2110. <tr class=odd><td align=center>Out 0</td><td>Signal Output</td></tr>
  2111. </table>
  2112. <h3>Functions</h3>
  2113. <p class=func><span class=keyword>fadeIn</span>(milliseconds);</p>
  2114. <p class=desc>Begin increasing the audio level, to reach 1.0 (input passed
  2115. directly to the output) after "milliseconds" time.
  2116. </p>
  2117. <p class=func><span class=keyword>fadeOut</span>(milliseconds);</p>
  2118. <p class=desc>Begin decreasing the audio level, to reach 0 (no output)
  2119. after "milliseconds" time.
  2120. </p>
  2121. <!--
  2122. <h3>Examples</h3>
  2123. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2124. </p>
  2125. -->
  2126. <h3>Notes</h3>
  2127. <p>Cross fading can be built with 2 fade objects fed into a mixer.
  2128. When one fade object is off (fully faded out) and the other on
  2129. (fully faded in), if both are started at the same moment for the
  2130. same time duration, their signal gains always add to 1.0. This
  2131. allows 2 fade objects to work together for a smooth transition
  2132. between a pair of signals.
  2133. </p>
  2134. <p><a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  2135. should be used when changing
  2136. settings on multiple objects, so all changes always take effect
  2137. at the same moment.
  2138. </p>
  2139. </script>
  2140. <script type="text/x-red" data-template-name="AudioEffectFade">
  2141. <div class="form-row">
  2142. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2143. <input type="text" id="node-input-name" placeholder="Name">
  2144. </div>
  2145. </script>
  2146. <script type="text/x-red" data-help-name="AudioEffectChorus">
  2147. <h3>Summary</h3>
  2148. <div class=tooltipinfo>
  2149. <p>The chorus effect simulates the richness of several nearly-identical
  2150. sound sources (like the way a choir sounds different to a single singer).
  2151. It does this by sampling from a delay line, so each voice is actually
  2152. the same but at a slightly different point in time. This is a type of
  2153. comb filtering.</p>
  2154. </div>
  2155. <p>Chorus combines one or more samples ranging from the most recent
  2156. sample back to about 50ms ago. The additional samples are evenly spread
  2157. through the supplied delay line, and there is no modulation.</p>
  2158. <p>If the number of voices is specified as 2, then the
  2159. effect combines the current sample and the oldest sample (the last one
  2160. in the delay line). If the number of voices is 3 then the effect combines
  2161. the most recent sample, the oldest sample and the sample in the middle of
  2162. the delay line.</p>
  2163. <p>For two voices the effect can be represented as:<br/>
  2164. result = (sample(0) + sample(dt))/2<br/>
  2165. where sample(0) represents the current sample and sample(dt)
  2166. is the sample in the delay line from dt milliseconds ago.</p>
  2167. <h3>Audio Connections</h3>
  2168. <table class=doc align=center cellpadding=3>
  2169. <tr class="top"><th>Port</th><th>Purpose</th></tr>
  2170. <tr class="odd"><td align="center">In 0</td><td>Signal Input</td></tr>
  2171. <tr class="odd"><td align="center">Out 0</td><td>Chorused Output</td></tr>
  2172. </table>
  2173. <h3>Functions</h3>
  2174. <p class=func><span class=keyword>begin</span>(delayBuffer, length, n_chorus);</p>
  2175. <p class=desc>Create a chorus by specifying the address of the delayline, the
  2176. total number of samples in the delay line (often done as an integer multiple of
  2177. AUDIO_BLOCK_SAMPLES) and the number of voices in the chorus <em>including</em>
  2178. the original voice (so, 2 and up to get a chorus effect, although you can
  2179. specify 1 if you want).
  2180. </p>
  2181. <p class=func><span class=keyword>modify</span>(n_chorus);</p>
  2182. <p class=desc>Alters the number of voices in a running chorus (previously started with begin).
  2183. </p>
  2184. <h3>Examples</h3>
  2185. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Chorus
  2186. </p>
  2187. <h3>Notes</h3>
  2188. <p>The longer the length of the chorus, the more memory blocks are used.</p>
  2189. </script>
  2190. <script type="text/x-red" data-template-name="AudioEffectChorus">
  2191. <div class="form-row">
  2192. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2193. <input type="text" id="node-input-name" placeholder="Name">
  2194. </div>
  2195. </script>
  2196. <script type="text/x-red" data-help-name="AudioEffectFlange">
  2197. <h3>Summary</h3>
  2198. <div class=tooltipinfo>
  2199. <p>Originally, flanging was produced by playing the same signal on two synchronized
  2200. reel-to-reel tape recorders and making one of the reels slow down and speed up by
  2201. pressing on the flange of the reel (hence the name). This is a type of
  2202. comb filtering, and produces a harmonically-related series of peaks and notches
  2203. in the audio spectrum.</p>
  2204. </div>
  2205. <p>This flanger uses a delay line, combining the original voice with only one sample from the delay
  2206. line, but the position of that sample varies sinusoidally.</p>
  2207. <p>The effect can be represented as:<br>
  2208. result = sample(0) + sample(dt + depth*sin(2*PI*Fe))</p>
  2209. <p>The value of the sine function is always a number from -1 to +1 and
  2210. so the result of depth*(sin(Fe)) is always a number from -depth to +depth.
  2211. Thus, the delayed sample will be selected from the range (dt-depth) to
  2212. (dt+depth). This selection will vary at whatever rate is specified as the
  2213. frequency of the effect, Fe. Typically a low frequency (a few Hertz) is used.
  2214. <h3>Audio Connections</h3>
  2215. <table class=doc align=center cellpadding=3>
  2216. <tr class="top"><th>Port</th><th>Purpose</th></tr>
  2217. <tr class="odd"><td align="center">In 0</td><td>Signal Input</td></tr>
  2218. <tr class="odd"><td align="center">Out 0</td><td>Flanged Output</td></tr>
  2219. </table>
  2220. <h3>Functions</h3>
  2221. <p class=func><span class=keyword>begin</span>(delayBuffer, length, offset, depth, delayRate);</p>
  2222. <p class=desc>Create a flanger by specifying the address of the delayline, the
  2223. total number of samples in the delay line (often done as an integer multiple of
  2224. AUDIO_BLOCK_SAMPLES), the offset (how far back the flanged sample is from the original voice),
  2225. the modulation depth (larger values give a greater variation) and the modulation
  2226. frequency, in Hertz.
  2227. </p>
  2228. <p class=func><span class=keyword>voices</span>(offset, depth, delayRate);</p>
  2229. <p class=desc>Alters the parameters in a running flanger (previously started with begin).
  2230. </p>
  2231. <h3>Examples</h3>
  2232. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Flange
  2233. </p>
  2234. <h3>Notes</h3>
  2235. <p>The longer the length of the delay buffer, the more memory blocks are used.</p>
  2236. <p>Try these settings:<br>
  2237. #define FLANGE_DELAY_LENGTH (2*AUDIO_BLOCK_SAMPLES)<br>
  2238. and<br>
  2239. int s_idx = 2*FLANGE_DELAY_LENGTH/4;<br>
  2240. int s_depth = FLANGE_DELAY_LENGTH/4;<br>
  2241. double s_freq = 3;</p>
  2242. <p>The flange effect can also produce a chorus-like effect if a longer
  2243. delay line is used with a slower modulation rate, for example try:<br>
  2244. #define FLANGE_DELAY_LENGTH (12*AUDIO_BLOCK_SAMPLES)<br>
  2245. and<br>
  2246. int s_idx = 3*FLANGE_DELAY_LENGTH/4;<br>
  2247. int s_depth = FLANGE_DELAY_LENGTH/8;<br>
  2248. double s_freq = .0625;</p>
  2249. </script>
  2250. <script type="text/x-red" data-template-name="AudioEffectFlange">
  2251. <div class="form-row">
  2252. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2253. <input type="text" id="node-input-name" placeholder="Name">
  2254. </div>
  2255. </script>
  2256. <script type="text/x-red" data-help-name="AudioEffectReverb">
  2257. <h3>Summary</h3>
  2258. <div class=tooltipinfo>
  2259. <p>Reverb with adjustable reverberation time. Contributed by Joao Rossi FIlho.
  2260. </p>
  2261. </div>
  2262. <h3>Audio Connections</h3>
  2263. <table class=doc align=center cellpadding=3>
  2264. <tr class="top"><th>Port</th><th>Purpose</th></tr>
  2265. <tr class="odd"><td align="center">In 0</td><td>Input</td></tr>
  2266. <tr class="odd"><td align="center">Out 0</td><td>Output</td></tr>
  2267. </table>
  2268. <h3>Functions</h3>
  2269. <p class=func><span class=keyword>reverbTime</span>(seconds);</p>
  2270. <p class=desc>Sets the amount of reverberation time.
  2271. </p>
  2272. <h3>Examples</h3>
  2273. <p><a href="https://twitter.com/joaorossifilho/status/779737126841753601">Video Demo</a>
  2274. </p>
  2275. <!--<p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Flange
  2276. </p>-->
  2277. <h3>Notes</h3>
  2278. <p>This effect may have distortion problems with the input signal is more than 0.5.</p>
  2279. </script>
  2280. <script type="text/x-red" data-template-name="AudioEffectReverb">
  2281. <div class="form-row">
  2282. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2283. <input type="text" id="node-input-name" placeholder="Name">
  2284. </div>
  2285. </script>
  2286. <script type="text/x-red" data-help-name="AudioEffectEnvelope">
  2287. <h3>Summary</h3>
  2288. <div class=tooltipinfo>
  2289. <p>Modify a signal with a DAHDSR (Delay Attack Hold Decay Sustain
  2290. Release) envelope.
  2291. </p>
  2292. <p align=center><img src="img/dahdsr.png"></p>
  2293. </div>
  2294. <h3>Audio Connections</h3>
  2295. <table class=doc align=center cellpadding=3>
  2296. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2297. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2298. <tr class=odd><td align=center>Out 0</td><td>Signal with Envelope Applied</td></tr>
  2299. </table>
  2300. <h3>Functions</h3>
  2301. <p class=func><span class=keyword>noteOn</span>();</p>
  2302. <p class=desc>Begin the delay to attack, or the attack phase is
  2303. delay is zero.
  2304. </p>
  2305. <p class=func><span class=keyword>noteOff</span>();</p>
  2306. <p class=desc>Begin the release phase.
  2307. </p>
  2308. <p class=func><span class=keyword>delay</span>(milliseconds);</p>
  2309. <p class=desc>Set the delay from noteOn to the attach phase. The
  2310. default is zero, for no delay.
  2311. </p>
  2312. <p class=func><span class=keyword>attack</span>(milliseconds);</p>
  2313. <p class=desc>Set the attack time. The default is 1.5 milliseconds.
  2314. </p>
  2315. <p class=func><span class=keyword>hold</span>(milliseconds);</p>
  2316. <p class=desc>Set the hold time. The default is 0.5 milliseconds.
  2317. </p>
  2318. <p class=func><span class=keyword>decay</span>(milliseconds);</p>
  2319. <p class=desc>Set the decay time. The default is 15 milliseconds.
  2320. </p>
  2321. <p class=func><span class=keyword>sustain</span>(level);</p>
  2322. <p class=desc>Set the sustain level. The range is 0 to 1.0. The
  2323. gain will be maintained at this level after the decay phase,
  2324. until noteOff() is called.
  2325. </p>
  2326. <p class=func><span class=keyword>release</span>(milliseconds);</p>
  2327. <p class=desc>Set the release time. The default is 30 millisecond.
  2328. </p>
  2329. <h3>Examples</h3>
  2330. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; PlaySynthMusic
  2331. </p>
  2332. <p class=exam>File &gt; Examples &gt; Audio &gt; Synthesis &gt; pulseWidth
  2333. </p>
  2334. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  2335. </p>
  2336. <h3>Notes</h3>
  2337. <p>To achieve the more common ADSR shape, simply
  2338. set delay and hold to zero.</p>
  2339. <p>The recommended range for each of the 5 timing inputs is 0 to 50
  2340. milliseconds. Up to 200 ms can be used, with somewhat reduced
  2341. accuracy</p>
  2342. </script>
  2343. <script type="text/x-red" data-template-name="AudioEffectEnvelope">
  2344. <div class="form-row">
  2345. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2346. <input type="text" id="node-input-name" placeholder="Name">
  2347. </div>
  2348. </script>
  2349. <script type="text/x-red" data-help-name="AudioEffectMultiply">
  2350. <h3>Summary</h3>
  2351. <div class=tooltipinfo>
  2352. <p>Multiply two signals together, useful for amplitude modulation
  2353. or "voltage controlled amplification".
  2354. </p>
  2355. <p align=center><img src="img/multiply.png"><br><small>56 Hz and 1 kHz sine waves multiplied.</small></p>
  2356. </div>
  2357. <h3>Audio Connections</h3>
  2358. <table class=doc align=center cellpadding=3>
  2359. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2360. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2361. <tr class=odd><td align=center>In 1</td><td>Signal Input</td></tr>
  2362. <tr class=odd><td align=center>Out 0</td><td>Signal with Envelope Applied</td></tr>
  2363. </table>
  2364. <h3>Functions</h3>
  2365. <p>There are no functions to call from the Arduino sketch.
  2366. This object simply multiplies the 2 signals to create
  2367. a continuous output
  2368. </p>
  2369. <!--
  2370. <h3>Examples</h3>
  2371. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2372. </p>
  2373. -->
  2374. <h3>Notes</h3>
  2375. <p>
  2376. </p>
  2377. </script>
  2378. <script type="text/x-red" data-template-name="AudioEffectMultiply">
  2379. <div class="form-row">
  2380. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2381. <input type="text" id="node-input-name" placeholder="Name">
  2382. </div>
  2383. </script>
  2384. <script type="text/x-red" data-help-name="AudioEffectDelay">
  2385. <h3>Summary</h3>
  2386. <div class=tooltipinfo>
  2387. <p>Delay a signal. Up to 8 separate delay taps can be used.</p>
  2388. <p align=center><img src="img/delay.png"><br><small>1 kHz burst, delayed 5.2 ms.</small></p>
  2389. </div>
  2390. <h3>Audio Connections</h3>
  2391. <table class=doc align=center cellpadding=3>
  2392. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2393. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2394. <tr class=odd><td align=center>Out 0</td><td>Delay Tap #1</td></tr>
  2395. <tr class=odd><td align=center>Out 1</td><td>Delay Tap #2</td></tr>
  2396. <tr class=odd><td align=center>Out 2</td><td>Delay Tap #3</td></tr>
  2397. <tr class=odd><td align=center>Out 3</td><td>Delay Tap #4</td></tr>
  2398. <tr class=odd><td align=center>Out 4</td><td>Delay Tap #5</td></tr>
  2399. <tr class=odd><td align=center>Out 5</td><td>Delay Tap #6</td></tr>
  2400. <tr class=odd><td align=center>Out 6</td><td>Delay Tap #7</td></tr>
  2401. <tr class=odd><td align=center>Out 7</td><td>Delay Tap #8</td></tr>
  2402. </table>
  2403. <h3>Functions</h3>
  2404. <p class=func><span class=keyword>delay</span>(channel, milliseconds);</p>
  2405. <p class=desc>Set output channel (0 to 7) to delay the signals by
  2406. milliseconds. The maximum delay is approx 425 ms. The actual delay
  2407. is rounded to the nearest sample. Each channel can be configured for
  2408. any delay. There is no requirement to configure the "taps" in increasing
  2409. delay order.
  2410. </p>
  2411. <p class=func><span class=keyword>disable</span>(channel);</p>
  2412. <p class=desc>Disable a channel. The output of this channel becomes
  2413. silent. If this channel is the longest delay, memory usage is
  2414. automatically reduced to accomodate only the remaining channels used.
  2415. </p>
  2416. <h3>Examples</h3>
  2417. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Delay
  2418. </p>
  2419. <h3>Notes</h3>
  2420. <p>Memory for the delayed signal is take from the memory pool allocated by
  2421. <a href="http://www.pjrc.com/teensy/td_libs_AudioConnection.html" target="_blank">AudioMemory()</a>.
  2422. Each block allows about 3 milliseconds of delay, so AudioMemory
  2423. should be increased to allow for the longest delay tap.
  2424. </p>
  2425. </script>
  2426. <script type="text/x-red" data-template-name="AudioEffectDelay">
  2427. <div class="form-row">
  2428. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2429. <input type="text" id="node-input-name" placeholder="Name">
  2430. </div>
  2431. </script>
  2432. <script type="text/x-red" data-help-name="AudioEffectDelayExternal">
  2433. <h3>Summary</h3>
  2434. <div class=tooltipinfo>
  2435. <p>Delay a signal, using external memory for longer delay times! Up to 8 separate delay taps can be used.</p>
  2436. <p align=center><img src="img/delay.png"><br><small>1 kHz burst, delayed 5.2 ms.</small></p>
  2437. </div>
  2438. <h3>Audio Connections</h3>
  2439. <table class=doc align=center cellpadding=3>
  2440. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2441. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2442. <tr class=odd><td align=center>Out 0</td><td>Delay Tap #1</td></tr>
  2443. <tr class=odd><td align=center>Out 1</td><td>Delay Tap #2</td></tr>
  2444. <tr class=odd><td align=center>Out 2</td><td>Delay Tap #3</td></tr>
  2445. <tr class=odd><td align=center>Out 3</td><td>Delay Tap #4</td></tr>
  2446. <tr class=odd><td align=center>Out 4</td><td>Delay Tap #5</td></tr>
  2447. <tr class=odd><td align=center>Out 5</td><td>Delay Tap #6</td></tr>
  2448. <tr class=odd><td align=center>Out 6</td><td>Delay Tap #7</td></tr>
  2449. <tr class=odd><td align=center>Out 7</td><td>Delay Tap #8</td></tr>
  2450. </table>
  2451. <h3>Functions</h3>
  2452. <p class=func><span class=keyword>delay</span>(channel, milliseconds);</p>
  2453. <p class=desc>Set output channel (0 to 7) to delay the signals by
  2454. milliseconds. The maximum delay is approx 1.5 seconds for each 23LC1024 chip.
  2455. The actual delay
  2456. is rounded to the nearest sample. Each channel can be configured for
  2457. any delay. There is no requirement to configure the "taps" in increasing
  2458. delay order.
  2459. </p>
  2460. <p class=func><span class=keyword>disable</span>(channel);</p>
  2461. <p class=desc>Disable a channel. The output of this channel becomes
  2462. silent. If this channel is the longest delay, memory usage is
  2463. automatically reduced to accomodate only the remaining channels used.
  2464. </p>
  2465. <h3>Hardware</h3>
  2466. <p>By default, or when <span class=literal>AUDIO_MEMORY_23LC1024</span> is used (see below),
  2467. a single 23LC1024 RAM chip is used, with these pins:
  2468. <table class=doc align=center cellpadding=3>
  2469. <tr class=top><th>Pin</th><th>Signal</th></tr>
  2470. <tr class=odd><td align=center>6</td><td>CS</td></tr>
  2471. <tr class=odd><td align=center>7</td><td>MOSI</td></tr>
  2472. <tr class=odd><td align=center>12</td><td>MISO</td></tr>
  2473. <tr class=odd><td align=center>14</td><td>SCK</td></tr>
  2474. </table>
  2475. </p>
  2476. <p>When <span class=literal>AUDIO_MEMORY_MEMORYBOARD</span> is used, up to six
  2477. 23LC1024 chips are used.
  2478. </p>
  2479. <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>
  2480. <p>
  2481. <table class=doc align=center cellpadding=3>
  2482. <tr class=top><th>Pin</th><th>Signal</th></tr>
  2483. <tr class=odd><td align=center>2</td><td>CS0 (encoded)</td></tr>
  2484. <tr class=odd><td align=center>3</td><td>CS1 (encoded)</td></tr>
  2485. <tr class=odd><td align=center>4</td><td>CS2 (encoded)</td></tr>
  2486. <tr class=odd><td align=center>7</td><td>MOSI</td></tr>
  2487. <tr class=odd><td align=center>12</td><td>MISO</td></tr>
  2488. <tr class=odd><td align=center>14</td><td>SCK</td></tr>
  2489. </table>
  2490. </p>
  2491. <p>
  2492. If fewer than 6 chips are soldered, the optional parameter for maximum delay
  2493. must be used. See below for details. Each chip provides 1485 ms of delay
  2494. memory, so the total of all objects using AUDIO_MEMORY_MEMORYBOARD must not
  2495. exceed the amount of memory physically present.
  2496. </p>
  2497. <h3>Examples</h3>
  2498. <p>
  2499. <a href="https://www.youtube.com/watch?v=d80d1HWy5_s" target="_blank">Demo Video</a> (YouTube)
  2500. </p>
  2501. <!--
  2502. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Delay
  2503. </p>
  2504. -->
  2505. <p>
  2506. <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)
  2507. </p>
  2508. <h3>Notes</h3>
  2509. <p>External RAM allows for longer delays without consuming
  2510. limited internal RAM. However, SPI communication is required,
  2511. which consumes much more CPU time. The
  2512. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html">AudioProcessorUsageMax</a>
  2513. function may be used to monitor how much CPU time is consumed.
  2514. </p>
  2515. <p>You may specify the type of hardware to be used by editing the code. AUDIO_MEMORY_23LC1024
  2516. specifies a single 23LC1024 chip. AUDIO_MEMORY_MEMORYBOARD allows using up to 6 of these
  2517. chips.
  2518. </p>
  2519. <p class=desc><span class=keyword>AudioEffectDelayExternal</span> delayExt1(<span class=literal>AUDIO_MEMORY_23LC1024</span>);
  2520. </p>
  2521. <p>You may also create more than one delay using the same hardware, where the memory is partitioned
  2522. by specifying a maximum delay in milliseconds. This can be useful if you wish to delay both
  2523. channels of a stereo signal.
  2524. <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);
  2525. </p>
  2526. </script>
  2527. <script type="text/x-red" data-template-name="AudioEffectDelayExternal">
  2528. <div class="form-row">
  2529. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2530. <input type="text" id="node-input-name" placeholder="Name">
  2531. </div>
  2532. </script>
  2533. <script type="text/x-red" data-help-name="AudioEffectBitcrusher">
  2534. <h3>Summary</h3>
  2535. <div class=tooltipinfo>
  2536. <p>Reduce the samplerate and/or bitdepth of a source signal, resulting in
  2537. a distorted sound.</p>
  2538. </div>
  2539. <h3>Audio Connections</h3>
  2540. <table class=doc align=center cellpadding=3>
  2541. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2542. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  2543. <tr class=odd><td align=center>Out 0</td><td>Signal Output</td></tr>
  2544. </table>
  2545. <h3>Functions</h3>
  2546. <p class=func><span class=keyword>bits</span>(xcrushBits);</p>
  2547. <p class=desc>xcrushBits sets the bitdepth, from 1 to 16. A Value of 16
  2548. does not crush the bitdepth, and is effectively a passthru for this part
  2549. of the function.</p>
  2550. <p class=func><span class=keyword>sampleRate</span>(xsampleRate);</p>
  2551. <p class=desc>xsampleRate sets the frequency, from 1 to 44100Hz, however it
  2552. works in integer steps so you will only really get a handful of results from
  2553. the many samplerates you can pass. 44100 is passthru.</p>
  2554. <p class=desc>set xbitDepth to 16 and xsampleRate to 44100 to pass audio
  2555. through without any Bitcrush effect.</p>
  2556. <h3>Examples</h3>
  2557. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Bitcrusher
  2558. </p>
  2559. <h3>Notes</h3>
  2560. <p>Needs a lot of improvement. Options for anti-aliasing would be nice in
  2561. the future, but for now, it's rough, it's dirty and it sounds a bit like
  2562. Nine Inch Nails.
  2563. </p>
  2564. <p><a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  2565. should be used when changing
  2566. settings on multiple objects, so all changes always take effect
  2567. at the same moment.
  2568. </p>
  2569. </script>
  2570. <script type="text/x-red" data-template-name="AudioEffectBitcrusher">
  2571. <div class="form-row">
  2572. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2573. <input type="text" id="node-input-name" placeholder="Name">
  2574. </div>
  2575. </script>
  2576. <script type="text/x-red" data-help-name="AudioEffectMidSide">
  2577. <h3>Summary</h3>
  2578. <div class=tooltipinfo>
  2579. <p>Convert stereo signals to/from Mid-Side format.
  2580. Mid-Side encoding can be used to increase stereo width, make the lower
  2581. frequencies mono (to please your sub), or as the basis of audio compression.</p>
  2582. </div>
  2583. <h3>Audio Connections</h3>
  2584. <table class=doc align=center cellpadding=3>
  2585. <tr class=top><th>Port</th><th>While<br>Encoding</th><th>While<br>Decoding</th></tr>
  2586. <tr class=odd><td align=center>In 0</td><td>Left Input</td><td>Mid Output</td></tr>
  2587. <tr class=odd><td align=center>In 1</td><td>Right Input</td><td>Side Output</td></tr>
  2588. <tr class=odd><td align=center>Out 0</td><td>Mid Input</td><td>Left Output</td></tr>
  2589. <tr class=odd><td align=center>Out 1</td><td>Side Input</td><td>Right Output</td></tr>
  2590. </table>
  2591. <h3>Functions</h3>
  2592. <p class=func><span class=keyword>encode</span>();</p>
  2593. <p class=desc>Configure this object to encode from stereo to Mid-Side format.</p>
  2594. <p class=func><span class=keyword>decode</span>();</p>
  2595. <p class=desc>Configure this object to decode from Mid-Side format back to stereo signals.</p>
  2596. <h3>Examples</h3>
  2597. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Mid_Side</p>
  2598. <h3>Notes</h3>
  2599. <p>Many interesting stereo effects can be achieved by manipulating Mid-Side signals.</p>
  2600. <p>Normally a pair of these objects are used, one to encode, then additional
  2601. gain/attenuation or effects applied to the Mid-Side signals, and finally
  2602. decoding back to stereo signals</p>
  2603. <p>To prevent saturation, halving is done in the encoding, that is:</p>
  2604. <p>Mid = (left+right)/2</p>
  2605. <p>Side = (left-right)/2</p>
  2606. <p>And to decode:</p>
  2607. <p>Left = Mid+Side</p>
  2608. <p>Right = Mid-Side</p>
  2609. </script>
  2610. <script type="text/x-red" data-template-name="AudioEffectMidSide">
  2611. <div class="form-row">
  2612. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2613. <input type="text" id="node-input-name" placeholder="Name">
  2614. </div>
  2615. </script>
  2616. <script type="text/x-red" data-help-name="AudioFilterBiquad">
  2617. <h3>Summary</h3>
  2618. <div class=tooltipinfo>
  2619. <p>Biquadratic cascaded filter, useful for all sorts of filtering.
  2620. Up to 4 stages may be cascaded.
  2621. </p>
  2622. <p align=center><img src="img/biquad.png"></p>
  2623. </div>
  2624. <h3>Audio Connections</h3>
  2625. <table class=doc align=center cellpadding=3>
  2626. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2627. <tr class=odd><td align=center>In 0</td><td>Signal to be filtered</td></tr>
  2628. <tr class=odd><td align=center>Out 0</td><td>Filtered Signal Output</td></tr>
  2629. </table>
  2630. <h3>Functions</h3>
  2631. <p class=func><span class=keyword>setLowpass</span>(stage, frequency, Q);</p>
  2632. <p class=desc>Configure one stage of the filter (0 to 3) with low pass
  2633. response, with the specified corner frequency and Q shape. If Q is
  2634. higher that 0.7071, be careful of filter gain (see below).
  2635. </p>
  2636. <p class=func><span class=keyword>setHighpass</span>(stage, frequency, Q);</p>
  2637. <p class=desc>Configure one stage of the filter (0 to 3) with high pass
  2638. response, with the specified corner frequency and Q shape. If Q is
  2639. higher that 0.7071, be careful of filter gain (see below).
  2640. </p>
  2641. <p class=func><span class=keyword>setBandpass</span>(stage, frequency, Q);</p>
  2642. <p class=desc>Configure one stage of the filter (0 to 3) with band pass
  2643. response. The filter has unity gain at the specified frequency. Q
  2644. controls the width of frequencies allowed to pass.
  2645. </p>
  2646. <p class=func><span class=keyword>setNotch</span>(stage, frequency, Q);</p>
  2647. <p class=desc>Configure one stage of the filter (0 to 3) with band reject (notch)
  2648. response. Q controls the width of rejected frequencies.
  2649. </p>
  2650. <p class=func><span class=keyword>setLowShelf</span>(stage, frequency, gain, slope);</p>
  2651. <p class=desc>Configure one stage of the filter (0 to 3) with low shelf response.
  2652. A low shelf filter attenuates or amplifies signals below the specified frequency.
  2653. Frequency controls the slope midpoint, gain is in dB and can be both
  2654. positive or negative. The slope parameter controls steepness of gain transition.
  2655. A slope of 1 yields maximum steepness without overshoot,
  2656. lower values yield a less steep slope. See the picture below for a visualization
  2657. of the slope parameter's effect.
  2658. Be careful with positive gains and slopes higher than 1 as they introduce gain
  2659. (see warning below).
  2660. </p>
  2661. </p>
  2662. <p class=func><span class=keyword>setHighShelf</span>(stage, frequency, gain, slope);</p>
  2663. <p class=desc>Configure one stage of the filter (0 to 3) with high shelf response.
  2664. A high shelf filter attenuates or amplifies signals above the specified frequency.
  2665. Frequency controls the slope midpoint, gain is in dB and can be both
  2666. positive or negative. The slope parameter controls steepness of gain transition.
  2667. A slope of 1 yields maximum steepness without overshoot,
  2668. lower values yield a less steep slope. See the picture below for a visualization
  2669. of the slope parameter's effect.
  2670. Be careful with positive gains and slopes higher than 1 as they introduce gain
  2671. (see warning below).
  2672. </p>
  2673. <p align=center><img src="img/shelf_filter.png"></p>
  2674. <p class=func><span class=keyword>setCoefficients</span>(stage, array[5]);</p>
  2675. <p class=desc>Configure one stage of the filter (0 to 3) with an arbitrary
  2676. filter response. The array of coefficients is in order: B0, B1, B2, A1, A2.
  2677. Each coefficient must be less than 2.0 and greater than -2.0. The array
  2678. should be type double. Alternately, it may be type int, where 1.0 is
  2679. represented with 1073741824 (2<sup>30</sup>).
  2680. </p>
  2681. <h3>Examples</h3>
  2682. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter
  2683. </p>
  2684. <h3>Notes</h3>
  2685. <p>Filters can with gain must have their input signals attenuated, so the
  2686. signal does not exceed 1.0.
  2687. </p>
  2688. <p>This object implements up to 4 cascaded stages. Unconfigured stages will
  2689. not pass any signal.
  2690. </p>
  2691. <p>Biquad filters with low corner frequency (under about 400 Hz) can run into
  2692. trouble with limited numerical precision, causing the filter to perform
  2693. poorly. For very low corner frequency, the State Variable (Chamberlin)
  2694. filter should be used.
  2695. </p>
  2696. </script>
  2697. <script type="text/x-red" data-template-name="AudioFilterBiquad">
  2698. <div class="form-row">
  2699. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2700. <input type="text" id="node-input-name" placeholder="Name">
  2701. </div>
  2702. </script>
  2703. <script type="text/x-red" data-help-name="AudioFilterFIR">
  2704. <h3>Summary</h3>
  2705. <div class=tooltipinfo>
  2706. <p>Finite impulse response filter, useful for all sorts of filtering.
  2707. </p>
  2708. <p align=center><img src="img/fir_filter.png"></p>
  2709. </div>
  2710. <h3>Audio Connections</h3>
  2711. <table class=doc align=center cellpadding=3>
  2712. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2713. <tr class=odd><td align=center>In 0</td><td>Signal to be filtered</td></tr>
  2714. <tr class=odd><td align=center>Out 0</td><td>Filtered Signal Output</td></tr>
  2715. </table>
  2716. <h3>Functions</h3>
  2717. <p class=func><span class=keyword>begin</span>(array, length);</p>
  2718. <p class=desc>Initialize the filter. The array must be 16 bit integers (the
  2719. filter's impulse response), and
  2720. length indicates the number of points in the array. Array may also be
  2721. FIR_PASSTHRU (length = 0), to directly pass the input to output without
  2722. filtering.
  2723. </p>
  2724. <p class=func><span class=keyword>end</span>();</p>
  2725. <p class=desc>Turn the filter off.
  2726. </p>
  2727. <h3>Examples</h3>
  2728. <p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Filter_FIR
  2729. </p>
  2730. <h3>Known Issues</h3>
  2731. <p>Your filter's impulse response array must have an even length. If you have
  2732. add odd number of taps, you must add an extra zero to increase the length
  2733. to an even number.
  2734. </p>
  2735. <p>The minimum number of taps is 4. If you use less, add extra zeros to increase
  2736. the length to 4.
  2737. </p>
  2738. <p>The impulse response must be given in reverse order. Many filters have
  2739. symetrical impluse response, making this a non-issue. If your filter has
  2740. a non-symetrical response, make sure the data is in reverse time order.
  2741. </p>
  2742. <h3>Notes</h3>
  2743. <p>FIR filters requires more CPU time than Biquad (IIR), but they can
  2744. implement filters with better phase response.
  2745. </p>
  2746. <p>A 100 point filter requires 9% CPU time on Teensy 3.1. The maximum
  2747. supported filter length is 200 points.
  2748. </p>
  2749. <p>The free
  2750. <a href="http://t-filter.engineerjs.com/" target="_blank"> TFilter Design Tool</a>
  2751. can be used to create the impulse response array. Be sure to set the sampling
  2752. frequency to 44117 HZ (it defaults to only 2000 Hz) and the output type to "int" (16 bit).
  2753. </p>
  2754. <p>
  2755. If you use TFilter Design's "C/C++ array" option, it's output has "int" definition, which
  2756. is 32 bits on Teensy 3.1. Edit "int" to "short" for an array of 16 bit numbers,
  2757. and add "const" to avoid consuming extra RAM.
  2758. </p>
  2759. </script>
  2760. <script type="text/x-red" data-template-name="AudioFilterFIR">
  2761. <div class="form-row">
  2762. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2763. <input type="text" id="node-input-name" placeholder="Name">
  2764. </div>
  2765. </script>
  2766. <script type="text/x-red" data-help-name="AudioFilterStateVariable">
  2767. <h3>Summary</h3>
  2768. <div class=tooltipinfo>
  2769. <p>A State Variable (Chamberlin) Filter with 12 dB/octave roll-off,
  2770. adjustable resonance, and optional signal control of corner
  2771. frequency.</p>
  2772. </div>
  2773. <h3>Audio Connections</h3>
  2774. <table class=doc align=center cellpadding=3>
  2775. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2776. <tr class=odd><td align=center>In 0</td><td>Signal to Filter</td></tr>
  2777. <tr class=odd><td align=center>In 1</td><td>Frequency Control</td></tr>
  2778. <tr class=odd><td align=center>Out 0</td><td>Low Pass Output</td></tr>
  2779. <tr class=odd><td align=center>Out 1</td><td>Band Pass Output</td></tr>
  2780. <tr class=odd><td align=center>Out 2</td><td>High Pass Output</td></tr>
  2781. </table>
  2782. <h3>Functions</h3>
  2783. <p class=func><span class=keyword>frequency</span>(freq);</p>
  2784. <p class=desc>Set the filter's corner frequency. When a signal is
  2785. connected to the control input, the filter will implement this
  2786. frequency when the signal is zero.
  2787. </p>
  2788. <p class=func><span class=keyword>resonance</span>(Q);</p>
  2789. <p class=desc>Set the filter's resonance. Q ranges from 0.7 to 5.0.
  2790. Resonance greater than 0.707 will amplify the signal near the
  2791. corner frequency. You must attenuate the signal before input
  2792. to this filter, to prevent clipping.
  2793. </p>
  2794. <p class=func><span class=keyword>octaveControl</span>(octaves);</p>
  2795. <p class=desc>Set how much (in octaves) the control signal can alter
  2796. the filter's corner freqency. Range is 0 to 7 octaves. For
  2797. example, when set to 2.5, a full scale positive signal (1.0) will
  2798. shift the filter frequency up 2.5 octaves, and a full scale negative
  2799. signal will shift it down 2.5 octaves.
  2800. </p>
  2801. <!--
  2802. <h3>Examples</h3>
  2803. <p class=exam>File &gt; Examples &gt; Audio &gt;
  2804. </p>
  2805. -->
  2806. <h3>Notes</h3>
  2807. <p>
  2808. When controlled by a signal, the equation for the filter
  2809. frequency is:
  2810. </p>
  2811. <p>
  2812. F = Fcenter * 2^<sup>(signal * octaves)</sup>
  2813. <br><small>If anyone knows how to do HTML equations, please
  2814. help me improve this.....</small>
  2815. </p>
  2816. <p>When operating with signal control of corner frequency, this
  2817. object uses approximately 4% of the CPU time on Teensy 3.1.
  2818. </p>
  2819. </script>
  2820. <script type="text/x-red" data-template-name="AudioFilterFIR">
  2821. <div class="form-row">
  2822. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2823. <input type="text" id="node-input-name" placeholder="Name">
  2824. </div>
  2825. </script>
  2826. <script type="text/x-red" data-help-name="AudioAnalyzePeak">
  2827. <h3>Summary</h3>
  2828. <div class=tooltipinfo>
  2829. <p>Track the signal peak amplitude. Very useful for simple
  2830. audio level response projects, and general troubleshooting.</p>
  2831. </div>
  2832. <h3>Audio Connections</h3>
  2833. <table class=doc align=center cellpadding=3>
  2834. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2835. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  2836. </table>
  2837. <h3>Functions</h3>
  2838. <p class=func><span class=keyword>available</span>();</p>
  2839. <p class=desc>Returns true each time new peak data is available.
  2840. </p>
  2841. <p class=func><span class=keyword>read</span>();</p>
  2842. <p class=desc>Read the highest peak amplitude value since the last read.
  2843. Return is from 0.0 to 1.0.
  2844. </p>
  2845. <p class=func><span class=keyword>readPeakToPeak</span>();</p>
  2846. <p class=desc>Read the highest peak-to-peak amplitude since the last read.
  2847. Return is from 0.0 to 2.0.
  2848. </p>
  2849. <h3>Examples</h3>
  2850. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterMono
  2851. </p>
  2852. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterStereo
  2853. </p>
  2854. <h3>Notes</h3>
  2855. <p></p>
  2856. </script>
  2857. <script type="text/x-red" data-template-name="AudioAnalyzePeak">
  2858. <div class="form-row">
  2859. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2860. <input type="text" id="node-input-name" placeholder="Name">
  2861. </div>
  2862. </script>
  2863. <script type="text/x-red" data-help-name="AudioAnalyzeRMS">
  2864. <h3>Summary</h3>
  2865. <div class=tooltipinfo>
  2866. <p>Track the signal RMS amplitude. Useful for
  2867. audio level response projects, and general troubleshooting.</p>
  2868. </div>
  2869. <h3>Audio Connections</h3>
  2870. <table class=doc align=center cellpadding=3>
  2871. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2872. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  2873. </table>
  2874. <h3>Functions</h3>
  2875. <p class=func><span class=keyword>available</span>();</p>
  2876. <p class=desc>Returns true if new RMS data is available.
  2877. </p>
  2878. <p class=func><span class=keyword>read</span>();</p>
  2879. <p class=desc>Read the new RMS value.
  2880. Return is from 0.0 to 1.0.
  2881. </p>
  2882. <h3>Examples</h3>
  2883. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakAndRMSMeterStereo</p>
  2884. </p>
  2885. <h3>Notes</h3>
  2886. <p></p>
  2887. </script>
  2888. <script type="text/x-red" data-template-name="AudioAnalyzeRMS">
  2889. <div class="form-row">
  2890. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2891. <input type="text" id="node-input-name" placeholder="Name">
  2892. </div>
  2893. </script>
  2894. <script type="text/x-red" data-help-name="AudioAnalyzeFFT256">
  2895. <h3>Summary</h3>
  2896. <div class=tooltipinfo>
  2897. <p>Compute a 256 point Fast Fourier Transform (FFT) frequency analysis,
  2898. with real value (magnitude) output. The frequency resolution is
  2899. 172 Hz, useful for simple audio visualization.</p>
  2900. </div>
  2901. <h3>Audio Connections</h3>
  2902. <table class=doc align=center cellpadding=3>
  2903. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2904. <tr class=odd><td align=center>In 0</td><td>Signal to convert to frequency bins</td></tr>
  2905. </table>
  2906. <h3>Functions</h3>
  2907. <p class=func><span class=keyword>available</span>();</p>
  2908. <p class=desc>Returns true each time the FFT analysis produces new output data.
  2909. </p>
  2910. <p class=func><span class=keyword>read</span>(binNumber);</p>
  2911. <p class=desc>Read a single frequency bin, from 0 to 127. The result is scaled
  2912. so 1.0 represents a full scale sine wave.
  2913. </p>
  2914. <p class=func><span class=keyword>read</span>(firstBin, lastBin);</p>
  2915. <p class=desc>Read several frequency bins, returning their sum. The higher
  2916. audio octaves are represented by many bins, which are typically read
  2917. as a group for audio visualization.
  2918. </p>
  2919. <p class=func><span class=keyword>averageTogether</span>(number);</p>
  2920. <p class=desc>New data is produced very radidly, approximately 344 times
  2921. per second. Multiple outputs can be averaged together, so available()
  2922. returns true at a slower rate.
  2923. </p>
  2924. <p class=func><span class=keyword>windowFunction</span>(window);</p>
  2925. <p class=desc>Set the window function to be used. AudioWindowHanning256
  2926. is the default. Windowing may be disabled by NULL, but windowing
  2927. should be used for all non-periodic (music) signals, and all periodic
  2928. signals that are not exact integer division of the sample rate.
  2929. </p>
  2930. <h3>Examples</h3>
  2931. <p class=exam>File &gt; Examples &gt; Audio &gt; MemoryAndCpuUsage
  2932. </p>
  2933. <h3>Notes</h3>
  2934. <p>The raw 16 bit output data bins may be access with myFFT.output[num], where
  2935. num is 0 to 127.</p>
  2936. <p>TODO: caveats about spectral leakage vs frequency precision for arbitrary signals</p>
  2937. <p>Window Types:
  2938. <ul>
  2939. <li><span class=literal>AudioWindowHanning256</span> (default)</li>
  2940. <li><span class=literal>AudioWindowBartlett256</span></li>
  2941. <li><span class=literal>AudioWindowBlackman256</span></li>
  2942. <li><span class=literal>AudioWindowFlattop256</span></li>
  2943. <li><span class=literal>AudioWindowBlackmanHarris256</span></li>
  2944. <li><span class=literal>AudioWindowNuttall256</span></li>
  2945. <li><span class=literal>AudioWindowBlackmanNuttall256</span></li>
  2946. <li><span class=literal>AudioWindowWelch256</span></li>
  2947. <li><span class=literal>AudioWindowHamming256</span></li>
  2948. <li><span class=literal>AudioWindowCosine256</span></li>
  2949. <li><span class=literal>AudioWindowTukey256</span></li>
  2950. </ul>
  2951. </p>
  2952. </script>
  2953. <script type="text/x-red" data-template-name="AudioAnalyzeFFT256">
  2954. <div class="form-row">
  2955. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  2956. <input type="text" id="node-input-name" placeholder="Name">
  2957. </div>
  2958. </script>
  2959. <script type="text/x-red" data-help-name="AudioAnalyzeFFT1024">
  2960. <h3>Summary</h3>
  2961. <div class=tooltipinfo>
  2962. <p>Compute a 1024 point Fast Fourier Transform (FFT) frequency analysis,
  2963. with real value (magnitude) output. The frequency resolution is
  2964. 43 Hz, useful detailed for audio visualization.</p>
  2965. </div>
  2966. <h3>Audio Connections</h3>
  2967. <table class=doc align=center cellpadding=3>
  2968. <tr class=top><th>Port</th><th>Purpose</th></tr>
  2969. <tr class=odd><td align=center>In 0</td><td>Signal to convert to frequency bins</td></tr>
  2970. </table>
  2971. <h3>Functions</h3>
  2972. <p class=func><span class=keyword>available</span>();</p>
  2973. <p class=desc>Returns true each time the FFT analysis produces new output data.
  2974. </p>
  2975. <p class=func><span class=keyword>read</span>(binNumber);</p>
  2976. <p class=desc>Read a single frequency bin, from 0 to 511. The result is scaled
  2977. so 1.0 represents a full scale sine wave.
  2978. </p>
  2979. <p class=func><span class=keyword>read</span>(firstBin, lastBin);</p>
  2980. <p class=desc>Read several frequency bins, returning their sum. The higher
  2981. audio octaves are represented by many bins, which are typically read
  2982. as a group for audio visualization.
  2983. </p>
  2984. <p class=func><span class=keyword>averageTogether</span>(number);</p>
  2985. <p class=desc>This function does nothing. The 1024 point FFT always
  2986. updates at approximately 86 times per second.
  2987. </p>
  2988. <p class=func><span class=keyword>windowFunction</span>(window);</p>
  2989. <p class=desc>Set the window function to be used. AudioWindowHanning1024
  2990. is the default. Windowing may be disabled by NULL, but windowing
  2991. should be used for all non-periodic (music) signals, and all periodic
  2992. signals that are not exact integer division of the sample rate.
  2993. </p>
  2994. <h3>Examples</h3>
  2995. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; FFT
  2996. </p>
  2997. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; SpectrumAnalyzerBasic
  2998. </p>
  2999. <h3>Notes</h3>
  3000. <p>The raw 16 bit output data bins may be access with myFFT.output[num], where
  3001. num is 0 to 511.</p>
  3002. <p>TODO: caveats about spectral leakage vs frequency precision for arbitrary signals</p>
  3003. <p>Window Types:
  3004. <ul>
  3005. <li><span class=literal>AudioWindowHanning1024</span> (default)</li>
  3006. <li><span class=literal>AudioWindowBartlett1024</span></li>
  3007. <li><span class=literal>AudioWindowBlackman1024</span></li>
  3008. <li><span class=literal>AudioWindowFlattop1024</span></li>
  3009. <li><span class=literal>AudioWindowBlackmanHarris1024</span></li>
  3010. <li><span class=literal>AudioWindowNuttall1024</span></li>
  3011. <li><span class=literal>AudioWindowBlackmanNuttall1024</span></li>
  3012. <li><span class=literal>AudioWindowWelch1024</span></li>
  3013. <li><span class=literal>AudioWindowHamming1024</span></li>
  3014. <li><span class=literal>AudioWindowCosine1024</span></li>
  3015. <li><span class=literal>AudioWindowTukey1024</span></li>
  3016. </ul>
  3017. </p>
  3018. <p>1024 point FFT has a peak CPU usage of approx 52% on Teensy 3.1.
  3019. Average usage is much lower. Future versions might distribute the
  3020. load more evenly over time....
  3021. </p>
  3022. </script>
  3023. <script type="text/x-red" data-template-name="AudioAnalyzeFFT1024">
  3024. <div class="form-row">
  3025. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3026. <input type="text" id="node-input-name" placeholder="Name">
  3027. </div>
  3028. </script>
  3029. <script type="text/x-red" data-help-name="AudioAnalyzeToneDetect">
  3030. <h3>Summary</h3>
  3031. <div class=tooltipinfo>
  3032. <p>Detect the level of a single tone</p>
  3033. </div>
  3034. <h3>Audio Connections</h3>
  3035. <table class=doc align=center cellpadding=3>
  3036. <tr class=top><th>Port</th><th>Purpose</th></tr>
  3037. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  3038. </table>
  3039. <h3>Functions</h3>
  3040. <p class=func><span class=keyword>frequency</span>(freq);</p>
  3041. <p class=desc>Set the frequency to detect. The default detection time
  3042. will be 10 cycles of this frequency.
  3043. </p>
  3044. <p class=func><span class=keyword>frequency</span>(freq, cycles);</p>
  3045. <p class=desc>Set the frequency to detect, and the number of cycles.
  3046. Longer detection time (more cycles) will give higher precision,
  3047. but of course slower response.
  3048. </p>
  3049. <p class=func><span class=keyword>available</span>();</p>
  3050. <p class=desc>Returns true (non-zero) each time a detection interval
  3051. (number of cycles) completed and a new level is detected.
  3052. </p>
  3053. <p class=func><span class=keyword>read</span>();</p>
  3054. <p class=desc>Read the detected signal level. Range is 0 to 1.0.
  3055. </p>
  3056. <p class=func><span class=keyword>threshold</span>(level);</p>
  3057. <p class=desc>Set a detection threshold, where the bool test operation
  3058. will return true if at or above this level, or false when below.
  3059. </p>
  3060. <p class=func>(bool)</p>
  3061. <p class=desc>By testing the object as a boolean value, you can respond
  3062. to detection of a tone.
  3063. </p>
  3064. <h3>Examples</h3>
  3065. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_Serial
  3066. </p>
  3067. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; DialTone_7segment
  3068. </p>
  3069. <h3>Notes</h3>
  3070. <p>Low frequency detection has trouble with numerical precision.
  3071. Works really well for all 8 DTMF frequencies, but fails for
  3072. detecting "sub audible tones" used in some control applications.</p>
  3073. <p>The (bool) test continues to return true until the next detection
  3074. interval (the configured number of cycles). This behavior may
  3075. change in future versions, for a single true each time the signal
  3076. is detected, and then false for the remainder of that interval.</p>
  3077. </script>
  3078. <script type="text/x-red" data-template-name="AudioAnalyzeToneDetect">
  3079. <div class="form-row">
  3080. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3081. <input type="text" id="node-input-name" placeholder="Name">
  3082. </div>
  3083. </script>
  3084. <script type="text/x-red" data-help-name="AudioAnalyzeNoteFrequency">
  3085. <h3>Summary</h3>
  3086. <div class=tooltipinfo>
  3087. <p>Detect with fairly good accuracy the fundamental frequency f<sub>o</sub>
  3088. of musical notes, such as electric guitar and bass.</p>
  3089. </div>
  3090. <p>Written By Collin Duffy</p>
  3091. <h3>Audio Connections</h3>
  3092. <table class=doc align=center cellpadding=3>
  3093. <tr class=top><th>Port</th><th>Purpose</th></tr>
  3094. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  3095. </table>
  3096. <h3>Functions</h3>
  3097. <p class=func><span class=keyword>begin</span>(threshold);</p>
  3098. <p class=desc>Initialize and start detecting frequencies,
  3099. with an initial threshold (the amount of allowed uncertainty).
  3100. </p>
  3101. <p class=func><span class=keyword>available</span>();</p>
  3102. <p class=desc>Returns true (non-zero) when a valid
  3103. frequency is detected.
  3104. </p>
  3105. <p class=func><span class=keyword>read</span>();</p>
  3106. <p class=desc>Read the detected frequency.
  3107. </p>
  3108. <p class=func><span class=keyword>probability</span>();</p>
  3109. <p class=desc>Return the level of certainty, betweeo 0 to 1.0.
  3110. </p>
  3111. <p class=func><span class=keyword>threshold</span>(level);</p>
  3112. <p class=desc>Set the detection threshold, the amount of allowed uncertainty.
  3113. </p>
  3114. <h3>Examples</h3>
  3115. <p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; NoteFrequency
  3116. </p>
  3117. <h3>Notes</h3>
  3118. <p>The <a href="http://recherche.ircam.fr/equipes/pcm/cheveign/pss/2002_JASA_YIN.pdf">YIN algorithm</a> (PDF)
  3119. is used to detect frequencies, with many optimizations for
  3120. frequencies between 29-400Hz. This algorithm can be somewhat
  3121. memory and processor hungry but will allow you to detect with
  3122. fairly good accuracy the fundamental frequencies from
  3123. electric guitars and basses.</p>
  3124. <p>Within the code, AUDIO_GUITARTUNER_BLOCKS
  3125. may be edited to control low frequency range. The default
  3126. (24) allows measurement down to 29.14 Hz, or B(flat)0.</p>
  3127. <p>TODO: The usable upper range of this object is not well known.
  3128. Duff says "it should be good up to 1000Hz", but may have trouble
  3129. at 4 kHz. Please <a href="https://forum.pjrc.com/threads/32252-Different-Range-FFT-Algorithm/page2">post feedback here</a>, ideally with audio clips for the NoteFrequency example.</p>
  3130. <p>This object was contributed by Collin Duffy from his
  3131. <a href="https://github.com/duff2013/AudioTuner">AudioTuner project</a>.
  3132. Additional details and documentation may be found there.</p>
  3133. </script>
  3134. <script type="text/x-red" data-template-name="AudioAnalyzeNoteFrequency">
  3135. <div class="form-row">
  3136. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3137. <input type="text" id="node-input-name" placeholder="Name">
  3138. </div>
  3139. </script>
  3140. <script type="text/x-red" data-help-name="AudioAnalyzePrint">
  3141. <h3>Summary</h3>
  3142. <div class=tooltipinfo>
  3143. <p>Print raw audio data to the Arduino Serial Monitor. This
  3144. object creates massive output quickly, and should not normally be used.</p>
  3145. </div>
  3146. <h3>Audio Connections</h3>
  3147. <table class=doc align=center cellpadding=3>
  3148. <tr class=top><th>Port</th><th>Purpose</th></tr>
  3149. <tr class=odd><td align=center>In 0</td><td>Signal to print</td></tr>
  3150. </table>
  3151. <h3>Functions</h3>
  3152. <p class=func><span class=keyword>name</span>(string);</p>
  3153. <p class=desc>blah blah blah blah
  3154. </p>
  3155. <p class=func><span class=keyword>trigger</span>();</p>
  3156. <p class=desc>blah blah blah blah
  3157. </p>
  3158. <p class=func><span class=keyword>trigger</span>(level, edge);</p>
  3159. <p class=desc>blah blah blah blah
  3160. </p>
  3161. <p class=func><span class=keyword>delay</span>(samples);</p>
  3162. <p class=desc>blah blah blah blah
  3163. </p>
  3164. <p class=func><span class=keyword>length</span>(samples);</p>
  3165. <p class=desc>blah blah blah blah
  3166. </p>
  3167. <!--
  3168. <h3>Examples</h3>
  3169. <p class=exam>File &gt; Examples &gt; Audio &gt;
  3170. </p>
  3171. -->
  3172. <h3>Notes</h3>
  3173. <p>This object doesn't work very well and probably should not be used.</p>
  3174. </script>
  3175. <script type="text/x-red" data-template-name="AudioAnalyzePrint">
  3176. <div class="form-row">
  3177. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3178. <input type="text" id="node-input-name" placeholder="Name">
  3179. </div>
  3180. </script>
  3181. <script type="text/x-red" data-help-name="AudioControlSGTL5000">
  3182. <h3>Summary</h3>
  3183. <div class=tooltipinfo>
  3184. <p>Control the SGTL5000 chip on the
  3185. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>.
  3186. SGTL5000 is always used in slave mode, where Teensy controls
  3187. all I2S timing.
  3188. </p>
  3189. <p align=center><img src="img/sgtl5000closeup.jpg"></p>
  3190. </div>
  3191. <h3>Audio Connections</h3>
  3192. <p>This object has no audio inputs or outputs. Separate i2s objects
  3193. are used to send and receive audio data. I2S master mode objects
  3194. must be used, because this object configures the SGTL5000 in slave
  3195. mode, where it depends on Teensy to provide all I2S clocks.
  3196. This object controls
  3197. how the SGTL5000 will use those I2S audio streams.</p>
  3198. <h3>Functions</h3>
  3199. <p>These are the most commonly used SGTL5000 functions.</p>
  3200. <p class=func><span class=keyword>enable</span>();</p>
  3201. <p class=desc>Start the SGTL5000. This function should be called first.
  3202. </p>
  3203. <p class=func><span class=keyword>volume</span>(level);</p>
  3204. <p class=desc>Set the headphone volume level. Range is 0 to 1.0, but
  3205. 0.8 corresponds to the maximum undistorted output for a full scale
  3206. signal. Usually 0.5 is a comfortable listening level. The line
  3207. level outputs are <em>not</em> changed by this function.
  3208. </p>
  3209. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  3210. <p class=desc>Select which input to use: AUDIO_INPUT_LINEIN or AUDIO_INPUT_MIC.
  3211. </p>
  3212. <p class=func><span class=keyword>micGain</span>(dB);</p>
  3213. <p class=desc>When using the microphone input, set the amplifier gain.
  3214. The input number is in decibels, from 0 to 63.
  3215. </p>
  3216. <h3>Signal Levels</h3>
  3217. <p>The default signal levels should be used for most applications,
  3218. but these functions allow you to customize the analog signals.</p>
  3219. <p class=func><span class=keyword>muteHeadphone</span>();</p>
  3220. <p class=desc>Silence the headphone output.
  3221. </p>
  3222. <p class=func><span class=keyword>unmuteHeadphone</span>();</p>
  3223. <p class=desc>Turn the headphone output on.
  3224. </p>
  3225. <p class=func><span class=keyword>muteLineout</span>();</p>
  3226. <p class=desc>Silence the line level outputs.
  3227. </p>
  3228. <p class=func><span class=keyword>unmuteLineout</span>();</p>
  3229. <p class=desc>Turn the line level outputs on.
  3230. </p>
  3231. <p class=func><span class=keyword>lineInLevel</span>(both);</p>
  3232. <p class=desc style="padding-bottom:0.2em;">Adjust the sensitivity of the line-level inputs.
  3233. Fifteen settings are possible:
  3234. </p>
  3235. <pre class="desc">
  3236. 0: 3.12 Volts p-p
  3237. 1: 2.63 Volts p-p
  3238. 2: 2.22 Volts p-p
  3239. 3: 1.87 Volts p-p
  3240. 4: 1.58 Volts p-p
  3241. 5: 1.33 Volts p-p (default)
  3242. 6: 1.11 Volts p-p
  3243. 7: 0.94 Volts p-p
  3244. 8: 0.79 Volts p-p
  3245. 9: 0.67 Volts p-p
  3246. 10: 0.56 Volts p-p
  3247. 11: 0.48 Volts p-p
  3248. 12: 0.40 Volts p-p
  3249. 13: 0.34 Volts p-p
  3250. 14: 0.29 Volts p-p
  3251. 15: 0.24 Volts p-p
  3252. </pre>
  3253. <p class=func><span class=keyword>lineInLevel</span>(left, right);</p>
  3254. <p class=desc>Adjust the sensitivity of the line-level inputs, with different
  3255. settings for left and right. The same 15 settings are available.
  3256. </p>
  3257. <p class=func><span class=keyword>lineOutLevel</span>(both);</p>
  3258. <p class=desc style="padding-bottom:0.2em;">Adjust the line level output
  3259. voltage range. The following settings are possible:
  3260. </p>
  3261. <pre class="desc">
  3262. 13: 3.16 Volts p-p
  3263. 14: 2.98 Volts p-p
  3264. 15: 2.83 Volts p-p
  3265. 16: 2.67 Volts p-p
  3266. 17: 2.53 Volts p-p
  3267. 18: 2.39 Volts p-p
  3268. 19: 2.26 Volts p-p
  3269. 20: 2.14 Volts p-p
  3270. 21: 2.02 Volts p-p
  3271. 22: 1.91 Volts p-p
  3272. 23: 1.80 Volts p-p
  3273. 24: 1.71 Volts p-p
  3274. 25: 1.62 Volts p-p
  3275. 26: 1.53 Volts p-p
  3276. 27: 1.44 Volts p-p
  3277. 28: 1.37 Volts p-p
  3278. 29: 1.29 Volts p-p (default)
  3279. 30: 1.22 Volts p-p
  3280. 31: 1.16 Volts p-p
  3281. </pre>
  3282. <p class=func><span class=keyword>lineOutLevel</span>(left, right);</p>
  3283. <p class=desc>Adjust the line level outout voltage range, with separate
  3284. settings for left and right. The same settings (13 to 31) are available.
  3285. </p>
  3286. <h3>Signal Conditioning</h3>
  3287. <p>Usually these digital signal conditioning features should be left at their
  3288. default settings.
  3289. </p>
  3290. <p class=func><span class=keyword>adcHighPassFilterFreeze</span>();</p>
  3291. <p class=desc>By default, the analog input (either line-level inputs or mic)
  3292. is high-pass filtered, to remove any DC component. This function
  3293. freezes the filter, so the current DC component is still substracted, but
  3294. the filter stops tracking any DC or low frequency changes.
  3295. </p>
  3296. <p class=func><span class=keyword>adcHighPassFilterDisable</span>();</p>
  3297. <p class=desc>Completely disable the analog input filter. DC and sub-audible
  3298. low frequencies are allowed to enter the digital signal. This
  3299. <a href="http://openaudio.blogspot.com/2017/03/teensy-audio-board-self-noise.html">may
  3300. reduce noise</a> in some cases.
  3301. </p>
  3302. <p class=func><span class=keyword>adcHighPassFilterEnable</span>();</p>
  3303. <p class=desc>Turn the DC-blocking filter back on, if disabled, or
  3304. allows it to resume tracking DC and low frequency changes, if
  3305. previously frozen. This is the default setting.
  3306. </p>
  3307. <p class=func><span class=keyword>dacVolume</span>(both);</p>
  3308. <p class=desc>Normally output volume should be used with volume(), which
  3309. changes the analog gain in the headphone amplifier. This function
  3310. on the other hand controls digital attenuation before conversion to analog, which
  3311. reduces resolution, but allows another fine control of output
  3312. signal level. The ranges is 0 to 1.0, with the default (no digital attenuation)
  3313. at 1.0.
  3314. </p>
  3315. <p class=desc>dacVolume uses zero-crossing detect to avoid clicks, and graceful
  3316. ramping is handled by the chip so that a new volume may be set directly in
  3317. a single call.
  3318. </p>
  3319. <p class=func><span class=keyword>dacVolume</span>(left, right);</p>
  3320. <p class=desc>Adjust the digital output volume separately on left and
  3321. right channels.
  3322. </p>
  3323. <p class=func><span class=keyword>dacVolumeRamp</span>();</p>
  3324. <p class=desc>Enable graceful volume ramping. The dacVolume adjusts gradually using
  3325. an exponential curve. Pops or loud clicks are avoided when making large
  3326. changes in volume level.
  3327. </p>
  3328. <p class=func><span class=keyword>dacVolumeRampLinear</span>();</p>
  3329. <p class=desc>Enable faster volume ramping. A slight click may be heard during a
  3330. large volume change.
  3331. </p>
  3332. <p class=func><span class=keyword>dacVolumeRampDisable</span>();</p>
  3333. <p class=desc>Do not use any gradual ramping. The zero cross feature still helps
  3334. for small changes, but large volume changes may produce a pop or click.
  3335. </p>
  3336. <h3>Audio Processor</h3>
  3337. <p>The optional digital audio processor is capable of implementing
  3338. one or more of: automatic volume control, surround sound control,
  3339. bass enhancement, and tonal adjustments (either a
  3340. simple tone control, or a parametric equalizer, or a graphic equalizer),
  3341. in that order.
  3342. </p>
  3343. <p>These signal processing features are implemented in the SGTL5000 chip,
  3344. so they do not consume CPU time on Teensy. However, the order of
  3345. these processes is fixed in the hardware.
  3346. </p>
  3347. <p>It is good practice to mute the outputs before enabling or disabling
  3348. the Audio Processor, to avoid clicks or thumps.
  3349. </p>
  3350. <p class=func><span class=keyword>audioPreProcessorEnable</span>();</p>
  3351. <p class=desc>Enable the audio processor to pre-process the input
  3352. (from either line-level inputs or microphone) before it's sent
  3353. to Teensy by I2S.
  3354. </p>
  3355. <p class=func><span class=keyword>audioPostProcessorEnable</span>();</p>
  3356. <p class=desc>Enable the audio processor to post-process Teensy's
  3357. I2S output before it's turned into analog signals for the
  3358. headphones and/or line level outputs.
  3359. </p>
  3360. <p class=func><span class=keyword>audioProcessorDisable</span>();</p>
  3361. <p class=desc>Disable the audio processor.
  3362. </p>
  3363. <p class=func><span class=keyword>autoVolumeControl</span>(maxGain, response, hardLimit, threshold, attack, decay);</p>
  3364. <p class=desc>Configures the auto volume control, which is implemented as a compressor/expander
  3365. or hard limiter. <em>maxGain</em> is the maximum gain that can be applied for expanding, and
  3366. can take one of three values: 0 (0dB), 1 (6.0dB) and 2 (12dB). Values greater than 2 are treated
  3367. as 2. <em>response</em> controls the integration time for the compressor and can take
  3368. four values: 0 (0ms), 1 (25ms), 2 (50ms) or 3 (100ms). Larger values average the volume
  3369. over a longer time, allowing short-term peaks through.
  3370. </p>
  3371. <p class=desc>If <em>hardLimit</em> is 0, a 'soft
  3372. knee' compressor is used to progressively compress louder values which are near to or above the
  3373. threashold (the louder they are, the greater the compression). If it is 1, a hard compressor
  3374. is used (all values above the threashold are the same loudness). The <em>threashold</em> is specified
  3375. as a float in the range 0dBFS to -96dBFS, where -18dBFS is a typical value.
  3376. <em>attack</em> is a float controlling the rate of decrease in gain when the signal is over
  3377. threashold, in dB/s. <em>decay</em> controls how fast gain is restored once the level
  3378. drops below threashold, again in dB/s. It is typically set to a longer value than attack.
  3379. </p>
  3380. <p class=func><span class=keyword>autoVolumeEnable</span>();</p>
  3381. <p class=desc>Enables auto volume control, using the previously specified settings.
  3382. </p>
  3383. <p class=func><span class=keyword>autoVolumeDisable</span>();</p>
  3384. <p class=desc>Disables auto volume control.
  3385. </p>
  3386. <p class=func><span class=keyword>surroundSoundEnable</span>();</p>
  3387. <p class=desc>Enable virtual surround processing, to give a broader and
  3388. deeper stereo image (even with mono input).
  3389. </p>
  3390. <p class=func><span class=keyword>surroundSoundDisable</span>();</p>
  3391. <p class=desc>Disable virtual surround processing. Before disabling, ramp up
  3392. the width to maximum to avoid pops.
  3393. </p>
  3394. <p class=func><span class=keyword>surroundSound</span>(width);</p>
  3395. <p class=desc>Configures virtual surround width from 0 (mono) to 7 (widest).
  3396. </p>
  3397. <p class=func><span class=keyword>surroundSound</span>(width, select);</p>
  3398. <p class=desc>Configures virtual surround width from 0 (mono) to 7 (widest).
  3399. <em>select</em> may be set to 1 (disable), 2 (mono input) or 3 (stereo input).
  3400. </p>
  3401. <p class=func><span class=keyword>enhanceBassEnable</span>();</p>
  3402. <p class=desc>Enable bass enhancement. A mono, low-pass filtered copy of
  3403. the original stereo signal has bass levels boosted and is then mixed back into
  3404. the stereo signal, which is then optionally high pass filtered (to remove
  3405. inaudible subsonic frequencies).
  3406. </p>
  3407. <p class=func><span class=keyword>enhanceBassDisable</span>();</p>
  3408. <p class=desc>Disable bass enhancement. Before disabling, ramp down the bass
  3409. enhancement level to zero.
  3410. </p>
  3411. <p class=func><span class=keyword>enhanceBass</span>(lr_lev, bass_lev);</p>
  3412. <p class=desc>Configures the bass enhancement by setting the levels of the
  3413. original stereo signal and the bass-enhanced mono level which will be mixed together.
  3414. There is no high-pass filter.
  3415. </p>
  3416. <p class=desc>When changing bass level, call this function repeatedly to ramp up or down the bass in
  3417. steps of 0.5dB, to avoid pops.
  3418. </p>
  3419. <p class=func><span class=keyword>enhanceBass</span>(lr_lev, bass_lev, hpf_bypass, cutoff);</p>
  3420. <p class=desc>Configures the bass enhancement by setting the levels of the
  3421. original stereo signal and the bass-enhanced mono level which will be mixed together.
  3422. The high-pass filter may be enabled (0) or bypassed (1). The cutoff frequency is specified
  3423. as follows:
  3424. </p>
  3425. <pre class="desc">
  3426. value frequency
  3427. 0 80Hz
  3428. 1 100Hz
  3429. 2 125Hz
  3430. 3 150Hz
  3431. 4 175Hz
  3432. 5 200Hz
  3433. 6 225Hz
  3434. </pre>
  3435. <p class=desc>When changing bass level, call this function repeatedly to ramp up or down the bass in
  3436. steps of 0.5dB, to avoid pops.
  3437. </p>
  3438. <p class=func><span class=keyword>eqSelect</span>(n);</p>
  3439. <p class=desc>Selects the type of frequency control, where <em>n</em> is
  3440. one of</p>
  3441. <p class=desc><b>FLAT_FREQUENCY (0)</b><br>
  3442. Equalizers and tone controls disabled, flat frequency response.</p>
  3443. <p class=desc><b>PARAMETRIC_EQUALIZER (1)</b><br>
  3444. Enables the 7-band parametric equalizer, thus disabling the
  3445. tone controls and graphic equalizer.</p>
  3446. <p class=desc><b>TONE_CONTROLS (2)</b><br>
  3447. Enables bass and treble tone controls, disabling the parametric
  3448. equalization and graphic equalizer.</p>
  3449. <p class=desc><b>GRAPHIC_EQUALIZER (3)</b><br>
  3450. Enables the five-band graphic equalizer, disabling the parametric
  3451. equalization and tone controls.</p>
  3452. <p class=func><span class=keyword>eqBands</span>(bass, treble);</p>
  3453. <p class=desc>Configures bass and treble tone controls, which are
  3454. implemented as one second order low pass filter (bass) in parallel with
  3455. one second order high pass filter (treble).
  3456. </p>
  3457. <p class=desc>When changing bass or treble level, call this function repeatedly to ramp
  3458. up or down the level in steps of 0.04 (=0.5dB) or so, to avoid pops.
  3459. </p>
  3460. <p class=func><span class=keyword>eqBands</span>(bass, mid_bass, midrange, mid_treble, treble);</p>
  3461. <p class=desc>Configures the graphic equalizer. It is implemented by five parallel,
  3462. second order biquad filters with fixed frequencies of 115Hz, 330Hz, 990Hz, 3kHz,
  3463. and 9.9kHz. Each band has a range of adjustment from 1.00 (+12dB) to -1.00 (-11.75dB).
  3464. </p>
  3465. <p class=func><span class=keyword>eqBand</span>(bandNum, n);</p>
  3466. <p class=desc>Configures the gain or cut on one band in the graphic equalizer.
  3467. <em>bandnum</em> can range from 1 to 5; <em>n</em> is a float in the range 1.00 to -1.00.
  3468. </p>
  3469. <p class=desc>When changing a band, call this function repeatedly to ramp up the gain in steps of 0.5dB,
  3470. to avoid pops.
  3471. </p>
  3472. <p class=func><span class=keyword>eqFilter</span>(filterNum, filterParameters);</p>
  3473. <p class=desc>Configurs the parametric equalizer. The number of filters (1 to 7)
  3474. is specified along with a pointer to an array of filter coefficients.
  3475. The parametric equalizer is implemented using 7 cascaded, second order bi-quad
  3476. filters whose frequencies, gain, and Q may be freely configured, but each filter
  3477. can only be specified as a set of filter coefficients.
  3478. </p>
  3479. <p class=func><span class=keyword>eqFilterCount</span>(n);</p>
  3480. <p class=desc>Enables zero or more of the already enabled parametric filters.
  3481. </p>
  3482. <h3>Examples</h3>
  3483. <p>Nearly all of the library's examples use this object. These
  3484. examples demonstrate its special features.
  3485. </p>
  3486. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; PassThroughStereo
  3487. </p>
  3488. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; dap_bass_enhance
  3489. </p>
  3490. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; dap_avc_agc
  3491. </p>
  3492. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; balanceDAC
  3493. </p>
  3494. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; balanceHP
  3495. </p>
  3496. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; CalcBiquadToneControlDAP
  3497. </p>
  3498. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; SGTL5000 &gt; VolumeRamp
  3499. </p>
  3500. <h3>Notes</h3>
  3501. <p>TODO: add example with rock/classical/speech presets, where rock uses bass boost
  3502. and surround enhancement while speech uses bandpass filtering and auto volume control
  3503. compression.
  3504. </p>
  3505. <p>TODO: add example with two analogRead pots for bass and treble to demonstrate ramping.
  3506. </p>
  3507. </script>
  3508. <script type="text/x-red" data-template-name="AudioControlSGTL5000">
  3509. <div class="form-row">
  3510. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3511. <input type="text" id="node-input-name" placeholder="Name">
  3512. </div>
  3513. </script>
  3514. <script type="text/x-red" data-help-name="AudioControlWM8731">
  3515. <h3>Summary</h3>
  3516. <div class=tooltipinfo>
  3517. <p>Control a WM8731 chip in slave mode, where it receives all clocks from Teensy</p>
  3518. </div>
  3519. <h3>Audio Connections</h3>
  3520. <p>This object has no audio inputs or outputs. Separate i2s objects
  3521. are used to send and receive audio data. I2S master mode objects
  3522. must be used, since this control object configures the WM8731 into
  3523. slave mode.
  3524. </p>
  3525. <h3>Functions</h3>
  3526. <p class=func><span class=keyword>enable</span>();</p>
  3527. <p class=desc>blah blah blah blah
  3528. </p>
  3529. <p class=func><span class=keyword>disable</span>();</p>
  3530. <p class=desc>not implemented
  3531. </p>
  3532. <p class=func><span class=keyword>volume</span>(level);</p>
  3533. <p class=desc>blah blah blah blah
  3534. </p>
  3535. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  3536. <p class=desc>not implemented
  3537. </p>
  3538. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  3539. <p class=desc>not implemented
  3540. </p>
  3541. <!--
  3542. <h3>Examples</h3>
  3543. <p class=exam>File &gt; Examples &gt; Audio &gt;
  3544. </p>
  3545. -->
  3546. <h3>Notes</h3>
  3547. <p></p>
  3548. </script>
  3549. <script type="text/x-red" data-template-name="AudioControlWM8731">
  3550. <div class="form-row">
  3551. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3552. <input type="text" id="node-input-name" placeholder="Name">
  3553. </div>
  3554. </script>
  3555. <script type="text/x-red" data-help-name="AudioControlWM8731master">
  3556. <h3>Summary</h3>
  3557. <div class=tooltipinfo>
  3558. <p>Control a WM8731 chip in master mode, where it controls all I2S timing.</p>
  3559. </div>
  3560. <h3>Audio Connections</h3>
  3561. <p>This object has no audio inputs or outputs. Separate i2s objects
  3562. are used to send and receive audio data. I2S slave mode objects
  3563. must be used, since this control object configures the WM8731 into
  3564. master mode.
  3565. </p>
  3566. <h3>Functions</h3>
  3567. <p class=func><span class=keyword>enable</span>();</p>
  3568. <p class=desc>blah blah blah blah
  3569. </p>
  3570. <p class=func><span class=keyword>disable</span>();</p>
  3571. <p class=desc>not implemented
  3572. </p>
  3573. <p class=func><span class=keyword>volume</span>(level);</p>
  3574. <p class=desc>blah blah blah blah
  3575. </p>
  3576. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  3577. <p class=desc>not implemented
  3578. </p>
  3579. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  3580. <p class=desc>not implemented
  3581. </p>
  3582. <h3>Examples</h3>
  3583. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; WM8731MikroSine
  3584. </p>
  3585. <h3>Notes</h3>
  3586. <p></p>
  3587. </script>
  3588. <script type="text/x-red" data-template-name="AudioControlWM8731master">
  3589. <div class="form-row">
  3590. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3591. <input type="text" id="node-input-name" placeholder="Name">
  3592. </div>
  3593. </script>
  3594. <script type="text/x-red" data-help-name="AudioControlAK4558">
  3595. <h3>Summary</h3>
  3596. <div class=tooltipinfo>
  3597. <p>Control the AK4558 chip on the <a href="https://hackaday.io/project/8567-hifi-audio-codec-module" target="_blank">HiFi Audio CODEC Module</a>
  3598. in slave mode, where the Teensy controls all I2S timing.</p>
  3599. </div>
  3600. <h3>Audio Connections</h3>
  3601. <p>This object has no audio inputs or outputs. Separate I2S objects
  3602. are used to send and receive audio data.
  3603. </p>
  3604. <h3>Functions</h3>
  3605. <p class=func><span class=keyword>enable</span>();</p>
  3606. <p class=desc>Enables the CODEC to work with 44.1 KHz - 16 bit data. This function does not enable the ADC/DAC modules.
  3607. </p>
  3608. <p class=func><span class=keyword>enableIn</span>();</p>
  3609. <p class=desc>Enables the ADC module.
  3610. </p>
  3611. <p class=func><span class=keyword>enableOut</span>();</p>
  3612. <p class=desc>Enables the DAC module.
  3613. </p>
  3614. <p class=func><span class=keyword>disable</span>();</p>
  3615. <p class=desc>Disables the ADC and the DAC modules.
  3616. </p>
  3617. <p class=func><span class=keyword>disableIn</span>();</p>
  3618. <p class=desc>Disable the ADC module.
  3619. </p>
  3620. <p class=func><span class=keyword>disableOut</span>();</p>
  3621. <p class=desc>Disable the DAC module.
  3622. </p>
  3623. <p class=func><span class=keyword>volume</span>(level);</p>
  3624. <p class=desc>Accepts a float in range 0.0-1.0 and sets the line output volume accordingly.
  3625. </p>
  3626. <p class=func><span class=keyword>volumeLeft</span>(level);</p>
  3627. <p class=desc>Accepts a float in range 0.0-1.0 and sets the left line output volume accordingly.
  3628. </p>
  3629. <p class=func><span class=keyword>volumeRight</span>(level);</p>
  3630. <p class=desc>Accepts a float in range 0.0-1.0 and sets the right line output volume accordingly.
  3631. </p>
  3632. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  3633. <p class=desc>NOT SUPPORTED BY THE AK4558
  3634. </p>
  3635. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  3636. <p class=desc>not implemented yet
  3637. </p>
  3638. <h3>Examples</h3>
  3639. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; AK4558 &gt; PassthroughTest
  3640. </p>
  3641. <p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; AK4558 &gt; SineOutTest
  3642. </p>
  3643. <h3>Notes</h3>
  3644. <p>TODO: Implement inputSelect() function to enable mono left, mono right, stereo operation.</p>
  3645. <p>TODO: Implement ADC and DAC filters control.</p>
  3646. <p>TODO: Implement DAC level attenuator attack rate modifier.</p>
  3647. </script>
  3648. <script type="text/x-red" data-template-name="AudioControlAK4558">
  3649. <div class="form-row">
  3650. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3651. <input type="text" id="node-input-name" placeholder="Name">
  3652. </div>
  3653. </script>
  3654. <script type="text/x-red" data-help-name="AudioControlCS4272">
  3655. <h3>Summary</h3>
  3656. <div class=tooltipinfo>
  3657. <p>Control the CS4272 chip on the <a href="https://hackaday.io/project/5912-teensy-super-audio-board" target="_blank">Super Audio Board</a>.
  3658. </p>
  3659. <p>TODO: does this control object put the CS4272 into I2S master or slave mode</p>
  3660. </div>
  3661. <h3>Audio Connections</h3>
  3662. <p>This object has no audio inputs or outputs. Separate I2S objects
  3663. are used to send and receive audio data.
  3664. </p>
  3665. <h3>Functions</h3>
  3666. <p class=func><span class=keyword>enable</span>();</p>
  3667. <p class=desc>Enables the CODEC to work with 44.1 KHz - 16 bit data. This function does not enable the ADC/DAC modules.
  3668. </p>
  3669. <p class=func><span class=keyword>volume</span>(vol);</p>
  3670. <p class=desc>Set the volume level. Range is 0 to 1.0.
  3671. </p>
  3672. <p class=func><span class=keyword>volume</span>(left, right);</p>
  3673. <p class=desc>Set the volume level. Range is 0 to 1.0.
  3674. </p>
  3675. <p class=func><span class=keyword>dacVolume</span>(vol);</p>
  3676. <p class=desc>Set the volume level. Range is 0 to 1.0. TODO: what's the
  3677. distinction between volume() and dacVolume()?
  3678. </p>
  3679. <p class=func><span class=keyword>dacVolume</span>(left, right);</p>
  3680. <p class=desc>Set the volume level. Range is 0 to 1.0.
  3681. </p>
  3682. <p class=func><span class=keyword>muteOutput</span>();</p>
  3683. <p class=desc>TODO: description
  3684. </p>
  3685. <p class=func><span class=keyword>unmuteOutput</span>();</p>
  3686. <p class=desc>TODO: description
  3687. </p>
  3688. <p class=func><span class=keyword>muteInput</span>();</p>
  3689. <p class=desc>TODO: description
  3690. </p>
  3691. <p class=func><span class=keyword>unmuteInput</span>();</p>
  3692. <p class=desc>TODO: description
  3693. </p>
  3694. <p class=func><span class=keyword>enableDither</span>();</p>
  3695. <p class=desc>TODO: description
  3696. </p>
  3697. <p class=func><span class=keyword>disableDither</span>();</p>
  3698. <p class=desc>TODO: description
  3699. </p>
  3700. <h3>Hardware</h3>
  3701. <p>Pin 2 must be connected to the CS4272 reset. SDA &amp; SCL are used for all control.
  3702. </p>
  3703. <h3>Notes</h3>
  3704. </script>
  3705. <script type="text/x-red" data-template-name="AudioControlCS4272">
  3706. <div class="form-row">
  3707. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3708. <input type="text" id="node-input-name" placeholder="Name">
  3709. </div>
  3710. </script>
  3711. <script type="text/x-red" data-help-name="AudioControlCS42448">
  3712. <h3>Summary</h3>
  3713. <div class=tooltipinfo>
  3714. <p>Control the CS42448 chip in TDM mode, for 6 inputs and 8 outputs.
  3715. </p>
  3716. <p align=center><img src="img/cs42448.jpg"></p>
  3717. </div>
  3718. </div>
  3719. <h3>Audio Connections</h3>
  3720. <p>This object has no audio inputs or outputs. Separate TDM objects
  3721. are used to send and receive audio data.
  3722. </p>
  3723. <h3>Functions</h3>
  3724. <p class=func><span class=keyword>enable</span>();</p>
  3725. <p class=desc>Enables the CS42448 to work in TDM mode.
  3726. </p>
  3727. <p class=func><span class=keyword>volume</span>(level);</p>
  3728. <p class=desc>Set the volume level for all output channels. Range is 0 to 1.0.
  3729. </p>
  3730. <p class=func><span class=keyword>volume</span>(channel, level);</p>
  3731. <p class=desc>Set the volume level for a single output. Channel is 1 to 8. Range is 0 to 1.0.
  3732. </p>
  3733. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  3734. <p class=desc>Set the input gain level for all input channels. Range is 0 to 15.85.
  3735. </p>
  3736. <p class=func><span class=keyword>inputLevel</span>(channel, level);</p>
  3737. <p class=desc>Set the input gain level for a single input. Channel is 1 to 6. Range is 0 to 15.85.
  3738. </p>
  3739. <h3>Hardware</h3>
  3740. <p>Tested with this <a href="https://oshpark.com/shared_projects/2Yj6rFaW">
  3741. CS42448 Circuit Board</a>.
  3742. </p>
  3743. <p align=center><img src="img/tdm.jpg"></p>
  3744. </div>
  3745. <h3>Notes</h3>
  3746. </script>
  3747. <script type="text/x-red" data-template-name="AudioControlCS42448">
  3748. <div class="form-row">
  3749. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  3750. <input type="text" id="node-input-name" placeholder="Name">
  3751. </div>
  3752. </script>
  3753. </body>
  3754. </html>