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

index.html 143KB

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