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

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