Page 640 - 3-2
P. 640

http://www.embedded.com/design/embedded/4024443/The-Goertzel-Algorithm
              so full credit to him for his generic implementation and breakdown. I've
              simply massaged it into an Arduino library. I recommend reading his article
              for a full description of whats going on behind the scenes.


              The Goertzel algorithm is long standing so see
              http://en.wikipedia.org/wiki/Goertzel_algorithm for a full description.
              It is often used in DTMF tone detection as an alternative to the Fast
              Fourier Transform because it is quick with low overheard because it
              is only searching for a single frequency rather than showing the
              occurrence of all frequencies.


              If what you really want is DTMF tone detection see el_supremo's fork of
              this library at http://forum.arduino.cc/index.php/topic,121540.0.html


              To use, you'll want a microphone not unlike this electret from Sparkfun
              https://www.sparkfun.com/products/9964 with AVD plugged to A0, VCC to 5V, and GND to
            GND


              See Contributors.md and add yourself for pull requests
              Released into the public domain.
            */
            #include <Goertzel.h>
            int sensorPin = A0;
            int led = D0;


            // ideally an integer of SAMPLING_FREQUENCY/N to center the bins around your content so if
            you're
            // looking for 700hz, frequencies below and above it equally contribute. Read up on Kevin's
            article
            // for more info.
            // Nyquist says the highest frequency we can target is SAMPLING_FREQUENCY/2


            const float TARGET_FREQUENCY = 400; //      원하는 주파수


            //1241
            // if you're trying to detect several different drum hits all within low frequency like
            // ~100-200hz you'll need a small bin size like 25 or 50 to distinguish them.
            // If however you're just trying to find ANY bass hit you might want something
            // basically equal to frequency youre looking for like ~100
            // If Im detecting a frequency much higher with no care about nearby tones, like 2000hz
            // Ill set to a round divisor like 200 So 1900 to 2100 could trigger, but not less or more
            // Max is 200 as we have limited ram in the Arduino, and sampling longer would make us less
            // responsive anyway




                                                         - 640 -
   635   636   637   638   639   640   641   642   643   644   645