No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

2095 líneas
75KB

  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>Notes</h3>
  46. <p>Normally, this object is used with the Audio Shield, which
  47. is controlled separately by the "sgtl5000" object.</p>
  48. <p>Only one I2S input and one I2S output object may be used. Master
  49. and slave modes may not be mixed (both must be of the same type).
  50. </p>
  51. <p>I2S master objects can be used together with non-I2S input and output
  52. objects, for simultaneous audio streaming on different hardware.</p>
  53. </script>
  54. <script type="text/x-red" data-template-name="AudioInputI2S">
  55. <div class="form-row">
  56. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  57. <input type="text" id="node-input-name" placeholder="Name">
  58. </div>
  59. </script>
  60. <script type="text/javascript">
  61. RED.nodes.registerType('AudioInputI2Sslave',{
  62. shortName: "i2ss",
  63. inputs:0,
  64. outputs:2,
  65. category: 'input-function',
  66. color:"#E6E0F8",
  67. icon: "arrow-in.png"
  68. });
  69. </script>
  70. <script type="text/x-red" data-help-name="AudioInputI2Sslave">
  71. <h3>Summary</h3>
  72. <p>Receive 16 bit stereo audio from an I2S device using I2S slave mode.</p>
  73. <h3>Audio Connections</h3>
  74. <table class=doc align=center cellpadding=3>
  75. <tr class=top><th>Port</th><th>Purpose</th></tr>
  76. <tr class=odd><td align=center>Out 0</td><td>Left Channel</td></tr>
  77. <tr class=odd><td align=center>Out 1</td><td>Right Channel</td></tr>
  78. </table>
  79. <h3>Functions</h3>
  80. <p>This object has no functions to call from the Arduino sketch. It
  81. simply streams data from the I2S hardware to its 2 output ports.</p>
  82. <h3>Hardware</h3>
  83. <p>The I2S signals are used in "slave" mode, where the I2S device controls
  84. data timing.</p>
  85. <table class=doc align=center cellpadding=3>
  86. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  87. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Input</td></tr>
  88. <tr class=odd><td align=center>13</td><td>RX</td><td>Input</td></tr>
  89. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Input</td></tr>
  90. </table>
  91. <h3>Notes</h3>
  92. <p>Slave mode I2S <b>should not used in the same project as ADC, DAC and
  93. PWM</b> signals. Differences in timing between the I2S device and
  94. Teensy's clock can cause occasional audio glitches when I2S slave mode
  95. is used together with other input or output objects based on Teensy's
  96. timing.</p>
  97. <p>Only one I2S input and one I2S output object may be used. Master
  98. and slave modes may not be mixed (both must be of the same type).
  99. </p>
  100. </script>
  101. <script type="text/x-red" data-template-name="AudioInputI2Sslave">
  102. <div class="form-row">
  103. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  104. <input type="text" id="node-input-name" placeholder="Name">
  105. </div>
  106. </script>
  107. <script type="text/javascript">
  108. RED.nodes.registerType('AudioInputADC',{
  109. shortName: "adc",
  110. inputs:0,
  111. outputs:1,
  112. category: 'input-function',
  113. color:"#E6E0F8",
  114. icon: "arrow-in.png"
  115. });
  116. </script>
  117. <script type="text/x-red" data-help-name="AudioInputADC">
  118. <h3>Summary</h3>
  119. <p>Receive audio using the built-in analog to digital converter.</p>
  120. <h3>Audio Connections</h3>
  121. <table class=doc align=center cellpadding=3>
  122. <tr class=top><th>Port</th><th>Purpose</th></tr>
  123. <tr class=odd><td align=center>Out 0</td><td>Audio Channel</td></tr>
  124. </table>
  125. <h3>Parameters</h3>
  126. <table class=doc align=center cellpadding=3>
  127. <tr class=top><th>Name</th><th>Type</th><th>Function</th></tr>
  128. <tr class=odd><td align=center>Pin</td><td>Integer</td><td>Analog Pin To Use</td></tr>
  129. </table>
  130. <p>The pin number should be specified as "A0" to "A20"</p>
  131. <p align=center><img src="adcpins2.jpg"></p>
  132. <p align=center><img src="adcpins1.jpg"></p>
  133. <h3>Functions</h3>
  134. <p>This object has no functions to call from the Arduino sketch. It
  135. simply streams data from the ADC to its output port.</p>
  136. <h3>Hardware</h3>
  137. <p>Signal range is 0 to 1.2V</p>
  138. <p>Need for DC bias, approx 0.6V</p>
  139. <p>TODO: suggested circuity for signal input</p>
  140. <h3>Notes</h3>
  141. <p>Algorithm for automatic DC bias tracking</p>
  142. <p>Noise due to high source impedance</p>
  143. <p>Power Supply rejection issue with simple DC bias</p>
  144. <p>TODO: actual noise measurements with different input circuitry
  145. (it's not nearly as quiet as the audio shield)</p>
  146. </script>
  147. <script type="text/x-red" data-template-name="AudioInputADC">
  148. <div class="form-row">
  149. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  150. <input type="text" id="node-input-name" placeholder="Name">
  151. </div>
  152. </script>
  153. <script type="text/javascript">
  154. RED.nodes.registerType('AudioOutputI2S',{
  155. shortName: "i2s",
  156. inputs:2,
  157. outputs:0,
  158. category: 'output-function',
  159. color:"#E6E0F8",
  160. icon: "arrow-in.png"
  161. });
  162. </script>
  163. <script type="text/x-red" data-help-name="AudioOutputI2S">
  164. <h3>Summary</h3>
  165. <p>Transmit 16 bit stereo audio to the
  166. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  167. or another I2S device, using I2S master mode.</p>
  168. <p align=center><img src="audioshield_outputs.jpg"></p>
  169. <h3>Audio Connections</h3>
  170. <table class=doc align=center cellpadding=3>
  171. <tr class=top><th>Port</th><th>Purpose</th></tr>
  172. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  173. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  174. </table>
  175. <h3>Functions</h3>
  176. <p>This object has no functions to call from the Arduino sketch. It
  177. simply streams data from its 2 input ports to the I2S hardware.</p>
  178. <h3>Hardware</h3>
  179. <p align=center><img src="audioshield_backside.jpg"></p>
  180. <p>The I2S signals are used in "master" mode, where Teensy creates
  181. all 3 clock signals and controls all data timing.</p>
  182. <table class=doc align=center cellpadding=3>
  183. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  184. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Output</td></tr>
  185. <tr class=odd><td align=center>11</td><td>MCLK</td><td>Output</td></tr>
  186. <tr class=odd><td align=center>22</td><td>TX</td><td>Output</td></tr>
  187. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Output</td></tr>
  188. </table>
  189. <p>Audio from
  190. master mode I2S may be used in the same project as ADC, DAC and
  191. PWM signals, because all remain in sync to Teensy's timing</p>
  192. <h3>Notes</h3>
  193. <p>Normally, this object is used with the Audio Shield, which
  194. is controlled separately by the "sgtl5000" object.</p>
  195. <p>Only one I2S input and one I2S output object may be used. Master
  196. and slave modes may not be mixed (both must be of the same type).
  197. </p>
  198. </script>
  199. <script type="text/x-red" data-template-name="AudioOutputI2S">
  200. <div class="form-row">
  201. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  202. <input type="text" id="node-input-name" placeholder="Name">
  203. </div>
  204. </script>
  205. <script type="text/javascript">
  206. RED.nodes.registerType('AudioOutputI2Sslave',{
  207. shortName: "i2ss",
  208. inputs:2,
  209. outputs:0,
  210. category: 'output-function',
  211. color:"#E6E0F8",
  212. icon: "arrow-in.png"
  213. });
  214. </script>
  215. <script type="text/x-red" data-help-name="AudioOutputI2Sslave">
  216. <h3>Summary</h3>
  217. <p>Transmit 16 bit stereo audio to an I2S device using I2S slave mode.</p>
  218. <h3>Audio Connections</h3>
  219. <table class=doc align=center cellpadding=3>
  220. <tr class=top><th>Port</th><th>Purpose</th></tr>
  221. <tr class=odd><td align=center>In 0</td><td>Left Channel</td></tr>
  222. <tr class=odd><td align=center>In 1</td><td>Right Channel</td></tr>
  223. </table>
  224. <h3>Functions</h3>
  225. <p>This object has no functions to call from the Arduino sketch. It
  226. simply streams data from its 2 input ports to the I2S hardware.</p>
  227. <h3>Hardware</h3>
  228. <p>The I2S signals are used in "slave" mode, where the I2S device controls
  229. data timing.</p>
  230. <table class=doc align=center cellpadding=3>
  231. <tr class=top><th>Pin</th><th>Signal</th><th>Direction</th></tr>
  232. <tr class=odd><td align=center>9</td><td>BCLK</td><td>Input</td></tr>
  233. <tr class=odd><td align=center>22</td><td>TX</td><td>Output</td></tr>
  234. <tr class=odd><td align=center>23</td><td>LRCLK</td><td>Input</td></tr>
  235. </table>
  236. <h3>Notes</h3>
  237. <p>Slave mode I2S <b>should not used in the same project as ADC, DAC and
  238. PWM</b> signals. Differences in timing between the I2S device and
  239. Teensy's clock can cause occasional audio glitches when I2S slave mode
  240. is used together with other input or output objects based on Teensy's
  241. timing.</p>
  242. <p>Only one I2S input and one I2S output object may be used. Master
  243. and slave modes may not be mixed (both must be of the same type).
  244. </p>
  245. </script>
  246. <script type="text/x-red" data-template-name="AudioOutputI2Sslave">
  247. <div class="form-row">
  248. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  249. <input type="text" id="node-input-name" placeholder="Name">
  250. </div>
  251. </script>
  252. <script type="text/javascript">
  253. RED.nodes.registerType('AudioOutputAnalog',{
  254. shortName: "dac",
  255. inputs:1,
  256. outputs:0,
  257. category: 'output-function',
  258. color:"#E6E0F8",
  259. icon: "arrow-in.png"
  260. });
  261. </script>
  262. <script type="text/x-red" data-help-name="AudioOutputAnalog">
  263. <h3>Summary</h3>
  264. <p>Transmit 12 bit audio using Teensy 3.1's built-in digital to analog converter.</p>
  265. <h3>Audio Connections</h3>
  266. <table class=doc align=center cellpadding=3>
  267. <tr class=top><th>Port</th><th>Purpose</th></tr>
  268. <tr class=odd><td align=center>In 0</td><td>Audio Channel</td></tr>
  269. </table>
  270. <h3>Functions</h3>
  271. <p>This object has no functions to call from the Arduino sketch. It
  272. simply streams data from the ADC to its output port.</p>
  273. <h3>Hardware</h3>
  274. <p align=center><img src="dacpin.jpg"></p>
  275. <p>Signal range is 0 to 1.2V</p>
  276. <p>Most applications require at least a 10&micro;F DC-blocking capacitor.</p>
  277. <p>TODO: photo of Teensy 3.1 with 10&micro;F capacitor and 3.5mm jack.</p>
  278. <h3>Notes</h3>
  279. <p>The output rate is 44.1 kHz (no oversampling). Ultrasonic noise present if
  280. not filtered. This may not
  281. be an issue for many uses, but care should be used if amplified and driven
  282. to high power tweeters.</p>
  283. </script>
  284. <script type="text/x-red" data-template-name="AudioOutputAnalog">
  285. <div class="form-row">
  286. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  287. <input type="text" id="node-input-name" placeholder="Name">
  288. </div>
  289. </script>
  290. <script type="text/javascript">
  291. RED.nodes.registerType('AudioOutputPWM',{
  292. shortName: "pwm",
  293. inputs:1,
  294. outputs:0,
  295. category: 'output-function',
  296. color:"#E6E0F8",
  297. icon: "arrow-in.png"
  298. });
  299. </script>
  300. <script type="text/x-red" data-help-name="AudioOutputPWM">
  301. <h3>Summary</h3>
  302. <p>Transmit audio using Teensy 3.1's PWM pins. Two pins are
  303. used for coarse and fine pulses, to be combined by scaled
  304. resistors.</p>
  305. <h3>Audio Connections</h3>
  306. <table class=doc align=center cellpadding=3>
  307. <tr class=top><th>Port</th><th>Purpose</th></tr>
  308. <tr class=odd><td align=center>In 0</td><td>Audio Channel</td></tr>
  309. </table>
  310. <h3>Functions</h3>
  311. <p>This object has no functions to call from the Arduino sketch. It
  312. simply streams data from the its input port to the PWM pins.</p>
  313. <h3>Hardware</h3>
  314. <p>The following circuit is recommended.</p>
  315. <p align=center><img src="pwmdualcircuit.jpg"></p>
  316. <p>Signal range is approx 1.55 Vp-p.</p>
  317. <p>These resistor values assume approx 20 ohms output impedance
  318. on the digital pins. The 127K resistor may be adjusted or
  319. trimmed for variation in output drive and tolerance on the
  320. 475 ohm resistor.</p>
  321. <p>A plastic film (Polypropylene, Polyethylene, Polyester, etc) or
  322. C0G/NPO ceramic capacitor should be used for filtering. Low
  323. quality ceramic (X7R, Y5V, Z5U, etc) can cause signal distortion.</p>
  324. <h3>Notes</h3>
  325. <p>The PWM carrier frequency is 88.2 kHz. The suggested circuit
  326. will only slightly filter the carrier. Extra filtering will be
  327. required for a clean signal without the ultrasonic PWM carrier.
  328. </p>
  329. <p>Analog signals created by filtering PWM waveforms use the digital
  330. power supply as their reference voltage. Any noise on the digital
  331. power line can directly couple to the output signal. The built-in DAC or
  332. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>
  333. should be used when higher quality signals are needed.</p>
  334. </script>
  335. <script type="text/x-red" data-template-name="AudioOutputPWM">
  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('AudioMixer4',{
  343. shortName: "mixer",
  344. inputs:4,
  345. outputs:1,
  346. category: 'mixer-function',
  347. color:"#E6E0F8",
  348. icon: "arrow-in.png"
  349. });
  350. </script>
  351. <script type="text/x-red" data-help-name="AudioMixer4">
  352. <h3>Summary</h3>
  353. <p>Combine up to 4 audio signals together, each with adjustable gain.
  354. All channels support signal attenuation or amplification.</p>
  355. <h3>Audio Connections</h3>
  356. <table class=doc align=center cellpadding=3>
  357. <tr class=top><th>Port</th><th>Purpose</th></tr>
  358. <tr class=odd><td align=center>In 0</td><td>Input signal #1</td></tr>
  359. <tr class=odd><td align=center>In 1</td><td>Input signal #2</td></tr>
  360. <tr class=odd><td align=center>In 2</td><td>Input signal #3</td></tr>
  361. <tr class=odd><td align=center>In 3</td><td>Input signal #4</td></tr>
  362. <tr class=odd><td align=center>Out 0</td><td>Sum of all inputs</td></tr>
  363. </table>
  364. <h3>Functions</h3>
  365. <p class=func><span class=keyword>gain</span>(channel, level);</p>
  366. <p class=desc>Adjust the amplification or attenuation. "channel" must
  367. be 0 to 3. "level" may be any floating point number from 0 to 32767.
  368. 1.0 passes the signal through directly. Level of 0 shuts the channel
  369. off completely. Between 0 to 1.0 attenuates the signal, and above
  370. 1.0 amplifies it. All 4 channels have separate settings.
  371. </p>
  372. <h3>Notes</h3>
  373. <p>Signal clipping can occur when any channel has gain greater than 1.0,
  374. or when multiple signals add together to greater than 1.0.</p>
  375. <p>More than 4 channels may be combined by connecting multiple mixers
  376. in tandem. For example, a 16 channel mixer may be built using 5
  377. mixers, where the fifth mixer combines the outputs of the first 4.
  378. </p>
  379. </script>
  380. <script type="text/x-red" data-template-name="AudioMixer4">
  381. <div class="form-row">
  382. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  383. <input type="text" id="node-input-name" placeholder="Name">
  384. </div>
  385. </script>
  386. <script type="text/javascript">
  387. RED.nodes.registerType('AudioPlayMemory',{
  388. shortName: "playMem",
  389. inputs:0,
  390. outputs:1,
  391. category: 'play-function',
  392. color:"#E6E0F8",
  393. icon: "arrow-in.png"
  394. });
  395. </script>
  396. <script type="text/x-red" data-help-name="AudioPlayMemory">
  397. <h3>Summary</h3>
  398. <p>Play a short sound clip, stored directly in memory.
  399. Data files are created with the
  400. <a href="https://github.com/PaulStoffregen/Audio/tree/master/examples/PlayFromSketch/wav2sketch" target="_blank">wav2sketch program</a>,
  401. and copied to the sketch folder to become part of your sketch.</p>
  402. <h3>Audio Connections</h3>
  403. <table class=doc align=center cellpadding=3>
  404. <tr class=top><th>Port</th><th>Purpose</th></tr>
  405. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  406. </table>
  407. <h3>Functions</h3>
  408. <p class=func><span class=keyword>play</span>(data);</p>
  409. <p class=desc>Begin playing a sound clip. If already playing, the
  410. currently playing clip is stopped and this new data begins
  411. playing from the beginning.
  412. </p>
  413. <p class=func><span class=keyword>stop</span>();</p>
  414. <p class=desc>Stop playing. If not playing, this function has no effect.
  415. </p>
  416. <p class=func><span class=keyword>isPlaying</span>();</p>
  417. <p class=desc>Return true (non-zero) if playing, or false (zero)
  418. when not playing.
  419. </p>
  420. <p class=func><span class=keyword>positionMillis</span>();</p>
  421. <p class=desc>While playing, return the current time offset, in
  422. milliseconds. When not playing, the return from this function
  423. is undefined.
  424. </p>
  425. <p class=func><span class=keyword>lengthMillis</span>();</p>
  426. <p class=desc>Return the total length of the current sound clip,
  427. in milliseconds. When not playing, the return from this function
  428. is undefined.
  429. </p>
  430. <h3>Notes</h3>
  431. <p>TODO: supported sample rates: 11.025, 22.05, 44.1</p>
  432. <p>TODO: ulaw vs uncompressed encoding</p>
  433. <p>Polyphonic playback can be built by creating multiple
  434. objects, with their output combined by mixers.</p>
  435. </script>
  436. <script type="text/x-red" data-template-name="AudioPlayMemory">
  437. <div class="form-row">
  438. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  439. <input type="text" id="node-input-name" placeholder="Name">
  440. </div>
  441. </script>
  442. <script type="text/javascript">
  443. RED.nodes.registerType('AudioPlaySdWav',{
  444. shortName: "playWav",
  445. inputs:0,
  446. outputs:2,
  447. category: 'play-function',
  448. color:"#E6E0F8",
  449. icon: "arrow-in.png"
  450. });
  451. </script>
  452. <script type="text/x-red" data-help-name="AudioPlaySdWav">
  453. <h3>Summary</h3>
  454. <p>Play a WAV file, stored on a SD card.</p>
  455. <h3>Audio Connections</h3>
  456. <table class=doc align=center cellpadding=3>
  457. <tr class=top><th>Port</th><th>Purpose</th></tr>
  458. <tr class=odd><td align=center>Out 0</td><td>Left Channel Output</td></tr>
  459. <tr class=odd><td align=center>Out 1</td><td>Right Channel Output</td></tr>
  460. </table>
  461. <h3>Functions</h3>
  462. <p class=func><span class=keyword>play</span>(filename);</p>
  463. <p class=desc>Begin playing a WAV file. If a file is already playing,
  464. it is stopped and this file starts playing from the beginning.
  465. </p>
  466. <p class=func><span class=keyword>stop</span>();</p>
  467. <p class=desc>Stop playing. If not playing, this function has no effect.
  468. </p>
  469. <p class=func><span class=keyword>isPlaying</span>();</p>
  470. <p class=desc>Return true (non-zero) if playing, or false (zero)
  471. when not playing. See the note below about delayed start.
  472. </p>
  473. <p class=func><span class=keyword>positionMillis</span>();</p>
  474. <p class=desc>While playing, return the current time offset, in
  475. milliseconds. When not playing, the return from this function
  476. is undefined.
  477. </p>
  478. <p class=func><span class=keyword>lengthMillis</span>();</p>
  479. <p class=desc>Return the total length of the current sound clip,
  480. in milliseconds. When not playing, the return from this function
  481. is undefined.
  482. </p>
  483. <h3>Notes</h3>
  484. <p>Only 16 bit PCM, 44100 Hz WAV files are supported. When mono
  485. files are played, both output ports transmit a copy of the
  486. single sound. Of course, stereo WAV files play with the left
  487. channel on port 0 and the right channel on port 1.
  488. </p>
  489. <p>A brief delay after calling play() will usually occur before
  490. isPlaying() returns true and positionMillis() returns valid
  491. time offset. WAV files have a header at the beginning of the
  492. file, which the audio library must read and parse before
  493. playing can begin.
  494. </p>
  495. <p>While playing, the audio library accesses the SD card automatically.
  496. If card access is required, you must
  497. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">use AudioNoInterrupts()</a>
  498. to prevent the library from accessing the SD card while you use it.
  499. Disabling the audio library interrupt for too long may cause audible
  500. dropouts or glitches.
  501. </p>
  502. </script>
  503. <script type="text/x-red" data-template-name="AudioPlaySdWav">
  504. <div class="form-row">
  505. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  506. <input type="text" id="node-input-name" placeholder="Name">
  507. </div>
  508. </script>
  509. <script type="text/javascript">
  510. RED.nodes.registerType('AudioPlaySdRaw',{
  511. shortName: "playRaw",
  512. inputs:0,
  513. outputs:1,
  514. category: 'play-function',
  515. color:"#E6E0F8",
  516. icon: "arrow-in.png"
  517. });
  518. </script>
  519. <script type="text/x-red" data-help-name="AudioPlaySdRaw">
  520. <h3>Summary</h3>
  521. <p>Play a RAW data file, stored on a SD card. RAW format is simpler
  522. than WAV and begins playing immediately, without parsing WAV file
  523. header info.</p>
  524. <h3>Audio Connections</h3>
  525. <table class=doc align=center cellpadding=3>
  526. <tr class=top><th>Port</th><th>Purpose</th></tr>
  527. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  528. </table>
  529. <h3>Functions</h3>
  530. <p class=func><span class=keyword>play</span>(filename);</p>
  531. <p class=desc>Begin playing a RAW data file. If a file is already playing,
  532. it is stopped and this file starts playing from the beginning.
  533. </p>
  534. <p class=func><span class=keyword>stop</span>();</p>
  535. <p class=desc>Stop playing. If not playing, this function has no effect.
  536. </p>
  537. <p class=func><span class=keyword>isPlaying</span>();</p>
  538. <p class=desc>Return true (non-zero) if playing, or false (zero)
  539. when not playing.
  540. </p>
  541. <p class=func><span class=keyword>positionMillis</span>();</p>
  542. <p class=desc>While playing, return the current time offset, in
  543. milliseconds. When not playing, the return from this function
  544. is undefined.
  545. </p>
  546. <p class=func><span class=keyword>lengthMillis</span>();</p>
  547. <p class=desc>Return the total length of the current sound clip,
  548. in milliseconds. When not playing, the return from this function
  549. is undefined.
  550. </p>
  551. <h3>Notes</h3>
  552. <p>The data file must be RAW 16 bit signed integers in LSB-first format.
  553. </p>
  554. <p>While playing, the audio library accesses the SD card automatically.
  555. If card access is required, you must
  556. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  557. to prevent the library from accessing the SD card while you use it.
  558. Disabling the audio library interrupt for too long may cause audible
  559. dropouts or glitches.
  560. </p>
  561. </script>
  562. <script type="text/x-red" data-template-name="AudioPlaySdRaw">
  563. <div class="form-row">
  564. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  565. <input type="text" id="node-input-name" placeholder="Name">
  566. </div>
  567. </script>
  568. <script type="text/javascript">
  569. RED.nodes.registerType('AudioPlayQueue',{
  570. shortName: "queue",
  571. inputs:0,
  572. outputs:1,
  573. category: 'play-function',
  574. color:"#E6E0F8",
  575. icon: "arrow-in.png"
  576. });
  577. </script>
  578. <script type="text/x-red" data-help-name="AudioPlayQueue">
  579. <h3>Summary</h3>
  580. <p>Play audio data provided by the Arduino sketch. This object provides
  581. functions to allow the sketch code to push data into the audio system.</p>
  582. <h3>Audio Connections</h3>
  583. <table class=doc align=center cellpadding=3>
  584. <tr class=top><th>Port</th><th>Purpose</th></tr>
  585. <tr class=odd><td align=center>Out 0</td><td>Sound Output</td></tr>
  586. </table>
  587. <h3>Functions</h3>
  588. <p class=func><span class=keyword>play</span>(int16);</p>
  589. <p class=desc>not yet implemented
  590. </p>
  591. <p class=func><span class=keyword>play</span>(int16[], length);</p>
  592. <p class=desc>not yet implemented
  593. </p>
  594. <p class=func><span class=keyword>getBuffer</span>();</p>
  595. <p class=desc>Returns a pointer to an array of 128 int16. This buffer
  596. is within the audio library memory pool, providing the most efficient
  597. way to input data to the audio system. The buffer is likely to be
  598. populated by previously used data, so the entire 128 words should be
  599. written before calling playBuffer(). Only a single buffer should be
  600. requested at a time. This function may return NULL if no memory is
  601. available.
  602. </p>
  603. <p class=func><span class=keyword>playBuffer</span>();</p>
  604. <p class=desc>Transmit the buffer previously obtained from getBuffer().
  605. </p>
  606. <h3>Notes</h3>
  607. <p>TODO: many caveats....</p>
  608. <p>
  609. </p>
  610. </script>
  611. <script type="text/x-red" data-template-name="AudioPlayQueue">
  612. <div class="form-row">
  613. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  614. <input type="text" id="node-input-name" placeholder="Name">
  615. </div>
  616. </script>
  617. <script type="text/javascript">
  618. RED.nodes.registerType('AudioSynthWaveformSine',{
  619. shortName: "sine",
  620. inputs:0,
  621. outputs:1,
  622. category: 'synth-function',
  623. color:"#E6E0F8",
  624. icon: "arrow-in.png"
  625. });
  626. </script>
  627. <script type="text/x-red" data-help-name="AudioSynthWaveformSine">
  628. <h3>Summary</h3>
  629. <p>Create a sine wave signal</p>
  630. <h3>Audio Connections</h3>
  631. <table class=doc align=center cellpadding=3>
  632. <tr class=top><th>Port</th><th>Purpose</th></tr>
  633. <tr class=odd><td align=center>Out 0</td><td>Sine Wave Output</td></tr>
  634. </table>
  635. <h3>Functions</h3>
  636. <p class=func><span class=keyword>amplitude</span>(level);</p>
  637. <p class=desc>Set the amplitude, from 0 to 1.0.
  638. </p>
  639. <p class=func><span class=keyword>frequency</span>(freq);</p>
  640. <p class=desc>Set the frequency, from 0 to 22000. Very low values may
  641. be used to create a LFO (Low Frequency Oscillator) for objects
  642. with modulation signal inputs.
  643. </p>
  644. <p class=func><span class=keyword>phase</span>(angle);</p>
  645. <p class=desc>
  646. Cause the generated waveform to jump to a specific point within
  647. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  648. are configured,
  649. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  650. should be used to guarantee all new settings take effect together.
  651. </p>
  652. <h3>Notes</h3>
  653. <p></p>
  654. </script>
  655. <script type="text/x-red" data-template-name="AudioSynthWaveformSine">
  656. <div class="form-row">
  657. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  658. <input type="text" id="node-input-name" placeholder="Name">
  659. </div>
  660. </script>
  661. <script type="text/javascript">
  662. RED.nodes.registerType('AudioSynthWaveformSineModulated',{
  663. shortName: "sine_fm",
  664. inputs:1,
  665. outputs:1,
  666. category: 'synth-function',
  667. color:"#E6E0F8",
  668. icon: "arrow-in.png"
  669. });
  670. </script>
  671. <script type="text/x-red" data-help-name="AudioSynthWaveformSineModulated">
  672. <h3>Summary</h3>
  673. <p>Create a modulated sine wave, using any audio signal to continuously
  674. modulate the sine wave frequency.</p>
  675. <h3>Audio Connections</h3>
  676. <table class=doc align=center cellpadding=3>
  677. <tr class=top><th>Port</th><th>Purpose</th></tr>
  678. <tr class=odd><td align=center>In 0</td><td>Modulation Signal</td></tr>
  679. <tr class=odd><td align=center>Out 0</td><td>Sine Wave Output</td></tr>
  680. </table>
  681. <h3>Functions</h3>
  682. <p class=func><span class=keyword>amplitude</span>(level);</p>
  683. <p class=desc>Set the amplitude, from 0 to 1.0.
  684. </p>
  685. <p class=func><span class=keyword>frequency</span>(freq);</p>
  686. <p class=desc>Set the center frequency, from 0 to 11000. The output will
  687. be this center frequency when the input modulation signal is zero.
  688. Modulation input 1.0 causes the frequency to double, and input -1.0
  689. causes zero Hz (DC) output. For less modulation, attenuate the input
  690. signal (perhaps with a mixer object) before it arrives here.
  691. </p>
  692. <p class=func><span class=keyword>phase</span>(angle);</p>
  693. <p class=desc>
  694. Cause the generated waveform to jump to a specific point within
  695. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  696. are configured,
  697. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  698. should be used to guarantee all new settings take effect together.
  699. </p>
  700. <h3>Notes</h3>
  701. <p></p>
  702. </script>
  703. <script type="text/x-red" data-template-name="AudioSynthWaveformSineModulated">
  704. <div class="form-row">
  705. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  706. <input type="text" id="node-input-name" placeholder="Name">
  707. </div>
  708. </script>
  709. <script type="text/javascript">
  710. RED.nodes.registerType('AudioSynthWaveform',{
  711. shortName: "waveform",
  712. inputs:0,
  713. outputs:1,
  714. category: 'synth-function',
  715. color:"#E6E0F8",
  716. icon: "arrow-in.png"
  717. });
  718. </script>
  719. <script type="text/x-red" data-help-name="AudioSynthWaveform">
  720. <h3>Summary</h3>
  721. <p>Create a waveform: sine, sawtooth, square, triangle, pulse or arbitrary.</p>
  722. <h3>Audio Connections</h3>
  723. <table class=doc align=center cellpadding=3>
  724. <tr class=top><th>Port</th><th>Purpose</th></tr>
  725. <tr class=odd><td align=center>Out 0</td><td>Waveform Output</td></tr>
  726. </table>
  727. <h3>Functions</h3>
  728. <p class=func><span class=keyword>begin</span>(waveform);</p>
  729. <p class=desc>Configure the waveform type to create.
  730. </p>
  731. <p class=func><span class=keyword>begin</span>(level, frequency, waveform);</p>
  732. <p class=desc>Output a waveform, and set the amplitude and frequency.
  733. </p>
  734. <p class=func><span class=keyword>frequency</span>(freq);</p>
  735. <p class=desc>Change the frequency.
  736. </p>
  737. <p class=func><span class=keyword>amplitude</span>(level);</p>
  738. <p class=desc>Change the amplitude. Set to 0 to turn the signal off.
  739. </p>
  740. <p class=func><span class=keyword>phase</span>(angle);</p>
  741. <p class=desc>
  742. Cause the generated waveform to jump to a specific point within
  743. its cycle. Angle is from 0 to 360 degrees. When multiple objects
  744. are configured,
  745. <a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  746. should be used to guarantee all new settings take effect together.
  747. </p>
  748. <p class=func><span class=keyword>pulseWidth</span>(amount);</p>
  749. <p class=desc>Change the width (duty cycle) of the pulse.</p>
  750. <p class=func><span class=keyword>arbitraryWaveform</span>(array, maxFreq);</p>
  751. <p class=desc>
  752. Configure the waveform to be used with WAVEFORM_ARBITRARY. Array
  753. must be an array of 256 samples. Currently, the data is used
  754. without any filtering, which can cause aliasing with frequencies
  755. above 172 Hz. For higher frequency output, you must bandwidth
  756. limit your waveform data. Someday, "maxFreq" will be used to
  757. do this automatically.
  758. </p>
  759. <h3>Notes</h3>
  760. <p>Supported Waveforms:<br>
  761. <ul>
  762. <li><span class=literal>WAVEFORM_SINE</span></li>
  763. <li><span class=literal>WAVEFORM_SAWTOOTH</span></li>
  764. <li><span class=literal>WAVEFORM_SQUARE</span></li>
  765. <li><span class=literal>WAVEFORM_TRIANGLE</span></li>
  766. <li><span class=literal>WAVEFORM_ARBITRARY</span></li>
  767. <li><span class=literal>WAVEFORM_PULSE</span></li>
  768. </ul>
  769. </p>
  770. </script>
  771. <script type="text/x-red" data-template-name="AudioSynthWaveform">
  772. <div class="form-row">
  773. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  774. <input type="text" id="node-input-name" placeholder="Name">
  775. </div>
  776. </script>
  777. <script type="text/javascript">
  778. RED.nodes.registerType('AudioSynthToneSweep',{
  779. shortName: "tonesweep",
  780. inputs:0,
  781. outputs:1,
  782. category: 'synth-function',
  783. color:"#E6E0F8",
  784. icon: "arrow-in.png"
  785. });
  786. </script>
  787. <script type="text/x-red" data-help-name="AudioSynthToneSweep">
  788. <h3>Summary</h3>
  789. <p>Create a continuously varying (in frequency) sine wave</p>
  790. <h3>Audio Connections</h3>
  791. <table class=doc align=center cellpadding=3>
  792. <tr class=top><th>Port</th><th>Purpose</th></tr>
  793. <tr class=odd><td align=center>Out 0</td><td>Continuously varying tone</td></tr>
  794. </table>
  795. <h3>Functions</h3>
  796. <p class=func><span class=keyword>play</span>(level, lowFreq, highFreq, time);</p>
  797. <p class=desc>Start generating frequency sweep output. The time is specified
  798. in milliseconds. Level is 0 to 1.0.
  799. </p>
  800. <p class=func><span class=keyword>isPlaying</span>();</p>
  801. <p class=desc>Returns true (non-zero) while the output is active.
  802. </p>
  803. <h3>Notes</h3>
  804. <p>Uses excessive CPU time</p>
  805. </script>
  806. <script type="text/x-red" data-template-name="AudioSynthToneSweep">
  807. <div class="form-row">
  808. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  809. <input type="text" id="node-input-name" placeholder="Name">
  810. </div>
  811. </script>
  812. <script type="text/javascript">
  813. RED.nodes.registerType('AudioSynthWaveformDc',{
  814. shortName: "dc",
  815. inputs:0,
  816. outputs:1,
  817. category: 'synth-function',
  818. color:"#E6E0F8",
  819. icon: "arrow-in.png"
  820. });
  821. </script>
  822. <script type="text/x-red" data-help-name="AudioSynthWaveformDc">
  823. <h3>Summary</h3>
  824. <p>Create constant (DC) signal, useful for control of objects that take
  825. a modulation or control input signal. This constant level can be
  826. used to modify other waveforms using mixer or multiplier objects</p>
  827. <h3>Audio Connections</h3>
  828. <table class=doc align=center cellpadding=3>
  829. <tr class=top><th>Port</th><th>Purpose</th></tr>
  830. <tr class=odd><td align=center>Out 0</td><td>Output constant DC level</td></tr>
  831. </table>
  832. <h3>Functions</h3>
  833. <p class=func><span class=keyword>amplitude</span>(level);</p>
  834. <p class=desc>Set the output. Level is -1.0 to 1.0. The output is
  835. changed immediately.
  836. </p>
  837. <p class=func><span class=keyword>amplitude</span>(level, milliseconds);</p>
  838. <p class=desc>Set the output. Level is -1.0 to 1.0. The output is
  839. gradually changed over a "milliseconds" time period. Any time may
  840. be specified, but periods longer than 1 second may be automatically
  841. shortened for small level changes, due to numerical precision limits.
  842. </p>
  843. <h3>Notes</h3>
  844. <p>Of course, the term "DC", for Direct Current, doesn't properly apply
  845. to a pure digital stream of numerical values. But the term is widely
  846. understood in audio applications, so hopefully it's not too confusing?</p>
  847. </script>
  848. <script type="text/x-red" data-template-name="AudioSynthWaveformDc">
  849. <div class="form-row">
  850. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  851. <input type="text" id="node-input-name" placeholder="Name">
  852. </div>
  853. </script>
  854. <script type="text/javascript">
  855. RED.nodes.registerType('AudioSynthNoiseWhite',{
  856. shortName: "noise",
  857. inputs:0,
  858. outputs:1,
  859. category: 'synth-function',
  860. color:"#E6E0F8",
  861. icon: "arrow-in.png"
  862. });
  863. </script>
  864. <script type="text/x-red" data-help-name="AudioSynthNoiseWhite">
  865. <h3>Summary</h3>
  866. <div>
  867. <p>Create white noise.
  868. </p>
  869. <p align=center><img src="whitenoise.png"></p>
  870. </div>
  871. <h3>Audio Connections</h3>
  872. <table class=doc align=center cellpadding=3>
  873. <tr class=top><th>Port</th><th>Purpose</th></tr>
  874. <tr class=odd><td align=center>Out 0</td><td>White Noise</td></tr>
  875. </table>
  876. <h3>Functions</h3>
  877. <p class=func><span class=keyword>amplitude</span>(level);</p>
  878. <p class=desc>Set the output peak level, from 0 (off) to 1.0.
  879. The default is off. Noise is generated only after setting
  880. to a non-zero level.
  881. </p>
  882. <h3>Notes</h3>
  883. <p>Setting the amplitude to zero causes this object to stop using
  884. CPU time to generate random numbers.
  885. </p>
  886. </script>
  887. <script type="text/x-red" data-template-name="AudioSynthNoiseWhite">
  888. <div class="form-row">
  889. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  890. <input type="text" id="node-input-name" placeholder="Name">
  891. </div>
  892. </script>
  893. <script type="text/javascript">
  894. RED.nodes.registerType('AudioSynthNoisePink',{
  895. shortName: "pink",
  896. inputs:0,
  897. outputs:1,
  898. category: 'synth-function',
  899. color:"#E6E0F8",
  900. icon: "arrow-in.png"
  901. });
  902. </script>
  903. <script type="text/x-red" data-help-name="AudioSynthNoisePink">
  904. <h3>Summary</h3>
  905. <div>
  906. <p>Create pink noise, using Stefan Stenzel's "New Shade Of Pink" algorithm.
  907. </p>
  908. <!--<p align=center><img src="whitenoise.png"></p>-->
  909. </div>
  910. <h3>Audio Connections</h3>
  911. <table class=doc align=center cellpadding=3>
  912. <tr class=top><th>Port</th><th>Purpose</th></tr>
  913. <tr class=odd><td align=center>Out 0</td><td>Pink Noise</td></tr>
  914. </table>
  915. <h3>Functions</h3>
  916. <p class=func><span class=keyword>amplitude</span>(level);</p>
  917. <p class=desc>Set the output peak level, from 0 (off) to 1.0.
  918. The default is off. Noise is generated only after setting
  919. to a non-zero level.
  920. </p>
  921. <h3>Notes</h3>
  922. <p>Setting the amplitude to zero causes this object to stop using
  923. CPU time. CPU usage is approx 3% on Teensy 3.1.
  924. </p>
  925. <p>Stefan Stenzel's
  926. <a href="http://stenzel.waldorfmusic.de/post/pink/" target="_blank">New Shade Of Pink</a>
  927. algorithm. Stefan's terms of use are "Use for any purpose. If used
  928. in a commercial product, you should give me one."
  929. </p>
  930. </script>
  931. <script type="text/x-red" data-template-name="AudioSynthNoisePink">
  932. <div class="form-row">
  933. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  934. <input type="text" id="node-input-name" placeholder="Name">
  935. </div>
  936. </script>
  937. <script type="text/javascript">
  938. RED.nodes.registerType('AudioEffectFade',{
  939. shortName: "fade",
  940. inputs:1,
  941. outputs:1,
  942. category: 'effect-function',
  943. color:"#E6E0F8",
  944. icon: "arrow-in.png"
  945. });
  946. </script>
  947. <script type="text/x-red" data-help-name="AudioEffectFade">
  948. <h3>Summary</h3>
  949. <p>Gradually increase or decrease audio level.</p>
  950. <h3>Audio Connections</h3>
  951. <table class=doc align=center cellpadding=3>
  952. <tr class=top><th>Port</th><th>Purpose</th></tr>
  953. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  954. <tr class=odd><td align=center>Out 0</td><td>Signal Output</td></tr>
  955. </table>
  956. <h3>Functions</h3>
  957. <p class=func><span class=keyword>fadeIn</span>(milliseconds);</p>
  958. <p class=desc>Begin increasing the audio level, to reach 1.0 (input passed
  959. directly to the output) after "milliseconds" time.
  960. </p>
  961. <p class=func><span class=keyword>fadeOut</span>(milliseconds);</p>
  962. <p class=desc>Begin decreasing the audio level, to reach 0 (no output)
  963. after "milliseconds" time.
  964. </p>
  965. <h3>Notes</h3>
  966. <p>Cross fading can be built with 2 fade objects fed into a mixer.
  967. When one fade object is off (fully faded out) and the other on
  968. (fully faded in), if both are started at the same moment for the
  969. same time duration, their signal gains always add to 1.0. This
  970. allows 2 fade objects to work together for a smooth transition
  971. between a pair of signals.
  972. </p>
  973. <p><a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
  974. should be used when changing
  975. settings on multiple objects, so all changes always take effect
  976. at the same moment.
  977. </p>
  978. </script>
  979. <script type="text/x-red" data-template-name="AudioEffectFade">
  980. <div class="form-row">
  981. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  982. <input type="text" id="node-input-name" placeholder="Name">
  983. </div>
  984. </script>
  985. <script type="text/javascript">
  986. RED.nodes.registerType('AudioEffectChorus',{
  987. shortName: "chorus",
  988. inputs:2,
  989. outputs:2,
  990. category: 'effect-function',
  991. color:"#E6E0F8",
  992. icon: "arrow-in.png"
  993. });
  994. </script>
  995. <script type="text/x-red" data-help-name="AudioEffectChorus">
  996. <h3>Summary</h3>
  997. <p>description</p>
  998. <h3>Audio Connections</h3>
  999. <table class=doc align=center cellpadding=3>
  1000. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1001. <tr class=odd><td align=center></td><td></td></tr>
  1002. </table>
  1003. <!--<h3>Parameters</h3>
  1004. <table class=doc align=center cellpadding=3>
  1005. <tr class=top><th>Name</th><th>Type</th><th>Function</th></tr>
  1006. <tr class=odd><td align=center></td><td>Integer</td><td></td></tr>
  1007. </table>
  1008. <p>Extra description... Section only present if object has params</p>-->
  1009. <h3>Functions</h3>
  1010. <p class=func><span class=keyword>begin</span>(delayBuffer, length, n_chorus);</p>
  1011. <p class=desc>blah blah blah blah
  1012. </p>
  1013. <p class=func><span class=keyword>stop</span>();</p>
  1014. <p class=desc>blah blah blah blah
  1015. </p>
  1016. <p class=func><span class=keyword>modify</span>(n_chorus);</p>
  1017. <p class=desc>blah blah blah blah
  1018. </p>
  1019. <h3>Notes</h3>
  1020. <p></p>
  1021. </script>
  1022. <script type="text/x-red" data-template-name="AudioEffectChorus">
  1023. <div class="form-row">
  1024. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1025. <input type="text" id="node-input-name" placeholder="Name">
  1026. </div>
  1027. </script>
  1028. <script type="text/javascript">
  1029. RED.nodes.registerType('AudioEffectFlange',{
  1030. shortName: "flange",
  1031. inputs:2,
  1032. outputs:2,
  1033. category: 'effect-function',
  1034. color:"#E6E0F8",
  1035. icon: "arrow-in.png"
  1036. });
  1037. </script>
  1038. <script type="text/x-red" data-help-name="AudioEffectFlange">
  1039. <h3>Summary</h3>
  1040. <p>description</p>
  1041. <h3>Audio Connections</h3>
  1042. <table class=doc align=center cellpadding=3>
  1043. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1044. <tr class=odd><td align=center></td><td></td></tr>
  1045. </table>
  1046. <!--<h3>Parameters</h3>
  1047. <table class=doc align=center cellpadding=3>
  1048. <tr class=top><th>Name</th><th>Type</th><th>Function</th></tr>
  1049. <tr class=odd><td align=center></td><td>Integer</td><td></td></tr>
  1050. </table>
  1051. <p>Extra description... Section only present if object has params</p>-->
  1052. <h3>Functions</h3>
  1053. <p class=func><span class=keyword>begin</span>(delayBuffer, length, offset, depth, delayRate);</p>
  1054. <p class=desc>blah blah blah blah
  1055. </p>
  1056. <p class=func><span class=keyword>modify</span>(offset, depth, delayRate);</p>
  1057. <p class=desc>blah blah blah blah
  1058. </p>
  1059. <p class=func><span class=keyword>stop</span>();</p>
  1060. <p class=desc>blah blah blah blah
  1061. </p>
  1062. <h3>Notes</h3>
  1063. <p></p>
  1064. </script>
  1065. <script type="text/x-red" data-template-name="AudioEffectFlange">
  1066. <div class="form-row">
  1067. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1068. <input type="text" id="node-input-name" placeholder="Name">
  1069. </div>
  1070. </script>
  1071. <script type="text/javascript">
  1072. RED.nodes.registerType('AudioEffectEnvelope',{
  1073. shortName: "envelope",
  1074. inputs:1,
  1075. outputs:1,
  1076. category: 'effect-function',
  1077. color:"#E6E0F8",
  1078. icon: "arrow-in.png"
  1079. });
  1080. </script>
  1081. <script type="text/x-red" data-help-name="AudioEffectEnvelope">
  1082. <h3>Summary</h3>
  1083. <div>
  1084. <p>Modify a signal with a DAHDSR (Delay Attack Hold Decay Sustain
  1085. Release) envelope.
  1086. </p>
  1087. <p align=center><img src="dahdsr.png"></p>
  1088. </div>
  1089. <h3>Audio Connections</h3>
  1090. <table class=doc align=center cellpadding=3>
  1091. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1092. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1093. <tr class=odd><td align=center>Out 0</td><td>Signal with Envelope Applied</td></tr>
  1094. </table>
  1095. <h3>Functions</h3>
  1096. <p class=func><span class=keyword>noteOn</span>();</p>
  1097. <p class=desc>Begin the delay to attack, or the attack phase is
  1098. delay is zero.
  1099. </p>
  1100. <p class=func><span class=keyword>noteOff</span>();</p>
  1101. <p class=desc>Begin the release phase.
  1102. </p>
  1103. <p class=func><span class=keyword>delay</span>(milliseconds);</p>
  1104. <p class=desc>Set the delay from noteOn to the attach phase. The
  1105. default is zero, for no delay.
  1106. </p>
  1107. <p class=func><span class=keyword>attack</span>(milliseconds);</p>
  1108. <p class=desc>Set the attack time. The default is 1.5 milliseconds.
  1109. </p>
  1110. <p class=func><span class=keyword>hold</span>(milliseconds);</p>
  1111. <p class=desc>Set the hold time. The default is 0.5 milliseconds.
  1112. </p>
  1113. <p class=func><span class=keyword>decay</span>(milliseconds);</p>
  1114. <p class=desc>Set the decay time. The default is 15 milliseconds.
  1115. </p>
  1116. <p class=func><span class=keyword>sustain</span>(level);</p>
  1117. <p class=desc>Set the sustain level. The range is 0 to 1.0. The
  1118. gain will be maintained at this level after the decay phase,
  1119. until noteOff() is called.
  1120. </p>
  1121. <p class=func><span class=keyword>release</span>(milliseconds);</p>
  1122. <p class=desc>Set the release time. The default is 30 millisecond.
  1123. </p>
  1124. <h3>Notes</h3>
  1125. <p>To achieve the more common ADSR shape, simply
  1126. set delay and hold to zero.</p>
  1127. <p>The recommended range for each of the 5 timing inputs is 0 to 50
  1128. milliseconds. Up to 200 ms can be used, with somewhat reduced
  1129. accuracy</p>
  1130. </script>
  1131. <script type="text/x-red" data-template-name="AudioEffectEnvelope">
  1132. <div class="form-row">
  1133. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1134. <input type="text" id="node-input-name" placeholder="Name">
  1135. </div>
  1136. </script>
  1137. <script type="text/javascript">
  1138. RED.nodes.registerType('AudioEffectMultiply',{
  1139. shortName: "multiply",
  1140. inputs:2,
  1141. outputs:1,
  1142. category: 'effect-function',
  1143. color:"#E6E0F8",
  1144. icon: "arrow-in.png"
  1145. });
  1146. </script>
  1147. <script type="text/x-red" data-help-name="AudioEffectMultiply">
  1148. <h3>Summary</h3>
  1149. <div>
  1150. <p>Multiply two signals together, useful for amplitude modulation
  1151. or "voltage controlled amplification".
  1152. </p>
  1153. <p align=center><img src="multiply.png"><br><small>56 Hz and 1 kHz sine waves multiplied.</small></p>
  1154. </div>
  1155. <h3>Audio Connections</h3>
  1156. <table class=doc align=center cellpadding=3>
  1157. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1158. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1159. <tr class=odd><td align=center>In 1</td><td>Signal Input</td></tr>
  1160. <tr class=odd><td align=center>Out 0</td><td>Signal with Envelope Applied</td></tr>
  1161. </table>
  1162. <h3>Functions</h3>
  1163. <p>There are no functions to call from the Arduino sketch.
  1164. This object simply multiplies the 2 signals to create
  1165. a continuous output
  1166. </p>
  1167. <h3>Notes</h3>
  1168. <p>
  1169. </p>
  1170. </script>
  1171. <script type="text/x-red" data-template-name="AudioEffectMultiply">
  1172. <div class="form-row">
  1173. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1174. <input type="text" id="node-input-name" placeholder="Name">
  1175. </div>
  1176. </script>
  1177. <script type="text/javascript">
  1178. RED.nodes.registerType('AudioEffectDelay',{
  1179. shortName: "delay",
  1180. inputs:1,
  1181. outputs:8,
  1182. category: 'effect-function',
  1183. color:"#E6E0F8",
  1184. icon: "arrow-in.png"
  1185. });
  1186. </script>
  1187. <script type="text/x-red" data-help-name="AudioEffectDelay">
  1188. <h3>Summary</h3>
  1189. <div>
  1190. <p>Delay a signal. Up to 8 separate delay taps can be used.</p>
  1191. <p align=center><img src="delay.png"><br><small>1 kHz burst, delayed 5.2 ms.</small></p>
  1192. </div>
  1193. <h3>Audio Connections</h3>
  1194. <table class=doc align=center cellpadding=3>
  1195. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1196. <tr class=odd><td align=center>In 0</td><td>Signal Input</td></tr>
  1197. <tr class=odd><td align=center>Out 0</td><td>Delay Tap #1</td></tr>
  1198. <tr class=odd><td align=center>Out 1</td><td>Delay Tap #2</td></tr>
  1199. <tr class=odd><td align=center>Out 2</td><td>Delay Tap #3</td></tr>
  1200. <tr class=odd><td align=center>Out 3</td><td>Delay Tap #4</td></tr>
  1201. <tr class=odd><td align=center>Out 4</td><td>Delay Tap #5</td></tr>
  1202. <tr class=odd><td align=center>Out 5</td><td>Delay Tap #6</td></tr>
  1203. <tr class=odd><td align=center>Out 6</td><td>Delay Tap #7</td></tr>
  1204. <tr class=odd><td align=center>Out 7</td><td>Delay Tap #8</td></tr>
  1205. </table>
  1206. <h3>Functions</h3>
  1207. <p class=func><span class=keyword>delay</span>(channel, milliseconds);</p>
  1208. <p class=desc>Set output channel (0 to 7) to delay the signals by
  1209. milliseconds. The maximum delay is approx 333 ms. The actual delay
  1210. is rounded to the nearest sample. Each channel can be configured for
  1211. any delay. There is no requirement to configure the "taps" in increasing
  1212. delay order.
  1213. </p>
  1214. <p class=func><span class=keyword>disable</span>(channel);</p>
  1215. <p class=desc>Disable a channel. The output of this channel becomes
  1216. silent. If this channel is the longest delay, memory usage is
  1217. automatically reduced to accomodate only the remaining channels used.
  1218. </p>
  1219. <h3>Notes</h3>
  1220. <p>Memory for the delayed signal is take from the memory pool allocated by
  1221. <a href="http://www.pjrc.com/teensy/td_libs_AudioConnection.html" target="_blank">AudioMemory()</a>.
  1222. Each block allows about 3 milliseconds of delay, so AudioMemory
  1223. should be increased to allow for the longest delay tap.
  1224. </p>
  1225. </script>
  1226. <script type="text/x-red" data-template-name="AudioEffectDelay">
  1227. <div class="form-row">
  1228. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1229. <input type="text" id="node-input-name" placeholder="Name">
  1230. </div>
  1231. </script>
  1232. <script type="text/javascript">
  1233. RED.nodes.registerType('AudioFilterBiquad',{
  1234. shortName: "biquad",
  1235. inputs:1,
  1236. outputs:1,
  1237. category: 'filter-function',
  1238. color:"#E6E0F8",
  1239. icon: "arrow-in.png"
  1240. });
  1241. </script>
  1242. <script type="text/x-red" data-help-name="AudioFilterBiquad">
  1243. <h3>Summary</h3>
  1244. <p>description</p>
  1245. <h3>Audio Connections</h3>
  1246. <table class=doc align=center cellpadding=3>
  1247. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1248. <tr class=odd><td align=center></td><td></td></tr>
  1249. </table>
  1250. <h3>Parameters</h3>
  1251. <table class=doc align=center cellpadding=3>
  1252. <tr class=top><th>Name</th><th>Type</th><th>Function</th></tr>
  1253. <tr class=odd><td align=center></td><td>Integer</td><td></td></tr>
  1254. </table>
  1255. <p>Extra description... Section only present if object has params</p>
  1256. <h3>Functions</h3>
  1257. <p class=func><span class=keyword>function</span>(parm1, parm2);</p>
  1258. <p class=desc>blah blah blah blah
  1259. </p>
  1260. <h3>Notes</h3>
  1261. <p></p>
  1262. </script>
  1263. <script type="text/x-red" data-template-name="AudioFilterBiquad">
  1264. <div class="form-row">
  1265. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1266. <input type="text" id="node-input-name" placeholder="Name">
  1267. </div>
  1268. </script>
  1269. <script type="text/javascript">
  1270. RED.nodes.registerType('AudioFilterFIR',{
  1271. shortName: "fir",
  1272. inputs:1,
  1273. outputs:1,
  1274. category: 'filter-function',
  1275. color:"#E6E0F8",
  1276. icon: "arrow-in.png"
  1277. });
  1278. </script>
  1279. <script type="text/x-red" data-help-name="AudioFilterFIR">
  1280. <h3>Summary</h3>
  1281. <p>description</p>
  1282. <h3>Audio Connections</h3>
  1283. <table class=doc align=center cellpadding=3>
  1284. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1285. <tr class=odd><td align=center></td><td></td></tr>
  1286. </table>
  1287. <!--<h3>Parameters</h3>
  1288. <table class=doc align=center cellpadding=3>
  1289. <tr class=top><th>Name</th><th>Type</th><th>Function</th></tr>
  1290. <tr class=odd><td align=center></td><td>Integer</td><td></td></tr>
  1291. </table>
  1292. <p>Extra description... Section only present if object has params</p>-->
  1293. <h3>Functions</h3>
  1294. <p class=func><span class=keyword>function</span>(parm1, parm2);</p>
  1295. <p class=desc>blah blah blah blah
  1296. </p>
  1297. <h3>Notes</h3>
  1298. <p></p>
  1299. </script>
  1300. <script type="text/x-red" data-template-name="AudioFilterFIR">
  1301. <div class="form-row">
  1302. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1303. <input type="text" id="node-input-name" placeholder="Name">
  1304. </div>
  1305. </script>
  1306. <script type="text/javascript">
  1307. RED.nodes.registerType('AudioFilterStateVariable',{
  1308. shortName: "filter",
  1309. inputs:2,
  1310. outputs:3,
  1311. category: 'filter-function',
  1312. color:"#E6E0F8",
  1313. icon: "arrow-in.png"
  1314. });
  1315. </script>
  1316. <script type="text/x-red" data-help-name="AudioFilterStateVariable">
  1317. <h3>Summary</h3>
  1318. <p>A State Variable (Chamberlin) Filter with 12 dB/octave roll-off,
  1319. adjustable resonance, and optional signal control of corner
  1320. frequency.</p>
  1321. <h3>Audio Connections</h3>
  1322. <table class=doc align=center cellpadding=3>
  1323. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1324. <tr class=odd><td align=center>In 0</td><td>Signal to Filter</td></tr>
  1325. <tr class=odd><td align=center>In 1</td><td>Frequency Control</td></tr>
  1326. <tr class=odd><td align=center>Out 0</td><td>Low Pass Output</td></tr>
  1327. <tr class=odd><td align=center>Out 1</td><td>Band Pass Output</td></tr>
  1328. <tr class=odd><td align=center>Out 2</td><td>High Pass Output</td></tr>
  1329. </table>
  1330. <h3>Functions</h3>
  1331. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1332. <p class=desc>Set the filter's corner frequency. When a signal is
  1333. connected to the control input, the filter will implement this
  1334. frequency when the signal is zero.
  1335. </p>
  1336. <p class=func><span class=keyword>resonance</span>(Q);</p>
  1337. <p class=desc>Set the filter's resonance. Q ranges from 0.7 to 5.0.
  1338. Resonance greater than 0.707 will amplify the signal near the
  1339. corner frequency. You must attenuate the signal before input
  1340. to this filter, to prevent clipping.
  1341. </p>
  1342. <p class=func><span class=keyword>octaveControl</span>(octaves);</p>
  1343. <p class=desc>Set how much (in octaves) the control signal can alter
  1344. the filter's corner freqency. Range is 0 to 7 octaves. For
  1345. example, when set to 2.5, a full scale positive signal (1.0) will
  1346. shift the filter frequency up 2.5 octaves, and a full scale negative
  1347. signal will shift it down 2.5 octaves.
  1348. </p>
  1349. <h3>Notes</h3>
  1350. <p>
  1351. When controlled by a signal, the equation for the filter
  1352. frequency is:
  1353. </p>
  1354. <p>
  1355. F = Fcenter * 2^<sup>(signal * octaves)</sup>
  1356. <br><small>If anyone knows how to do HTML equations, please
  1357. help me improve this.....</small>
  1358. </p>
  1359. <p>When operating with signal control of corner frequency, this
  1360. object uses approximately 4% of the CPU time on Teensy 3.1.
  1361. </p>
  1362. </script>
  1363. <script type="text/x-red" data-template-name="AudioFilterFIR">
  1364. <div class="form-row">
  1365. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1366. <input type="text" id="node-input-name" placeholder="Name">
  1367. </div>
  1368. </script>
  1369. <script type="text/javascript">
  1370. RED.nodes.registerType('AudioAnalyzePeak',{
  1371. shortName: "peak",
  1372. inputs:1,
  1373. outputs:0,
  1374. category: 'analyze-function',
  1375. color:"#E6E0F8",
  1376. icon: "arrow-in.png"
  1377. });
  1378. </script>
  1379. <script type="text/x-red" data-help-name="AudioAnalyzePeak">
  1380. <h3>Summary</h3>
  1381. <p>description</p>
  1382. <h3>Audio Connections</h3>
  1383. <table class=doc align=center cellpadding=3>
  1384. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1385. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  1386. </table>
  1387. <h3>Functions</h3>
  1388. <p class=func><span class=keyword>available</span>();</p>
  1389. <p class=desc>Returns true each time new peak data is available.
  1390. </p>
  1391. <p class=func><span class=keyword>read</span>();</p>
  1392. <p class=desc>Read the highest peak value since the last read.
  1393. Return is from 0.0 to 1.0.
  1394. </p>
  1395. <h3>Notes</h3>
  1396. <p></p>
  1397. </script>
  1398. <script type="text/x-red" data-template-name="AudioAnalyzePeak">
  1399. <div class="form-row">
  1400. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1401. <input type="text" id="node-input-name" placeholder="Name">
  1402. </div>
  1403. </script>
  1404. <script type="text/javascript">
  1405. RED.nodes.registerType('AudioAnalyzeFFT256',{
  1406. shortName: "fft256",
  1407. inputs:1,
  1408. outputs:0,
  1409. category: 'analyze-function',
  1410. color:"#E6E0F8",
  1411. icon: "arrow-in.png"
  1412. });
  1413. </script>
  1414. <script type="text/x-red" data-help-name="AudioAnalyzeFFT256">
  1415. <h3>Summary</h3>
  1416. <p>Compute a 256 point Fast Fourier Transform (FFT) frequency analysis,
  1417. with real value (magnitude) output. The frequency resolution is
  1418. 172 Hz, useful for simple audio visualization.</p>
  1419. <h3>Audio Connections</h3>
  1420. <table class=doc align=center cellpadding=3>
  1421. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1422. <tr class=odd><td align=center>In 0</td><td>Signal to convert to frequency bins</td></tr>
  1423. </table>
  1424. <h3>Functions</h3>
  1425. <p class=func><span class=keyword>available</span>();</p>
  1426. <p class=desc>Returns true each time the FFT analysis produces new output data.
  1427. </p>
  1428. <p class=func><span class=keyword>read</span>(binNumber);</p>
  1429. <p class=desc>Read a single frequency bin, from 0 to 127. The result is scaled
  1430. so 1.0 represents a full scale sine wave.
  1431. </p>
  1432. <p class=func><span class=keyword>read</span>(firstBin, lastBin);</p>
  1433. <p class=desc>Read several frequency bins, returning their sum. The higher
  1434. audio octaves are represented by many bins, which are typically read
  1435. as a group for audio visualization.
  1436. </p>
  1437. <p class=func><span class=keyword>averageTogether</span>(number);</p>
  1438. <p class=desc>New data is produced very radidly, approximately 344 times
  1439. per second. Multiple outputs can be averaged together, so available()
  1440. returns true at a slower rate.
  1441. </p>
  1442. <p class=func><span class=keyword>windowFunction</span>(window);</p>
  1443. <p class=desc>Set the window function to be used. AudioWindowHanning256
  1444. is the default. Windowing may be disabled by NULL, but windowing
  1445. should be used for all non-periodic (music) signals, and all periodic
  1446. signals that are not exact integer division of the sample rate.
  1447. </p>
  1448. <h3>Notes</h3>
  1449. <p>The raw 16 bit output data bins may be access with myFFT.output[num], where
  1450. num is 0 to 127.</p>
  1451. <p>TODO: caveats about spectral leakage vs frequency precision for arbitrary signals</p>
  1452. <p>Window Types:
  1453. <ul>
  1454. <li><span class=literal>AudioWindowHanning256</span> (default)</li>
  1455. <li><span class=literal>AudioWindowBartlett256</span></li>
  1456. <li><span class=literal>AudioWindowBlackman256</span></li>
  1457. <li><span class=literal>AudioWindowFlattop256</span></li>
  1458. <li><span class=literal>AudioWindowBlackmanHarris256</span></li>
  1459. <li><span class=literal>AudioWindowNuttall256</span></li>
  1460. <li><span class=literal>AudioWindowBlackmanNuttall256</span></li>
  1461. <li><span class=literal>AudioWindowWelch256</span></li>
  1462. <li><span class=literal>AudioWindowHamming256</span></li>
  1463. <li><span class=literal>AudioWindowCosine256</span></li>
  1464. <li><span class=literal>AudioWindowTukey256</span></li>
  1465. </ul>
  1466. </p>
  1467. </script>
  1468. <script type="text/x-red" data-template-name="AudioAnalyzeFFT256">
  1469. <div class="form-row">
  1470. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1471. <input type="text" id="node-input-name" placeholder="Name">
  1472. </div>
  1473. </script>
  1474. <script type="text/javascript">
  1475. RED.nodes.registerType('AudioAnalyzeFFT1024',{
  1476. shortName: "fft1024",
  1477. inputs:1,
  1478. outputs:0,
  1479. category: 'analyze-function',
  1480. color:"#E6E0F8",
  1481. icon: "arrow-in.png"
  1482. });
  1483. </script>
  1484. <script type="text/x-red" data-help-name="AudioAnalyzeFFT1024">
  1485. <h3>Summary</h3>
  1486. <p>Compute a 1024 point Fast Fourier Transform (FFT) frequency analysis,
  1487. with real value (magnitude) output. The frequency resolution is
  1488. 43 Hz, useful detailed for audio visualization.</p>
  1489. <h3>Audio Connections</h3>
  1490. <table class=doc align=center cellpadding=3>
  1491. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1492. <tr class=odd><td align=center>In 0</td><td>Signal to convert to frequency bins</td></tr>
  1493. </table>
  1494. <h3>Functions</h3>
  1495. <p class=func><span class=keyword>available</span>();</p>
  1496. <p class=desc>Returns true each time the FFT analysis produces new output data.
  1497. </p>
  1498. <p class=func><span class=keyword>read</span>(binNumber);</p>
  1499. <p class=desc>Read a single frequency bin, from 0 to 511. The result is scaled
  1500. so 1.0 represents a full scale sine wave.
  1501. </p>
  1502. <p class=func><span class=keyword>read</span>(firstBin, lastBin);</p>
  1503. <p class=desc>Read several frequency bins, returning their sum. The higher
  1504. audio octaves are represented by many bins, which are typically read
  1505. as a group for audio visualization.
  1506. </p>
  1507. <p class=func><span class=keyword>averageTogether</span>(number);</p>
  1508. <p class=desc>This function does nothing. The 1024 point FFT always
  1509. updates at approximately 86 times per second.
  1510. </p>
  1511. <p class=func><span class=keyword>windowFunction</span>(window);</p>
  1512. <p class=desc>Set the window function to be used. AudioWindowHanning1024
  1513. is the default. Windowing may be disabled by NULL, but windowing
  1514. should be used for all non-periodic (music) signals, and all periodic
  1515. signals that are not exact integer division of the sample rate.
  1516. </p>
  1517. <h3>Notes</h3>
  1518. <p>The raw 16 bit output data bins may be access with myFFT.output[num], where
  1519. num is 0 to 511.</p>
  1520. <p>TODO: caveats about spectral leakage vs frequency precision for arbitrary signals</p>
  1521. <p>Window Types:
  1522. <ul>
  1523. <li><span class=literal>AudioWindowHanning1024</span> (default)</li>
  1524. <li><span class=literal>AudioWindowBartlett1024</span></li>
  1525. <li><span class=literal>AudioWindowBlackman1024</span></li>
  1526. <li><span class=literal>AudioWindowFlattop1024</span></li>
  1527. <li><span class=literal>AudioWindowBlackmanHarris1024</span></li>
  1528. <li><span class=literal>AudioWindowNuttall1024</span></li>
  1529. <li><span class=literal>AudioWindowBlackmanNuttall1024</span></li>
  1530. <li><span class=literal>AudioWindowWelch1024</span></li>
  1531. <li><span class=literal>AudioWindowHamming1024</span></li>
  1532. <li><span class=literal>AudioWindowCosine1024</span></li>
  1533. <li><span class=literal>AudioWindowTukey1024</span></li>
  1534. </ul>
  1535. </p>
  1536. <p>1024 point FFT has a peak CPU usage of approx 52% on Teensy 3.1.
  1537. Average usage is much lower. Future versions might distribute the
  1538. load more evenly over time....
  1539. </p>
  1540. </script>
  1541. <script type="text/x-red" data-template-name="AudioAnalyzeFFT1024">
  1542. <div class="form-row">
  1543. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1544. <input type="text" id="node-input-name" placeholder="Name">
  1545. </div>
  1546. </script>
  1547. <script type="text/javascript">
  1548. RED.nodes.registerType('AudioAnalyzeToneDetect',{
  1549. shortName: "tone",
  1550. inputs:1,
  1551. outputs:0,
  1552. category: 'analyze-function',
  1553. color:"#E6E0F8",
  1554. icon: "arrow-in.png"
  1555. });
  1556. </script>
  1557. <script type="text/x-red" data-help-name="AudioAnalyzeToneDetect">
  1558. <h3>Summary</h3>
  1559. <p>Detect the level of a single tone</p>
  1560. <h3>Audio Connections</h3>
  1561. <table class=doc align=center cellpadding=3>
  1562. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1563. <tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
  1564. </table>
  1565. <h3>Functions</h3>
  1566. <p class=func><span class=keyword>frequency</span>(freq);</p>
  1567. <p class=desc>Set the frequency to detect. The default detection time
  1568. will be 10 cycles of this frequency.
  1569. </p>
  1570. <p class=func><span class=keyword>frequency</span>(freq, cycles);</p>
  1571. <p class=desc>Set the frequency to detect, and the number of cycles.
  1572. Longer detection time (more cycles) will give higher precision,
  1573. but of course slower response.
  1574. </p>
  1575. <p class=func><span class=keyword>available</span>();</p>
  1576. <p class=desc>Returns true (non-zero) each time a detection interval
  1577. (number of cycles) completed and a new level is detected.
  1578. </p>
  1579. <p class=func><span class=keyword>read</span>();</p>
  1580. <p class=desc>Read the detected signal level. Range is 0 to 1.0.
  1581. </p>
  1582. <p class=func><span class=keyword>threshold</span>(level);</p>
  1583. <p class=desc>Set a detection threshold, where the bool test operation
  1584. will return true if at or above this level, or false when below.
  1585. </p>
  1586. <p class=func>(bool)</p>
  1587. <p class=desc>By testing the object as a boolean value, you can respond
  1588. to detection of a tone.
  1589. </p>
  1590. <h3>Notes</h3>
  1591. <p>Low frequency detection has trouble with numerical precision.
  1592. Works really well for all 8 DTMF frequencies, but fails for
  1593. detecting "sub audible tones" used in some control applications.</p>
  1594. <p>The (bool) test continues to return true until the next detection
  1595. interval (the configured number of cycles). This behavior may
  1596. change in future versions, for a single true each time the signal
  1597. is detected, and then false for the remainder of that interval.</p>
  1598. </script>
  1599. <script type="text/x-red" data-template-name="AudioAnalyzeToneDetect">
  1600. <div class="form-row">
  1601. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1602. <input type="text" id="node-input-name" placeholder="Name">
  1603. </div>
  1604. </script>
  1605. <script type="text/javascript">
  1606. RED.nodes.registerType('AudioAnalyzePrint',{
  1607. shortName: "print",
  1608. inputs:1,
  1609. outputs:0,
  1610. category: 'analyze-function',
  1611. color:"#E6E0F8",
  1612. icon: "arrow-in.png"
  1613. });
  1614. </script>
  1615. <script type="text/x-red" data-help-name="AudioAnalyzePrint">
  1616. <h3>Summary</h3>
  1617. <p>Print raw audio data to the Arduino Serial Monitor. This
  1618. object creates massive output quickly, and should not normall be used.</p>
  1619. <h3>Audio Connections</h3>
  1620. <table class=doc align=center cellpadding=3>
  1621. <tr class=top><th>Port</th><th>Purpose</th></tr>
  1622. <tr class=odd><td align=center></td><td></td></tr>
  1623. </table>
  1624. <!--<h3>Parameters</h3>
  1625. <table class=doc align=center cellpadding=3>
  1626. <tr class=top><th>Name</th><th>Type</th><th>Function</th></tr>
  1627. <tr class=odd><td align=center></td><td>Integer</td><td></td></tr>
  1628. </table>
  1629. <p>Extra description... Section only present if object has params</p>-->
  1630. <h3>Functions</h3>
  1631. <p class=func><span class=keyword>name</span>(string);</p>
  1632. <p class=desc>blah blah blah blah
  1633. </p>
  1634. <p class=func><span class=keyword>trigger</span>();</p>
  1635. <p class=desc>blah blah blah blah
  1636. </p>
  1637. <p class=func><span class=keyword>trigger</span>(level, edge);</p>
  1638. <p class=desc>blah blah blah blah
  1639. </p>
  1640. <p class=func><span class=keyword>delay</span>(samples);</p>
  1641. <p class=desc>blah blah blah blah
  1642. </p>
  1643. <p class=func><span class=keyword>length</span>(samples);</p>
  1644. <p class=desc>blah blah blah blah
  1645. </p>
  1646. <h3>Notes</h3>
  1647. <p></p>
  1648. </script>
  1649. <script type="text/x-red" data-template-name="AudioAnalyzePrint">
  1650. <div class="form-row">
  1651. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1652. <input type="text" id="node-input-name" placeholder="Name">
  1653. </div>
  1654. </script>
  1655. <script type="text/javascript">
  1656. RED.nodes.registerType('AudioControlSGTL5000',{
  1657. shortName: "sgtl5000",
  1658. inputs:0,
  1659. outputs:0,
  1660. category: 'control-function',
  1661. color:"#E6E0F8",
  1662. icon: "arrow-in.png"
  1663. });
  1664. </script>
  1665. <script type="text/x-red" data-help-name="AudioControlSGTL5000">
  1666. <h3>Summary</h3>
  1667. <p>Control the SGTL5000 chip on the audio shield
  1668. <a href="http://www.pjrc.com/store/teensy3_audio.html" target="_blank">audio shield</a>.
  1669. SGTL5000 is always used in slave mode, where Teensy controls
  1670. all I2S timing.
  1671. </p>
  1672. <p align=center><img src="sgtl5000closeup.jpg"></p>
  1673. <h3>Audio Connections</h3>
  1674. <p>This object has no audio inputs or outputs. Separate i2s objects
  1675. are used to send and receive audio data. I2S master mode objects
  1676. must be used, because this object configures the SGTL5000 in slave
  1677. mode, where it depends on Teensy to provide all I2S clocks.
  1678. This object controls
  1679. how the SGTL5000 will use those I2S audio streams.</p>
  1680. <h3>Functions</h3>
  1681. <p>These are the most commonly used SGTL5000 functions.</p>
  1682. <p class=func><span class=keyword>enable</span>();</p>
  1683. <p class=desc>Start the SGTL5000. This function should be called first.
  1684. </p>
  1685. <p class=func><span class=keyword>volume</span>(level);</p>
  1686. <p class=desc>Set the headphone volume level. Range is 0 to 1.0, but
  1687. 0.8 corresponds to the maximum undistorted output for a full scale
  1688. signal. Usually 0.5 is a comfortable listening level. The line
  1689. level outputs are not changed by this function.
  1690. </p>
  1691. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  1692. <p class=desc>Select which input to use: AUDIO_INPUT_LINEIN or AUDIO_INPUT_MIC.
  1693. </p>
  1694. <p class=func><span class=keyword>micGain</span>(dB);</p>
  1695. <p class=desc>When using the microphone input, set the amplifier gain.
  1696. The input number is in decibels, from 0 to 63.
  1697. </p>
  1698. <h3>Signal Levels</h3>
  1699. <p>The default signal levels should be used for most applications,
  1700. but these functions allow you to customize the analog signals.</p>
  1701. <p class=func><span class=keyword>muteHeadphone</span>();</p>
  1702. <p class=desc>Silence the headphone output.
  1703. </p>
  1704. <p class=func><span class=keyword>unmuteHeadphone</span>();</p>
  1705. <p class=desc>Turn the headphone output on.
  1706. </p>
  1707. <p class=func><span class=keyword>muteLineout</span>();</p>
  1708. <p class=desc>Silence the line level outputs.
  1709. </p>
  1710. <p class=func><span class=keyword>unmuteLineout</span>();</p>
  1711. <p class=desc>Turn the line level outputs on.
  1712. </p>
  1713. <p class=func><span class=keyword>lineInLevel</span>(both);</p>
  1714. <p class=desc style="padding-bottom:0.2em;">Adjust the sensitivity of the line-level inputs.
  1715. Fifteen settings are possible:
  1716. </p>
  1717. <pre class="desc">
  1718. 0: 3.12 Volts p-p
  1719. 1: 2.63 Volts p-p
  1720. 2: 2.22 Volts p-p
  1721. 3: 1.87 Volts p-p
  1722. 4: 1.58 Volts p-p
  1723. 5: 1.33 Volts p-p (default)
  1724. 6: 1.11 Volts p-p
  1725. 7: 0.94 Volts p-p
  1726. 8: 0.79 Volts p-p
  1727. 9: 0.67 Volts p-p
  1728. 10: 0.56 Volts p-p
  1729. 11: 0.48 Volts p-p
  1730. 12: 0.40 Volts p-p
  1731. 13: 0.34 Volts p-p
  1732. 14: 0.29 Volts p-p
  1733. 15: 0.24 Volts p-p
  1734. </pre>
  1735. <p class=func><span class=keyword>lineInLevel</span>(left, right);</p>
  1736. <p class=desc>Adjust the sensitivity of the line-level inputs, with different
  1737. settings for left and right. The same 15 settings are available.
  1738. </p>
  1739. <p class=func><span class=keyword>lineOutLevel</span>(both);</p>
  1740. <p class=desc style="padding-bottom:0.2em;">Adjust the line level output
  1741. voltage range. The following settings are possible:
  1742. </p>
  1743. <pre class="desc">
  1744. 13: 3.16 Volts p-p
  1745. 14: 2.98 Volts p-p
  1746. 15: 2.83 Volts p-p
  1747. 16: 2.67 Volts p-p
  1748. 17: 2.53 Volts p-p
  1749. 18: 2.39 Volts p-p
  1750. 19: 2.26 Volts p-p
  1751. 20: 2.14 Volts p-p
  1752. 21: 2.02 Volts p-p
  1753. 22: 1.91 Volts p-p
  1754. 23: 1.80 Volts p-p
  1755. 24: 1.71 Volts p-p
  1756. 25: 1.62 Volts p-p
  1757. 26: 1.53 Volts p-p
  1758. 27: 1.44 Volts p-p
  1759. 28: 1.37 Volts p-p
  1760. 29: 1.29 Volts p-p (default)
  1761. 30: 1.22 Volts p-p
  1762. 31: 1.16 Volts p-p
  1763. </pre>
  1764. <p class=func><span class=keyword>lineOutLevel</span>(left, right);</p>
  1765. <p class=desc>Adjust the line level outout voltage range, with separate
  1766. settings for left and right. The same settings (13 to 31) are available.
  1767. </p>
  1768. <h3>Signal Conditioning</h3>
  1769. <p>Usually these digital signal conditioning features should be left at their
  1770. default settings.
  1771. </p>
  1772. <p class=func><span class=keyword>adcHighPassFilterFreeze</span>();</p>
  1773. <p class=desc>By default, the analog input (either line-level inputs or mic)
  1774. is high-pass filtered, to remove any DC component. This function
  1775. freezes the filter, so the DC component is still substracted, but
  1776. the filter stops tracking any DC or low frequency changes.
  1777. </p>
  1778. <p class=func><span class=keyword>adcHighPassFilterDisable</span>();</p>
  1779. <p class=desc>Completely disable the analog input filter. DC and sub-audible
  1780. low frequencies are allowed to enter the digital signal.
  1781. </p>
  1782. <p class=func><span class=keyword>adcHighPassFilterEnable</span>();</p>
  1783. <p class=desc>Turn the DC-blocking filter back on, if disabled, or
  1784. allows it to resume tracking DC and low frequency changes, if
  1785. previously frozen.
  1786. </p>
  1787. <p class=func><span class=keyword>dacVolume</span>(both);</p>
  1788. <p class=desc>Normally output volume should be used with volume(), which
  1789. changes the analog gain in the headphone amplifier. This function
  1790. controls digital attenuation before conversion to analog, which
  1791. reduces resolution, but allows another fine control of output
  1792. signal level. The ranges is 0 to 1.0, with the default at 1.0.
  1793. </p>
  1794. <p class=func><span class=keyword>dacVolume</span>(left, right);</p>
  1795. <p class=desc>Adjust the digital output volume separately on left and
  1796. right channels.
  1797. </p>
  1798. <h3>Audio Processor</h3>
  1799. <p>The optional digital audio processor is capable of implementing
  1800. automatic volume control, a
  1801. simple equalizer, filtering, bass enhancement and surround sound
  1802. is available.
  1803. </p>
  1804. <p>These signal processing features are implemented in the SGTL5000 chip,
  1805. so they do not consume CPU time on Teensy.
  1806. </p>
  1807. <p class=func><span class=keyword>audioPreProcessorEnable</span>();</p>
  1808. <p class=desc>Enable the audio processor to pre-process the input
  1809. (from either line-level inputs or microphone) before it's sent
  1810. to Teensy by I2S.
  1811. </p>
  1812. <p class=func><span class=keyword>audioPostProcessorEnable</span>();</p>
  1813. <p class=desc>Enable the audio processor to post-process Teensy's
  1814. I2S output before it's turned into analog signals for the
  1815. headphones and/or line level outputs.
  1816. </p>
  1817. <p class=func><span class=keyword>audioProcessorDisable</span>();</p>
  1818. <p class=desc>Disable the audio processor.
  1819. </p>
  1820. <p class=func><span class=keyword>eqFilterCount</span>(n);</p>
  1821. <p class=desc>blah blah blah blah
  1822. </p>
  1823. <p class=func><span class=keyword>eqSelect</span>(n);</p>
  1824. <p class=desc>blah blah blah blah
  1825. </p>
  1826. <p class=func><span class=keyword>eqBand</span>(bandNum, n);</p>
  1827. <p class=desc>blah blah blah blah
  1828. </p>
  1829. <p class=func><span class=keyword>eqBands</span>(bass, mid_bass, midrange, mid_treble, treble);</p>
  1830. <p class=desc>blah blah blah blah
  1831. </p>
  1832. <p class=func><span class=keyword>eqBands</span>(bass, treble);</p>
  1833. <p class=desc>blah blah blah blah
  1834. </p>
  1835. <p class=func><span class=keyword>eqFilter</span>(filterNum, filterParameters);</p>
  1836. <p class=desc>blah blah blah blah
  1837. </p>
  1838. <p class=func><span class=keyword>autoVolumeControl</span>(maxGain, response, hardLimit, threshold, attack, decay);</p>
  1839. <p class=desc>blah blah blah blah
  1840. </p>
  1841. <p class=func><span class=keyword>autoVolumeEnable</span>();</p>
  1842. <p class=desc>blah blah blah blah
  1843. </p>
  1844. <p class=func><span class=keyword>autoVolumeDisable</span>();</p>
  1845. <p class=desc>blah blah blah blah
  1846. </p>
  1847. <p class=func><span class=keyword>enhanceBass</span>(lr_lev, bass_lev);</p>
  1848. <p class=desc>blah blah blah blah
  1849. </p>
  1850. <p class=func><span class=keyword>enhanceBass</span>(lr_lev, bass_lev, hpf_bypass, cutoff);</p>
  1851. <p class=desc>blah blah blah blah
  1852. </p>
  1853. <p class=func><span class=keyword>enhanceBassEnable</span>();</p>
  1854. <p class=desc>blah blah blah blah
  1855. </p>
  1856. <p class=func><span class=keyword>enhanceBassDisable</span>();</p>
  1857. <p class=desc>blah blah blah blah
  1858. </p>
  1859. <p class=func><span class=keyword>surroundSound</span>(width);</p>
  1860. <p class=desc>blah blah blah blah
  1861. </p>
  1862. <p class=func><span class=keyword>surroundSound</span>(width, select);</p>
  1863. <p class=desc>blah blah blah blah
  1864. </p>
  1865. <p class=func><span class=keyword>surroundSoundEnable</span>();</p>
  1866. <p class=desc>blah blah blah blah
  1867. </p>
  1868. <p class=func><span class=keyword>surroundSoundDisable</span>();</p>
  1869. <p class=desc>blah blah blah blah
  1870. </p>
  1871. <h3>Notes</h3>
  1872. <p>TODO: document the many audio processor features &amp; functions!
  1873. </p>
  1874. </script>
  1875. <script type="text/x-red" data-template-name="AudioControlSGTL5000">
  1876. <div class="form-row">
  1877. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1878. <input type="text" id="node-input-name" placeholder="Name">
  1879. </div>
  1880. </script>
  1881. <script type="text/javascript">
  1882. RED.nodes.registerType('AudioControlWM8731',{
  1883. shortName: "wm8731",
  1884. inputs:0,
  1885. outputs:0,
  1886. category: 'control-function',
  1887. color:"#E6E0F8",
  1888. icon: "arrow-in.png"
  1889. });
  1890. </script>
  1891. <script type="text/x-red" data-help-name="AudioControlWM8731">
  1892. <h3>Summary</h3>
  1893. <p>Control a WM8731 chip in slave mode, where it receives all clocks from Teensy</p>
  1894. <h3>Audio Connections</h3>
  1895. <p>This object has no audio inputs or outputs. Separate i2s objects
  1896. are used to send and receive audio data. I2S master mode objects
  1897. must be used, since this control object configures the WM8731 into
  1898. slave mode.
  1899. </p>
  1900. <h3>Functions</h3>
  1901. <p class=func><span class=keyword>enable</span>();</p>
  1902. <p class=desc>blah blah blah blah
  1903. </p>
  1904. <p class=func><span class=keyword>disable</span>();</p>
  1905. <p class=desc>not implemented
  1906. </p>
  1907. <p class=func><span class=keyword>volume</span>(level);</p>
  1908. <p class=desc>blah blah blah blah
  1909. </p>
  1910. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  1911. <p class=desc>not implemented
  1912. </p>
  1913. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  1914. <p class=desc>not implemented
  1915. </p>
  1916. <h3>Notes</h3>
  1917. <p></p>
  1918. </script>
  1919. <script type="text/x-red" data-template-name="AudioControlWM8731">
  1920. <div class="form-row">
  1921. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1922. <input type="text" id="node-input-name" placeholder="Name">
  1923. </div>
  1924. </script>
  1925. <script type="text/javascript">
  1926. RED.nodes.registerType('AudioControlWM8731master',{
  1927. shortName: "wm8731m",
  1928. inputs:0,
  1929. outputs:0,
  1930. category: 'control-function',
  1931. color:"#E6E0F8",
  1932. icon: "arrow-in.png"
  1933. });
  1934. </script>
  1935. <script type="text/x-red" data-help-name="AudioControlWM8731master">
  1936. <h3>Summary</h3>
  1937. <p>Control a WM8731 chip in master mode, where it controls all I2S timing.</p>
  1938. <h3>Audio Connections</h3>
  1939. <p>This object has no audio inputs or outputs. Separate i2s objects
  1940. are used to send and receive audio data. I2S slave mode objects
  1941. must be used, since this control object configures the WM8731 into
  1942. master mode.
  1943. </p>
  1944. <h3>Functions</h3>
  1945. <p class=func><span class=keyword>enable</span>();</p>
  1946. <p class=desc>blah blah blah blah
  1947. </p>
  1948. <p class=func><span class=keyword>disable</span>();</p>
  1949. <p class=desc>not implemented
  1950. </p>
  1951. <p class=func><span class=keyword>volume</span>(level);</p>
  1952. <p class=desc>blah blah blah blah
  1953. </p>
  1954. <p class=func><span class=keyword>inputLevel</span>(level);</p>
  1955. <p class=desc>not implemented
  1956. </p>
  1957. <p class=func><span class=keyword>inputSelect</span>(input);</p>
  1958. <p class=desc>not implemented
  1959. </p>
  1960. <h3>Notes</h3>
  1961. <p></p>
  1962. </script>
  1963. <script type="text/x-red" data-template-name="AudioControlWM8731master">
  1964. <div class="form-row">
  1965. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  1966. <input type="text" id="node-input-name" placeholder="Name">
  1967. </div>
  1968. </script>