Advertisement
Guest User

Auduino with RCArduino's PROGMEM addidions

a guest
Nov 10th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.40 KB | None | 0 0
  1. // Auduino, the Lo-Fi granular synthesiser
  2. //
  3. // by Peter Knight, Tinker.it http://tinker.it
  4. // PROGMEM additions by Duane B http://rcarduino.blogspot.com
  5. // Additional scales, customizations, and tweaks by Patrick Enright
  6. //
  7. // Help: http://code.google.com/p/tinkerit/wiki/Auduino
  8. // More help: http://groups.google.com/group/auduino
  9. //
  10. // Analog in 0: Grain 1 pitch
  11. // Analog in 1: Grain 2 decay
  12. // Analog in 2: Grain 1 decay
  13. // Analog in 3: Grain 2 pitch
  14. // Analog in 4: Grain repetition frequency
  15. //
  16. // Digital 3: Audio out (Digital 11 on ATmega8)
  17. //
  18. // Changelog:
  19. // 19 Nov 2008: Added support for ATmega8 boards
  20. // 21 Mar 2009: Added support for ATmega328 boards
  21. // 7 Apr 2009: Fixed interrupt vector for ATmega328 boards
  22. // 8 Apr 2009: Added support for ATmega1280 boards (Arduino Mega)
  23.  
  24. #include <avr/io.h>
  25. #include <avr/interrupt.h>
  26.  
  27. int scalePin =5;
  28.  
  29. uint16_t syncPhaseAcc;
  30. volatile uint16_t syncPhaseInc;
  31. uint16_t grainPhaseAcc;
  32. volatile uint16_t grainPhaseInc;
  33. uint16_t grainAmp;
  34. volatile uint8_t grainDecay;
  35. uint16_t grain2PhaseAcc;
  36. volatile uint16_t grain2PhaseInc;
  37. uint16_t grain2Amp;
  38. volatile uint8_t grain2Decay;
  39.  
  40. // Map Analogue channels
  41. #define SYNC_CONTROL (4)
  42. #define GRAIN_FREQ_CONTROL (0)
  43. #define GRAIN_DECAY_CONTROL (2)
  44. #define GRAIN2_FREQ_CONTROL (3)
  45. #define GRAIN2_DECAY_CONTROL (1)
  46.  
  47.  
  48. // Changing these will also requires rewriting audioOn()
  49.  
  50. #if defined(__AVR_ATmega8__)
  51. //
  52. // On old ATmega8 boards.
  53. // Output is on pin 11
  54. //
  55. #define LED_PIN 13
  56. #define LED_PORT PORTB
  57. #define LED_BIT 5
  58. #define PWM_PIN 11
  59. #define PWM_VALUE OCR2
  60. #define PWM_INTERRUPT TIMER2_OVF_vect
  61. #elif defined(__AVR_ATmega1280__)
  62. //
  63. // On the Arduino Mega
  64. // Output is on pin 3
  65. //
  66. #define LED_PIN 13
  67. #define LED_PORT PORTB
  68. #define LED_BIT 7
  69. #define PWM_PIN 3
  70. #define PWM_VALUE OCR3C
  71. #define PWM_INTERRUPT TIMER3_OVF_vect
  72. #else
  73. //
  74. // For modern ATmega168 and ATmega328 boards
  75. // Output is on pin 3
  76. //
  77. #define PWM_PIN 3
  78. #define PWM_VALUE OCR2B
  79. #define LED_PIN 13
  80. #define LED_PORT PORTB
  81. #define LED_BIT 5
  82. #define PWM_INTERRUPT TIMER2_OVF_vect
  83. #endif
  84.  
  85. #ifndef _NOTETABLES_
  86. #define _NOTETABLES_
  87.  
  88. #include "avr/pgmspace.h"
  89.  
  90. #define MIDI_NOTES 128
  91. // used to convert midi note numbers into the increments required to generate the note in the ISR
  92. PROGMEM unsigned int midiNoteToWavePhaseIncrement[MIDI_NOTES] =
  93. {
  94. 66 // C 0, 8.18,66.98,66 C
  95. ,70 // C# 1, 8.66,70.96,70
  96. ,75 // D 2, 9.18,75.18,75
  97. ,79 // D# 3, 9.72,79.65,79
  98. ,84 // E 4, 10.30,84.38,84
  99. ,89 // F 5, 10.91,89.40,89
  100. ,94 // F# 6, 11.56,94.72,94
  101. ,100 // G 7, 12.25,100.35,100
  102. ,106 // G# 8, 12.98,106.32,106
  103. ,112 // A 9, 13.75,112.64,112
  104. ,119 // A# 10, 14.57,119.34,119
  105. ,126 // B 11, 15.43,126.43,126
  106. ,133 // C0 12, 16.35,133.95,133 C0
  107. ,141 // C#0 13, 17.32,141.92,141
  108. ,150 // D0 14, 18.35,150.35,150
  109. ,159 // D#0 15, 19.45,159.29,159
  110. ,168 // E0 16, 20.60,168.77,168
  111. ,178 // F0 17, 21.83,178.80,178
  112. ,189 // F#0 18, 23.12,189.43,189
  113. ,200 // G0 19, 24.50,200.70,200
  114. ,212 // G#0 20, 25.96,212.63,212
  115. ,225 // A0 21, 27.50,225.28,225
  116. ,238 // A#0 22, 29.14,238.67,238
  117. ,252 // B0 23, 30.87,252.86,252
  118. ,267 // C1 24, 32.70,267.90,267 C1
  119. ,283 // C#1 25, 34.65,283.83,283
  120. ,300 // D1 26, 36.71,300.71,300
  121. ,318 // D#1 27, 38.89,318.59,318
  122. ,337 // E1 28, 41.20,337.53,337
  123. ,357 // F1 29, 43.65,357.60,357
  124. ,378 // F#1 30, 46.25,378.87,378
  125. ,401 // G1 31, 49.00,401.40,401
  126. ,425 // G#1 32, 51.91,425.27,425
  127. ,450 // A1 33, 55.00,450.55,450
  128. ,477 // A#1 34, 58.27,477.34,477
  129. ,505 // B1 35, 61.74,505.73,505
  130. ,535 // C2 36, 65.41,535.80,535 C2
  131. ,567 // C#2 37, 69.30,567.66,567
  132. ,601 // D2 38, 73.42,601.42,601
  133. ,637 // D#2 39, 77.78,637.18,637
  134. ,675 // E2 40, 82.41,675.07,675
  135. ,715 // F2 41, 87.31,715.21,715
  136. ,757 // F#2 42, 92.50,757.74,757
  137. ,802 // G2 43, 98.00,802.79,802
  138. ,850 // G#2 44, 103.83,850.53,850
  139. ,901 // A2 45, 110.00,901.11,901
  140. ,954 // A#2 46, 116.54,954.69,954
  141. ,1011 // B2 47, 123.47,1011.46,1011
  142. ,1071 // C3 48, 130.81,1071.60,1071 C3
  143. ,1135 // C#3 49, 138.59,1135.32,1135
  144. ,1202 // D3 50, 146.83,1202.83,1202
  145. ,1274 // D#3 51, 155.56,1274.36,1274
  146. ,1350 // E3 52, 164.81,1350.13,1350
  147. ,1430 // F3 53, 174.61,1430.42,1430
  148. ,1515 // F#3 54, 185.00,1515.47,1515
  149. ,1605 // G3 55, 196.00,1605.59,1605
  150. ,1701 // G#3 56, 207.65,1701.06,1701
  151. ,1802 // A3 57, 220.00,1802.21,1802
  152. ,1909 // A#3 58, 233.08,1909.38,1909
  153. ,2022 // B3 59, 246.94,2022.92,2022
  154. ,2143 // C4 60, 261.63,2143.20,2143 C4
  155. ,2270 // C#4 61, 277.18,2270.64,2270
  156. ,2405 // D4 62, 293.66,2405.66,2405
  157. ,2548 // D#4 63, 311.13,2548.71,2548
  158. ,2700 // E4 64, 329.63,2700.27,2700
  159. ,2860 // F4 65, 349.23,2860.83,2860
  160. ,3030 // F#4 66, 369.99,3030.95,3030
  161. ,3211 // G4 67, 392.00,3211.18,3211
  162. ,3402 // G#4 68, 415.30,3402.12,3402
  163. ,3604 // A4 69, 440.00,3604.42,3604
  164. ,3818 // A#4 70, 466.16,3818.75,3818
  165. ,4045 // B4 71, 493.88,4045.83,4045
  166. ,4286 // C5 72, 523.25,4286.41,4286 C5
  167. ,4541 // C#5 73, 554.37,4541.29,4541
  168. ,4811 // D5 74, 587.33,4811.33,4811
  169. ,5097 // D#5 75, 622.25,5097.42,5097
  170. ,5400 // E5 76, 659.26,5400.53,5400
  171. ,5721 // F5 77, 698.46,5721.67,5721
  172. ,6061 // F#5 78, 739.99,6061.89,6061
  173. ,6422 // G5 79, 783.99,6422.36,6422
  174. ,6804 // G#5 80, 830.61,6804.25,6804
  175. ,7208 // A5 81, 880.00,7208.85,7208
  176. ,7637 // A#5 82, 932.33,7637.51,7637
  177. ,8091 // B5 83, 987.77,8091.66,8091
  178. ,8572 // C6 84, 1046.50,8572.82,8572 C6
  179. ,9082 // C#6 85, 1108.73,9082.58,9082
  180. ,9622 // D6 86, 1174.66,9622.66,9622
  181. ,10194 // D#6 87, 1244.51,10194.85,10194
  182. ,10801 // E6 88, 1318.51,10801.07,10801
  183. ,11443 // F6 89, 1396.91,11443.33,11443
  184. ,12123 // F#6 90, 1479.98,12123.79,12123
  185. ,12844 // G6 91, 1567.98,12844.71,12844
  186. ,13608 // G#6 92, 1661.22,13608.50,13608
  187. ,14417 // A6 93, 1760.00,14417.70,14417
  188. ,15275 // A#6 94, 1864.65,15275.02,15275
  189. ,16183 // B6 95, 1975.53,16183.31,16183
  190. ,17145 // C7 96, 2093.00,17145.63,17145 C7
  191. ,18165 // C#7 97, 2217.46,18165.16,18165
  192. ,19245 // D7 98, 2349.32,19245.31,19245
  193. ,20389 // D#7 99, 2489.01,20389.70,20389
  194. ,21602 // E7 100, 2637.02,21602.14,21602
  195. ,22886 // F7 101, 2793.83,22886.67,22886
  196. ,24247 // F#7 102, 2959.95,24247.58,24247
  197. ,25689 // G7 103, 3135.96,25689.42,25689
  198. ,27216 // G#7 104, 3322.44,27216.99,27216
  199. ,28835 // A7 105, 3520.00,28835.39,28835
  200. ,30550 // A#7 106, 3729.31,30550.04,30550
  201. ,32366 // B7 107, 3951.06,32366.63,32366
  202. ,34291 // C8 108, 4186.01,34291.26,34291 C8
  203. ,36330 // C#8 109, 4434.92,36330.32,36330
  204. ,38490 // D8 110, 4698.64,38490.65,38490
  205. ,40779 // D#8 111, 4978.03,40779.41,40779
  206. ,43204 // E8 112, 5274.04,43204.25,43204
  207. ,45773 // F8 113, 5587.65,45773.32,45773
  208. ,48495 // F#8 114, 5919.91,48495.14,48495
  209. ,51378 // G8 115, 6271.92,51378.79,51378
  210. ,54433 // G#8 116, 6644.87,54433.96,54433
  211. ,57670 // A8 117, 7040.00,57670.76,57670
  212. ,61100 // A#8 118, 7458.62,61100.07,61100
  213. ,64733 // B8 119, 7902.13,64733.26,64733
  214. ,3046 // C9 120, 8372.02,68582.53,3046 C9
  215. ,7124 // C#9 121, 8869.84,72660.64,7124
  216. ,11445 // D9 122, 9397.27,76981.30,11445
  217. ,16022 // D#9 123, 9956.06,81558.77,16022
  218. ,20872 // E9 124, 10548.07,86408.50,20872
  219. ,26010 // F9 125, 11175.30,91546.65,26010
  220. ,31454 // F#9 126, 11839.81,96990.28,31454
  221. ,31454 // G9 127, 11839.81,96990.28,31454 // this is wrong, need to calculate correct value, even though at 8Khz its wrapping around on every tick
  222. };
  223.  
  224. unsigned int getMidiNotePhaseIncrement(unsigned char sNote)
  225. {
  226. return pgm_read_word(midiNoteToWavePhaseIncrement + (sNote));
  227. }
  228.  
  229. // Major keys
  230. // Key of C ........C D E F G A B
  231. PROGMEM unsigned char majorC[29] = {
  232. 48, 50, 52, 53, 55, 57, 59,
  233. 60, 62, 64, 65, 67, 69, 71,
  234. 72, 74, 76, 77, 79, 81, 83,
  235. 84, 86, 88, 89, 91, 93, 95, 96
  236. };
  237.  
  238. unsigned int getMajorC(unsigned int nAnalogInput)
  239. {
  240. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  241. uint8_t sMidiIndex = pgm_read_byte(majorC + sPentatonicNote);
  242. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  243. }
  244.  
  245. // Key of G ........G A B C D E F#
  246. PROGMEM unsigned char majorG[29] = {
  247. 55, 57, 59, 48, 50, 52, 54,
  248. 67, 69, 71, 72, 74, 76, 78,
  249. 79, 81, 83, 84, 86, 88, 90,
  250. 91, 93, 95, 96, 98, 100, 102, 103,
  251. };
  252.  
  253. unsigned int getMajorG(unsigned int nAnalogInput)
  254. {
  255. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  256. uint8_t sMidiIndex = pgm_read_byte(majorG + sPentatonicNote);
  257. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  258. }
  259.  
  260. // Key of D ........D E F# G A B C#
  261. PROGMEM unsigned char majorD[29] = {
  262. 50, 52, 54, 55, 57, 59, 61,
  263. 62, 64, 66, 67, 69, 71, 73,
  264. 74, 76, 78, 79, 81, 83, 85,
  265. 86, 88, 90, 91, 93, 95, 97, 98,
  266. };
  267.  
  268. unsigned int getMajorD(unsigned int nAnalogInput)
  269. {
  270. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  271. uint8_t sMidiIndex = pgm_read_byte(majorD + sPentatonicNote);
  272. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  273. }
  274.  
  275. // Key of A ........A B C# D E F# G#
  276. PROGMEM unsigned char majorA[29] = {
  277. 57, 59, 61, 62, 64, 66, 68,
  278. 69, 71, 73, 74, 76, 78, 80,
  279. 81, 83, 85, 86, 88, 90, 92,
  280. 93, 95, 97, 98, 100, 102, 104, 105,
  281. };
  282.  
  283. unsigned int getMajorA(unsigned int nAnalogInput)
  284. {
  285. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  286. uint8_t sMidiIndex = pgm_read_byte(majorA + sPentatonicNote);
  287. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  288. }
  289.  
  290. // Key of E ........E F# G# A B C# D#
  291. PROGMEM unsigned char majorE[29] = {
  292. 52, 54, 56, 57, 59, 61, 63,
  293. 64, 66, 68, 69, 71, 73, 75,
  294. 76, 78, 80, 81, 83, 85, 87,
  295. 88, 90, 92, 93, 95, 97, 99, 100
  296. };
  297.  
  298. unsigned int getMajorE(unsigned int nAnalogInput)
  299. {
  300. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  301. uint8_t sMidiIndex = pgm_read_byte(majorE + sPentatonicNote);
  302. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  303. }
  304.  
  305. // Key of B ........B C# D# E F# G# A#
  306. PROGMEM unsigned char majorB[29] = {
  307. 59, 61, 63, 64, 66, 68, 70,
  308. 71, 73, 75, 76, 78, 80, 82,
  309. 83, 85, 87, 88, 90, 92, 94,
  310. 95, 97, 99, 100, 102, 104, 106, 107
  311. };
  312.  
  313. unsigned int getMajorB(unsigned int nAnalogInput)
  314. {
  315. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  316. uint8_t sMidiIndex = pgm_read_byte(majorB + sPentatonicNote);
  317. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  318. }
  319.  
  320. // Key of F# ........F# G# A# B C# D# E#
  321. PROGMEM unsigned char majorFs[29] = {
  322. 54, 56, 58, 59, 61, 63, 65,
  323. 66, 68, 70, 71, 73, 75, 77,
  324. 78, 80, 82, 83, 85, 87, 89,
  325. 90, 92, 94, 95, 97, 99, 101, 102,
  326. };
  327.  
  328. unsigned int getMajorFs(unsigned int nAnalogInput)
  329. {
  330. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  331. uint8_t sMidiIndex = pgm_read_byte(majorFs + sPentatonicNote);
  332. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  333. }
  334.  
  335. // Key of Db ........C# D# F F# G# A# C
  336. PROGMEM unsigned char majorDb[29] = {
  337. 49, 51, 53, 54, 56, 58, 48,
  338. 61, 63, 65, 66, 68, 70, 60,
  339. 73, 75, 77, 78, 80, 82, 72,
  340. 85, 87, 89, 90, 92, 94, 84, 97
  341. };
  342.  
  343. unsigned int getMajorDb(unsigned int nAnalogInput)
  344. {
  345. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  346. uint8_t sMidiIndex = pgm_read_byte(majorDb + sPentatonicNote);
  347. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  348. }
  349.  
  350. // Key of Ab ........G# A# C C# D# F G
  351. PROGMEM unsigned char majorAb[29] = {
  352. 56, 58, 48, 61, 63, 65, 67,
  353. 68, 70, 60, 73, 75, 77, 79,
  354. 80, 82, 72, 85, 87, 89, 91,
  355. 92, 94, 84, 97, 99, 101, 103, 104
  356. };
  357.  
  358. unsigned int getMajorAb(unsigned int nAnalogInput)
  359. {
  360. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  361. uint8_t sMidiIndex = pgm_read_byte(majorAb + sPentatonicNote);
  362. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  363. }
  364.  
  365. // Key of Eb ........D# F G G# A# C D
  366. PROGMEM unsigned char majorEb[29] = {
  367. 51, 53, 55, 56, 58, 48, 62,
  368. 63, 65, 67, 68, 70, 60, 74,
  369. 75, 77, 79, 80, 82, 72, 86,
  370. 87, 89, 91, 92, 94, 84, 98, 99
  371. };
  372.  
  373. unsigned int getMajorEb(unsigned int nAnalogInput)
  374. {
  375. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  376. uint8_t sMidiIndex = pgm_read_byte(majorEb + sPentatonicNote);
  377. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  378. }
  379.  
  380. // Key of Bb ........A# C D D# F G A
  381. PROGMEM unsigned char majorBb[29] = {
  382. 58, 48, 62, 63, 65, 67, 69,
  383. 70, 60, 74, 75, 77, 79, 81,
  384. 82, 72, 86, 87, 89, 91, 93,
  385. 94, 84, 98, 99, 101, 103, 105, 106
  386. };
  387.  
  388. unsigned int getMajorBb(unsigned int nAnalogInput)
  389. {
  390. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  391. uint8_t sMidiIndex = pgm_read_byte(majorBb + sPentatonicNote);
  392. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  393. }
  394.  
  395. // Key of F ........F G A A# C D E
  396. PROGMEM unsigned char majorF[29] = {
  397. 53, 55, 57, 58, 48, 62, 64,
  398. 65, 67, 69, 70, 60, 74, 76,
  399. 77, 79, 81, 82, 72, 86, 88,
  400. 89, 91, 93, 94, 84, 98, 100, 101
  401. };
  402.  
  403. unsigned int getMajorF(unsigned int nAnalogInput)
  404. {
  405. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  406. uint8_t sMidiIndex = pgm_read_byte(majorF + sPentatonicNote);
  407. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  408. }
  409.  
  410. // Half Whole Diminished keys
  411. // Key of C ........C D E F G A B
  412. PROGMEM unsigned char dimC[29] = {
  413. 48, 50, 52, 53, 55, 57, 59,
  414. 60, 62, 64, 65, 67, 69, 71,
  415. 72, 74, 76, 77, 79, 81, 83,
  416. 84, 86, 88, 89, 91, 93, 95, 96
  417. };
  418.  
  419. unsigned int getDimC(unsigned int nAnalogInput)
  420. {
  421. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  422. uint8_t sMidiIndex = pgm_read_byte(dimC + sPentatonicNote);
  423. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  424. }
  425.  
  426. // Key of G ........G A B C D E F#
  427. PROGMEM unsigned char dimG[29] = {
  428. 55, 57, 59, 48, 50, 52, 54,
  429. 67, 69, 71, 72, 74, 76, 78,
  430. 79, 81, 83, 84, 86, 88, 90,
  431. 91, 93, 95, 96, 98, 100, 102, 103,
  432. };
  433.  
  434. unsigned int getDimG(unsigned int nAnalogInput)
  435. {
  436. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  437. uint8_t sMidiIndex = pgm_read_byte(dimG + sPentatonicNote);
  438. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  439. }
  440.  
  441. // Key of D ........D E F# G A B C#
  442. PROGMEM unsigned char dimD[29] = {
  443. 50, 52, 54, 55, 57, 59, 61,
  444. 62, 64, 66, 67, 69, 71, 73,
  445. 74, 76, 78, 79, 81, 83, 85,
  446. 86, 88, 90, 91, 93, 95, 97, 98,
  447. };
  448.  
  449. unsigned int getDimD(unsigned int nAnalogInput)
  450. {
  451. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  452. uint8_t sMidiIndex = pgm_read_byte(dimD + sPentatonicNote);
  453. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  454. }
  455.  
  456. // Key of A ........A B C# D E F# G#
  457. PROGMEM unsigned char dimA[29] = {
  458. 57, 59, 61, 62, 64, 66, 68,
  459. 69, 71, 73, 74, 76, 78, 80,
  460. 81, 83, 85, 86, 88, 90, 92,
  461. 93, 95, 97, 98, 100, 102, 104, 105,
  462. };
  463.  
  464. unsigned int getDimA(unsigned int nAnalogInput)
  465. {
  466. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  467. uint8_t sMidiIndex = pgm_read_byte(dimA + sPentatonicNote);
  468. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  469. }
  470.  
  471. // Key of E ........E F# G# A B C# D#
  472. PROGMEM unsigned char dimE[29] = {
  473. 52, 54, 56, 57, 59, 61, 63,
  474. 64, 66, 68, 69, 71, 73, 75,
  475. 76, 78, 80, 81, 83, 85, 87,
  476. 88, 90, 92, 93, 95, 97, 99, 100
  477. };
  478.  
  479. unsigned int getDimE(unsigned int nAnalogInput)
  480. {
  481. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  482. uint8_t sMidiIndex = pgm_read_byte(dimE + sPentatonicNote);
  483. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  484. }
  485.  
  486. // Key of B ........B C# D# E F# G# A#
  487. PROGMEM unsigned char dimB[29] = {
  488. 59, 61, 63, 64, 66, 68, 70,
  489. 71, 73, 75, 76, 78, 80, 82,
  490. 83, 85, 87, 88, 90, 92, 94,
  491. 95, 97, 99, 100, 102, 104, 106, 107
  492. };
  493.  
  494. unsigned int getDimB(unsigned int nAnalogInput)
  495. {
  496. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  497. uint8_t sMidiIndex = pgm_read_byte(dimB + sPentatonicNote);
  498. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  499. }
  500.  
  501. // Key of F# ........F# G# A# B C# D# E#
  502. PROGMEM unsigned char dimFs[29] = {
  503. 54, 56, 58, 59, 61, 63, 65,
  504. 66, 68, 70, 71, 73, 75, 77,
  505. 78, 80, 82, 83, 85, 87, 89,
  506. 90, 92, 94, 95, 97, 99, 101, 102,
  507. };
  508.  
  509. unsigned int getDimFs(unsigned int nAnalogInput)
  510. {
  511. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  512. uint8_t sMidiIndex = pgm_read_byte(dimFs + sPentatonicNote);
  513. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  514. }
  515.  
  516. // Key of Db ........C# D# F F# G# A# C
  517. PROGMEM unsigned char dimDb[29] = {
  518. 49, 51, 53, 54, 56, 58, 48,
  519. 61, 63, 65, 66, 68, 70, 60,
  520. 73, 75, 77, 78, 80, 82, 72,
  521. 85, 87, 89, 90, 92, 94, 84, 97
  522. };
  523.  
  524. unsigned int getDimDb(unsigned int nAnalogInput)
  525. {
  526. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  527. uint8_t sMidiIndex = pgm_read_byte(dimDb + sPentatonicNote);
  528. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  529. }
  530.  
  531. // Key of Ab ........G# A# C C# D# F G
  532. PROGMEM unsigned char dimAb[29] = {
  533. 56, 58, 48, 61, 63, 65, 67,
  534. 68, 70, 60, 73, 75, 77, 79,
  535. 80, 82, 72, 85, 87, 89, 91,
  536. 92, 94, 84, 97, 99, 101, 103, 104
  537. };
  538.  
  539. unsigned int getDimAb(unsigned int nAnalogInput)
  540. {
  541. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  542. uint8_t sMidiIndex = pgm_read_byte(dimAb + sPentatonicNote);
  543. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  544. }
  545.  
  546. // Key of Eb ........D# F G G# A# C D
  547. PROGMEM unsigned char dimEb[29] = {
  548. 51, 53, 55, 56, 58, 48, 62,
  549. 63, 65, 67, 68, 70, 60, 74,
  550. 75, 77, 79, 80, 82, 72, 86,
  551. 87, 89, 91, 92, 94, 84, 98, 99
  552. };
  553.  
  554. unsigned int getDimEb(unsigned int nAnalogInput)
  555. {
  556. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  557. uint8_t sMidiIndex = pgm_read_byte(dimEb + sPentatonicNote);
  558. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  559. }
  560.  
  561. // Key of Bb ........A# C D D# F G A
  562. PROGMEM unsigned char dimBb[29] = {
  563. 58, 48, 62, 63, 65, 67, 69,
  564. 70, 60, 74, 75, 77, 79, 81,
  565. 82, 72, 86, 87, 89, 91, 93,
  566. 94, 84, 98, 99, 101, 103, 105, 106
  567. };
  568.  
  569. unsigned int getDimBb(unsigned int nAnalogInput)
  570. {
  571. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  572. uint8_t sMidiIndex = pgm_read_byte(dimBb + sPentatonicNote);
  573. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  574. }
  575.  
  576. // Key of F ........F G A A# C D E
  577. PROGMEM unsigned char dimF[29] = {
  578. 53, 55, 57, 58, 48, 62, 64,
  579. 65, 67, 69, 70, 60, 74, 76,
  580. 77, 79, 81, 82, 72, 86, 88,
  581. 89, 91, 93, 94, 84, 98, 100, 101
  582. };
  583.  
  584. unsigned int getDimF(unsigned int nAnalogInput)
  585. {
  586. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  587. uint8_t sMidiIndex = pgm_read_byte(dimF + sPentatonicNote);
  588. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  589. }
  590.  
  591. // Minor Pentatonic Keys
  592. // Key of C ........C D E F G A B
  593. PROGMEM unsigned char pentC[29] = {
  594. 48, 50, 52, 53, 55, 57, 59,
  595. 60, 62, 64, 65, 67, 69, 71,
  596. 72, 74, 76, 77, 79, 81, 83,
  597. 84, 86, 88, 89, 91, 93, 95, 96
  598. };
  599.  
  600. unsigned int getPentC(unsigned int nAnalogInput)
  601. {
  602. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  603. uint8_t sMidiIndex = pgm_read_byte(pentC + sPentatonicNote);
  604. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  605. }
  606.  
  607. // Key of G ........G A B C D E F#
  608. PROGMEM unsigned char pentG[29] = {
  609. 55, 57, 59, 48, 50, 52, 54,
  610. 67, 69, 71, 72, 74, 76, 78,
  611. 79, 81, 83, 84, 86, 88, 90,
  612. 91, 93, 95, 96, 98, 100, 102, 103,
  613. };
  614.  
  615. unsigned int getPentG(unsigned int nAnalogInput)
  616. {
  617. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  618. uint8_t sMidiIndex = pgm_read_byte(pentG + sPentatonicNote);
  619. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  620. }
  621.  
  622. // Key of D ........D E F# G A B C#
  623. PROGMEM unsigned char pentD[29] = {
  624. 50, 52, 54, 55, 57, 59, 61,
  625. 62, 64, 66, 67, 69, 71, 73,
  626. 74, 76, 78, 79, 81, 83, 85,
  627. 86, 88, 90, 91, 93, 95, 97, 98,
  628. };
  629.  
  630. unsigned int getPentD(unsigned int nAnalogInput)
  631. {
  632. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  633. uint8_t sMidiIndex = pgm_read_byte(pentD + sPentatonicNote);
  634. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  635. }
  636.  
  637. // Key of A ........A B C# D E F# G#
  638. PROGMEM unsigned char pentA[29] = {
  639. 57, 59, 61, 62, 64, 66, 68,
  640. 69, 71, 73, 74, 76, 78, 80,
  641. 81, 83, 85, 86, 88, 90, 92,
  642. 93, 95, 97, 98, 100, 102, 104, 105,
  643. };
  644.  
  645. unsigned int getPentA(unsigned int nAnalogInput)
  646. {
  647. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  648. uint8_t sMidiIndex = pgm_read_byte(pentA + sPentatonicNote);
  649. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  650. }
  651.  
  652. // Key of E ........E F# G# A B C# D#
  653. PROGMEM unsigned char pentE[29] = {
  654. 52, 54, 56, 57, 59, 61, 63,
  655. 64, 66, 68, 69, 71, 73, 75,
  656. 76, 78, 80, 81, 83, 85, 87,
  657. 88, 90, 92, 93, 95, 97, 99, 100
  658. };
  659.  
  660. unsigned int getPentE(unsigned int nAnalogInput)
  661. {
  662. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  663. uint8_t sMidiIndex = pgm_read_byte(pentE + sPentatonicNote);
  664. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  665. }
  666.  
  667. // Key of B ........B C# D# E F# G# A#
  668. PROGMEM unsigned char pentB[29] = {
  669. 59, 61, 63, 64, 66, 68, 70,
  670. 71, 73, 75, 76, 78, 80, 82,
  671. 83, 85, 87, 88, 90, 92, 94,
  672. 95, 97, 99, 100, 102, 104, 106, 107
  673. };
  674.  
  675. unsigned int getPentB(unsigned int nAnalogInput)
  676. {
  677. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  678. uint8_t sMidiIndex = pgm_read_byte(pentB + sPentatonicNote);
  679. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  680. }
  681.  
  682. // Key of F# ........F# G# A# B C# D# E#
  683. PROGMEM unsigned char pentFs[29] = {
  684. 54, 56, 58, 59, 61, 63, 65,
  685. 66, 68, 70, 71, 73, 75, 77,
  686. 78, 80, 82, 83, 85, 87, 89,
  687. 90, 92, 94, 95, 97, 99, 101, 102,
  688. };
  689.  
  690. unsigned int getPentFs(unsigned int nAnalogInput)
  691. {
  692. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  693. uint8_t sMidiIndex = pgm_read_byte(pentFs + sPentatonicNote);
  694. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  695. }
  696.  
  697. // Key of Db ........C# D# F F# G# A# C
  698. PROGMEM unsigned char pentDb[29] = {
  699. 49, 51, 53, 54, 56, 58, 48,
  700. 61, 63, 65, 66, 68, 70, 60,
  701. 73, 75, 77, 78, 80, 82, 72,
  702. 85, 87, 89, 90, 92, 94, 84, 97
  703. };
  704.  
  705. unsigned int getPentDb(unsigned int nAnalogInput)
  706. {
  707. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  708. uint8_t sMidiIndex = pgm_read_byte(pentDb + sPentatonicNote);
  709. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  710. }
  711.  
  712. // Key of Ab ........G# A# C C# D# F G
  713. PROGMEM unsigned char pentAb[29] = {
  714. 56, 58, 48, 61, 63, 65, 67,
  715. 68, 70, 60, 73, 75, 77, 79,
  716. 80, 82, 72, 85, 87, 89, 91,
  717. 92, 94, 84, 97, 99, 101, 103, 104
  718. };
  719.  
  720. unsigned int getPentAb(unsigned int nAnalogInput)
  721. {
  722. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  723. uint8_t sMidiIndex = pgm_read_byte(pentAb + sPentatonicNote);
  724. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  725. }
  726.  
  727. // Key of Eb ........D# F G G# A# C D
  728. PROGMEM unsigned char pentEb[29] = {
  729. 51, 53, 55, 56, 58, 48, 62,
  730. 63, 65, 67, 68, 70, 60, 74,
  731. 75, 77, 79, 80, 82, 72, 86,
  732. 87, 89, 91, 92, 94, 84, 98, 99
  733. };
  734.  
  735. unsigned int getPentEb(unsigned int nAnalogInput)
  736. {
  737. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  738. uint8_t sMidiIndex = pgm_read_byte(pentEb + sPentatonicNote);
  739. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  740. }
  741.  
  742. // Key of Bb ........A# C D D# F G A
  743. PROGMEM unsigned char pentBb[29] = {
  744. 58, 48, 62, 63, 65, 67, 69,
  745. 70, 60, 74, 75, 77, 79, 81,
  746. 82, 72, 86, 87, 89, 91, 93,
  747. 94, 84, 98, 99, 101, 103, 105, 106
  748. };
  749.  
  750. unsigned int getPentBb(unsigned int nAnalogInput)
  751. {
  752. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  753. uint8_t sMidiIndex = pgm_read_byte(pentBb + sPentatonicNote);
  754. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  755. }
  756.  
  757. // Key of F ........F G A A# C D E
  758. PROGMEM unsigned char pentF[29] = {
  759. 53, 55, 57, 58, 48, 62, 64,
  760. 65, 67, 69, 70, 60, 74, 76,
  761. 77, 79, 81, 82, 72, 86, 88,
  762. 89, 91, 93, 94, 84, 98, 100, 101
  763. };
  764.  
  765. unsigned int getPentF(unsigned int nAnalogInput)
  766. {
  767. uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,29);
  768. uint8_t sMidiIndex = pgm_read_byte(pentF + sPentatonicNote);
  769. return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
  770. }
  771.  
  772. #endif
  773.  
  774. // Smooth logarithmic mapping
  775. //
  776. uint16_t antilogTable[] = {
  777. 64830,64132,63441,62757,62081,61413,60751,60097,59449,58809,58176,57549,56929,56316,55709,55109,
  778. 54515,53928,53347,52773,52204,51642,51085,50535,49991,49452,48920,48393,47871,47356,46846,46341,
  779. 45842,45348,44859,44376,43898,43425,42958,42495,42037,41584,41136,40693,40255,39821,39392,38968,
  780. 38548,38133,37722,37316,36914,36516,36123,35734,35349,34968,34591,34219,33850,33486,33125,32768
  781. };
  782. uint16_t mapPhaseInc(uint16_t input) {
  783. return (antilogTable[input & 0x3f]) >> (input >> 6);
  784. }
  785.  
  786. void audioOn() {
  787. #if defined(__AVR_ATmega8__)
  788. // ATmega8 has different registers
  789. TCCR2 = _BV(WGM20) | _BV(COM21) | _BV(CS20);
  790. TIMSK = _BV(TOIE2);
  791. #elif defined(__AVR_ATmega1280__)
  792. TCCR3A = _BV(COM3C1) | _BV(WGM30);
  793. TCCR3B = _BV(CS30);
  794. TIMSK3 = _BV(TOIE3);
  795. #else
  796. // Set up PWM to 31.25kHz, phase accurate
  797. TCCR2A = _BV(COM2B1) | _BV(WGM20);
  798. TCCR2B = _BV(CS20);
  799. TIMSK2 = _BV(TOIE2);
  800. #endif
  801. }
  802.  
  803.  
  804. void setup() {
  805. pinMode(PWM_PIN,OUTPUT);
  806. audioOn();
  807. pinMode(LED_PIN,OUTPUT);
  808. }
  809.  
  810. void loop() {
  811. // The loop is pretty simple - it just updates the parameters for the oscillators.
  812. //
  813. // Avoid using any functions that make extensive use of interrupts, or turn interrupts off.
  814. // They will cause clicks and poops in the audio.
  815.  
  816. // Smooth frequency mapping
  817. //syncPhaseInc = mapPhaseInc(analogRead(SYNC_CONTROL)) / 4;
  818.  
  819. // Stepped mapping to MIDI notes: C, Db, D, Eb, E, F...
  820. //syncPhaseInc = mapMidi(analogRead(SYNC_CONTROL));
  821.  
  822. // Stepped pentatonic mapping: D, E, G, A, B
  823. //syncPhaseInc = getPentatonicPhaseIncrement(analogRead(SYNC_CONTROL));
  824.  
  825. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  826. // reads the scale select pin, converts input to 36 choices +
  827. // reads the converted input to select a scale from the +
  828. // corresponding case. +
  829. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  830.  
  831. int scale = analogRead(scalePin);
  832. scale = constrain(scale, 0, 1023);
  833. int scaleSelect = map(scale, 0, 1024, 0, 35);
  834.  
  835. switch (scaleSelect) {
  836. case 0:
  837. syncPhaseInc = getMajorC(analogRead(SYNC_CONTROL));
  838. break;
  839. case 1:
  840. syncPhaseInc = getMajorG(analogRead(SYNC_CONTROL));
  841. break;
  842. case 2:
  843. syncPhaseInc = getMajorD(analogRead(SYNC_CONTROL));
  844. break;
  845. case 3:
  846. syncPhaseInc = getMajorA(analogRead(SYNC_CONTROL));
  847. break;
  848. case 4:
  849. syncPhaseInc = getMajorE(analogRead(SYNC_CONTROL));
  850. break;
  851. case 5:
  852. syncPhaseInc = getMajorB(analogRead(SYNC_CONTROL));
  853. break;
  854. case 6:
  855. syncPhaseInc = getMajorFs(analogRead(SYNC_CONTROL));
  856. break;
  857. case 7:
  858. syncPhaseInc = getMajorDb(analogRead(SYNC_CONTROL));
  859. break;
  860. case 8:
  861. syncPhaseInc = getMajorAb(analogRead(SYNC_CONTROL));
  862. break;
  863. case 9:
  864. syncPhaseInc = getMajorEb(analogRead(SYNC_CONTROL));
  865. break;
  866. case 10:
  867. syncPhaseInc = getMajorBb(analogRead(SYNC_CONTROL));
  868. break;
  869. case 11:
  870. syncPhaseInc = getMajorF(analogRead(SYNC_CONTROL));
  871. break;
  872. case 12:
  873. syncPhaseInc = getMajorC(analogRead(SYNC_CONTROL));
  874. break;
  875. case 13:
  876. syncPhaseInc = getMajorG(analogRead(SYNC_CONTROL));
  877. break;
  878. case 14:
  879. syncPhaseInc = getMajorD(analogRead(SYNC_CONTROL));
  880. break;
  881. case 15:
  882. syncPhaseInc = getMajorA(analogRead(SYNC_CONTROL));
  883. break;
  884. case 16:
  885. syncPhaseInc = getMajorE(analogRead(SYNC_CONTROL));
  886. break;
  887. case 17:
  888. syncPhaseInc = getMajorB(analogRead(SYNC_CONTROL));
  889. break;
  890. case 18:
  891. syncPhaseInc = getMajorFs(analogRead(SYNC_CONTROL));
  892. break;
  893. case 19:
  894. syncPhaseInc = getMajorDb(analogRead(SYNC_CONTROL));
  895. break;
  896. case 20:
  897. syncPhaseInc = getMajorAb(analogRead(SYNC_CONTROL));
  898. break;
  899. case 21:
  900. syncPhaseInc = getMajorEb(analogRead(SYNC_CONTROL));
  901. break;
  902. case 22:
  903. syncPhaseInc = getMajorBb(analogRead(SYNC_CONTROL));
  904. break;
  905. case 23:
  906. syncPhaseInc = getMajorF(analogRead(SYNC_CONTROL));
  907. break;
  908. case 24:
  909. syncPhaseInc = getMajorC(analogRead(SYNC_CONTROL));
  910. break;
  911. case 25:
  912. syncPhaseInc = getMajorG(analogRead(SYNC_CONTROL));
  913. break;
  914. case 26:
  915. syncPhaseInc = getMajorD(analogRead(SYNC_CONTROL));
  916. break;
  917. case 27:
  918. syncPhaseInc = getMajorA(analogRead(SYNC_CONTROL));
  919. break;
  920. case 28:
  921. syncPhaseInc = getMajorE(analogRead(SYNC_CONTROL));
  922. break;
  923. case 29:
  924. syncPhaseInc = getMajorB(analogRead(SYNC_CONTROL));
  925. break;
  926. case 30:
  927. syncPhaseInc = getMajorFs(analogRead(SYNC_CONTROL));
  928. break;
  929. case 31:
  930. syncPhaseInc = getMajorDb(analogRead(SYNC_CONTROL));
  931. break;
  932. case 32:
  933. syncPhaseInc = getMajorAb(analogRead(SYNC_CONTROL));
  934. break;
  935. case 33:
  936. syncPhaseInc = getMajorEb(analogRead(SYNC_CONTROL));
  937. break;
  938. case 34:
  939. syncPhaseInc = getMajorBb(analogRead(SYNC_CONTROL));
  940. break;
  941. case 35:
  942. syncPhaseInc = getMajorF(analogRead(SYNC_CONTROL));
  943. break;
  944.  
  945. }
  946.  
  947. grainPhaseInc = mapPhaseInc(analogRead(GRAIN_FREQ_CONTROL)) / 2;
  948. grainDecay = analogRead(GRAIN_DECAY_CONTROL) / 8;
  949. grain2PhaseInc = mapPhaseInc(analogRead(GRAIN2_FREQ_CONTROL)) / 2;
  950. grain2Decay = analogRead(GRAIN2_DECAY_CONTROL) / 4;
  951. }
  952.  
  953. SIGNAL(PWM_INTERRUPT)
  954. {
  955. uint8_t value;
  956. uint16_t output;
  957.  
  958. syncPhaseAcc += syncPhaseInc;
  959. if (syncPhaseAcc < syncPhaseInc) {
  960. // Time to start the next grain
  961. grainPhaseAcc = 0;
  962. grainAmp = 0x7fff;
  963. grain2PhaseAcc = 0;
  964. grain2Amp = 0x7fff;
  965. LED_PORT ^= 1 << LED_BIT; // Faster than using digitalWrite
  966. }
  967.  
  968. // Increment the phase of the grain oscillators
  969. grainPhaseAcc += grainPhaseInc;
  970. grain2PhaseAcc += grain2PhaseInc;
  971.  
  972. // Convert phase into a triangle wave
  973. value = (grainPhaseAcc >> 7) & 0xff;
  974. if (grainPhaseAcc & 0x8000) value = ~value;
  975. // Multiply by current grain amplitude to get sample
  976. output = value * (grainAmp >> 8);
  977.  
  978. // Repeat for second grain
  979. value = (grain2PhaseAcc >> 7) & 0xff;
  980. if (grain2PhaseAcc & 0x8000) value = ~value;
  981. output += value * (grain2Amp >> 8);
  982.  
  983. // Make the grain amplitudes decay by a factor every sample (exponential decay)
  984. grainAmp -= (grainAmp >> 8) * grainDecay;
  985. grain2Amp -= (grain2Amp >> 8) * grain2Decay;
  986.  
  987. // Scale output to the available range, clipping if necessary
  988. output >>= 9;
  989. if (output > 255) output = 255;
  990.  
  991. // Output to PWM (this is faster than using analogWrite)
  992. PWM_VALUE = output;
  993. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement