選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

README.md 5.8KB

9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
9年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <p align="center">
  2. <b>Guitar and Bass Tuner Library</b><br>
  3. <b>Teensy 3.1 v2.0</b><br>
  4. </p>
  5. >Software algorithm ([YIN]) for guitar and bass tuning using a Teensy Audio Library. This audio object's algorithm can be some what memory and processor hungry but will allow you to detect with fairly good accuracy the fundamental frequencies f<sub>o</sub> from electric guitars and basses.
  6. >>You can install this as a normal Arduino Library and will work with the Audio Library, no need to edit the Audio libraries source now.
  7. <!-- language: lang-none -->
  8. Hookup Guide - 1.2v DC Bias and High Pass Filter - No Amplification
  9. *--------------------------------------------------*
  10. | |
  11. | Pull Down Resistor | ' | |
  12. *------------/\/\/\-------------* |' '| |
  13. | 47K | _|_'_|_ |
  14. | | |` ` ` `| |
  15. *---)|+--* | | ` ` ` | |
  16. | 10uF | | |` ` ` `| |
  17. TEENSY 3.1 | | | | ` ` ` | |
  18. _______________ *-/\/\/\-* | |` ` ` `| |
  19. |GND |_____| Vin| | 2.2K | | | ` ` ` | |
  20. |0 ----- AGND|<-* | | |` ` ` `| |
  21. |1 |`````| 3.3V|>--/\/\/\--*--/\/\/\---* | | ` ` ` | |
  22. |2 | | 23| 10K 47K | | |` ` ` `| |
  23. |3 ----- 22| | | | ` ` ` | |
  24. |4 |'| 21| | | \=====/ |
  25. |5 ------ 20| | | | :`| |
  26. |6 |::::::::| 19| | REMOVE | | S`| |
  27. |7 |::::::::| 18| | DC | | H`| |
  28. |8 |::::::::| 17| | BIAS | | I`| |
  29. |9 ------A2/16|<---SIGNAL-1.2v-BIAS---*---+|(----* | E`|>--ANGD--*
  30. |10 --- 15| 1.2VDC 10uF | | L`|
  31. |11 |(`)| 14| | | D`|
  32. |12 --- 13| | | :`|
  33. --------------- | |===|
  34. | \_/
  35. | /T\
  36. | - I -
  37. *---<\ P /
  38. \_/
  39. >Many optimizations have been done to the [YIN] algorithm for frequencies between 29-360Hz.
  40. >>While its still using a brute force method ( n<sup>2</sup> ) for finding the fundamental frequency f<sub>o</sub>, it is tuned to skip certain <b>tau</b> (<img src="http://rogercortesi.com/eqn/tempimagedir/eqn7483.png"/></img>) values and focus mostly on frequencies found in the bass and guitar.
  41. >>>The input is double buffered so while you are processing one buffer it is filling the other to double throughput.
  42. >>>>There are a few parameters that can be adjusted to "dial in" the algorithm for better estimations. The defaults are what I found that have the best trade off for speed and accuracy.
  43. <h4>AudioTuner.h</h4>
  44. ```
  45. /****************************************************************/
  46. #define SAMPLE_RATE_DIVIDE_BY_1 1 // 44100 sample rate
  47. #define SAMPLE_RATE_DIVIDE_BY_2 2 // 22050 sample rate
  48. #define SAMPLE_RATE_DIVIDE_BY_4 4 // 11025 sample rate
  49. #define SAMPLE_RATE_DIVIDE_BY_8 8 // 5512.5 sample rate
  50. #define SAMPLE_RATE_DIVIDE_BY_16 16 // 2756.25 sample rate
  51. #define SAMPLE_RATE_DIVIDE_BY_32 32 // 1378.125 sample rate
  52. /****************************************************************
  53. * Safe to adjust these values below *
  54. ****************************************************************/
  55. // Adjust number of samples to collect in buffer here, also effects
  56. // convergence speed and resolution.
  57. #define NUM_SAMPLES 2048 // make a power of two
  58. // larger the divide-by, less resolution and lower the frequency for
  59. // a given number of samples that can be detected. Also effects
  60. // convergence speed.
  61. #define SAMPLE_SKIP SAMPLE_RATE_DIVIDE_BY_2
  62. /****************************************************************/
  63. ```
  64. ```
  65. SAMPLE_RATE_DIVIDE_BY_x --> This sets 'SAMPLE_SKIP' to pass on every (x) data point from the
  66. Audio Block being saved to the buffer, it determines the sample rate.
  67. ```
  68. ```
  69. NUM_SAMPLES --> This the size of each buffer, there two for double buffering.
  70. ```
  71. ```
  72. SAMPLE_SKIP --> This sets your sample window length and sampling rate. Sample Window Size is
  73. (NUM_SAMPLES * SAMPLE_SKIP) of the ~44100 samples every second. Sample Rate is
  74. (AUDIO_SAMPLE_RATE_EXACT / SAMPLE_SKIP).
  75. ```
  76. <div>
  77. <b>YIN Algorithm</b>
  78. <ol>
  79. <li><b>Difference Function -</b> Squared difference of the (signal - signal lag(<img src="http://rogercortesi.com/eqn/tempimagedir/eqn7483.png"/></img>))</li>
  80. <img src="http://rogercortesi.com/eqn/tempimagedir/eqn1752.png" />
  81. <li><b>Cumulative Mean Normalized Difference Function -</b> Calculate the cumulative mean on the normalized difference signal</li>
  82. <img src="http://rogercortesi.com/eqn/tempimagedir/eqn3269.png" />
  83. <li><b>Absolute Threshold -</b> Fix for subharmonic error with Autocorrelation, choose (<img src="http://rogercortesi.com/eqn/tempimagedir/eqn7483.png"/></img>) that gives a minimum <img src="http://rogercortesi.com/eqn/tempimagedir/eqn3518.png"/></li>
  84. </ol>
  85. </div>
  86. [YIN]:http://recherche.ircam.fr/equipes/pcm/cheveign/pss/2002_JASA_YIN.pdf