Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

2514 lines
95KB

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