# Using the FFT library, is it possible to get the beats per minute?

**URL:** <https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965>\
**Category:** Libraries\
**Created:** [August 1, 2020, 12:57pm UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965 "2020-08-01T12:57:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon76195010](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anon76195010](https://discourse.processing.org/u/anon76195010)\
**Post date:** [August 1, 2020, 12:57pm UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965/1 "2020-08-01T12:57:19Z")

</div>

Using the FFT library, is it possible to get the beats per minute? If so what would I type exactly?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 1, 2020, 3:51pm UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965/2 "2020-08-01T15:51:50Z")

</div>

Hello,

Please include references when discussing a library.

FFT is part of the Processing sound library:

> **[Sound / Libraries](https://processing.org/reference/libraries/sound/index.html)**
>
> Playback audio files, audio input, synthesize sound, and effects.

I have a deep voice and was beeping like a metronome to test some code out.  
I actually made “beep” sounds.

Steps:

- Started with:  
[FFT / Libraries / Processing.org](https://processing.org/reference/libraries/sound/FFT.html)
- focused only on low end of the spectrum from the array  
[println() / Reference / Processing.org](https://processing.org/reference/println_.html) used to see data to get a sense of it
- grabbed the time when there was a “beep” (peak power at the frequency range of interest)  
[millis() / Reference / Processing.org](https://processing.org/reference/millis_.html)
- calculate the difference between times
- flags (true\false) were used in code to keep track of peaks and lows so I was able to calculate time differences

I was able to get the time between “beeps” in this first attempt.

It would require a lot more work to clean this up and work with a broader spectrum of sound with a “beat” hidden in there.

Some of the filters look like something to try; depends on what the “beat” is that you are filtering.

> [@anon76195010](#):
>
> If so what would I type exactly?

> [@Would anyone know how to get the tempo/speed of a song using import processing.sound.\* library?](https://discourse.processing.org/t/would-anyone-know-how-to-get-the-tempo-speed-of-a-song-using-import-processing-sound-library/22928/5):
>
> I have a university project and it is very hard to find the correct library.

Sometimes you have to write your own code from what is available in existing libraries.

This is an academic exercise from what I have gleaned from your other posts so I will not be sharing code.

`:)`

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [August 1, 2020, 6:20pm UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965/3 "2020-08-01T18:20:32Z")

</div>

What sensor are you using?

---

<div class="post-metadata">

**Author:** ![anon76195010](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anon76195010](https://discourse.processing.org/u/anon76195010)\
**Post date:** [August 2, 2020, 1:59am UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965/4 "2020-08-02T01:59:32Z")

</div>

> [@glv](#):
>
> Hello,
> 
> Please include references when discussing a library.

Hi man, sure I will keep that in mind next time.

> [@glv](#):
>
> I have a deep voice and was beeping like a metronome to test some code out.  
> I actually made “beep” sounds.
> 
> Steps:
> 
> - Started with:  
> [FFT / Libraries / Processing.org](https://processing.org/reference/libraries/sound/FFT.html)
> - focused only on low end of the spectrum from the array  
> [println() / Reference / Processing.org](https://processing.org/reference/println_.html) used to see data to get a sense of it
> - grabbed the time when there was a “beep” (peak power at the frequency range of interest)  
> [millis() / Reference / Processing.org](https://processing.org/reference/millis_.html)
> - calculate the difference between times
> - flags (true\false) were used in code to keep track of peaks and lows so I was able to calculate time differences
> 
> I was able to get the time between “beeps” in this first attempt.

I will check out the links.

[quote=“glv, post:2, topic:22965”]  
It would require a lot more work to clean this up and work with a broader spectrum of sound with a “beat” hidden in there.

Sounds like it

> [@glv](#):
>
> Sometimes you have to write your own code from what is available in existing libraries.

At that point why to use Processing, I might as well use something like C as this will give me more low level functionality. I am forced to use Processing.

---

<div class="post-metadata">

**Author:** ![anon76195010](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anon76195010](https://discourse.processing.org/u/anon76195010)\
**Post date:** [August 2, 2020, 1:59am UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965/5 "2020-08-02T01:59:51Z")

</div>

Not sensors like I want to take the audio file as the input.

---

<div class="post-metadata">

**Author:** ![anon76195010](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anon76195010](https://discourse.processing.org/u/anon76195010)\
**Post date:** [August 2, 2020, 2:11am UTC](https://discourse.processing.org/t/using-the-fft-library-is-it-possible-to-get-the-beats-per-minute/22965/6 "2020-08-02T02:11:33Z")

</div>

> [@glv](#):
>
> grabbed the time when there was a “beep” (peak power at the frequency range of interest)  
> [millis() / Reference / Processing.org](https://processing.org/reference/millis_.html)

I understand how this works, but how would I implement it with the FFT library?
