Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

3460 lines
153KB

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