您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

3451 行
152KB

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