Help with FFT (Fast Fourier Transform) and / or DSP

I am trying to make a screen application that blinks the screen in accordance with the music (which will have frequencies such as healing frequencies, etc.). I already made a player and I know how to make the screen flash, but I need to make the screen flash super fast according to the music, for example, if the music speeds up, the screen flash will flash faster. I understand that I would achieve this with FFT or DSP (since I only need to know when the frequency rises from a few Hz, say 20, to change color, creating a screen flash).

But I found that I did not understand ANYTHING, even less trying to implement it in my application.

Can someone help me find out which one? My email sismetic_chaos@hotmail.com. I really need help, I got stuck like 3 days without coding and doing nothing, trying to understand, but I don’t know.

PS: My application is written in C ++ and Qt.

PS: Thank you for taking the time to read this and the willingness to help.

Edit: thanks everyone for the answers, the problem has not yet been resolved, but I appreciate all the answers, I did not think that I get so many answers and information. Thank you all.

+4
source share
5 answers

This is a complex problem requiring more than FFT. I will briefly describe how I implemented beat detection when I wrote software for professional DJ equipment.

First of all, you need to reduce the amount of data you are dealing with, since there are only two or three bits per second, but tens of thousands of samples. You will also need to look at different frequency ranges, as some types of music carry the tempo in the bass line, and others in percussion or other instruments. Therefore, transmit the signal through several bandpass filters (I chose 8 filters, each of which covers one octave, from low low to high high frequencies), and then reduces each range, averaging the power of more than several hundred samples.

Every few seconds you will have a thousand samples in each group. Your next tool is autocorrelation to identify repeating patterns in music. Autocorrelation peaks tell you which bit is more or less likely; but you will need to compile a few heuristics to compare all frequency ranges, to find a rhythm in which you can be sure, and to avoid erroneous syncopies. If you handle this, then you will have a reasonable guess about the pace, but I will not think about the phase (that is, whenever the screen flash).

Now you can look at the smoothed version of the audio data for the peaks, some of which are likely to correspond to bits. Initially, look for the strongest peak in a few seconds and take it as a rush. Combined with the pace you rated in the first step, you can predict when the next hit will occur, and measure where you really saw something like a hit, and adjust your score to more closely match the data. You can also maintain confidence based on how well-predicted hits match measured peaks; if it is too low, then restart shock detection from scratch.

This has a lot of details, and it took me several weeks to make it work beautifully. This is a difficult problem.

Or for a simple visualization effect, you can simply detect peaks and light up the screen for each of them; he will probably look good enough.

+3
source

The FFT output will give you the frequency spectrum of the sound sample, but extracting the tempo from the FFT output is probably not the way you want.

One thing you can do is use peak detection to identify the volume of the “spikes” that usually occur when music is “downbeat”. If you can identify down-beats, you can use a resource like bpmdatabase.com to find the tempo of a song. The pace will tell you how to blink fast, and the peaks detected will tell you when to start blinking. Ask the app to track your flashes to make sure that they usually occur simultaneously with the peak (if the two begin to diverge, then the tempo may have changed in the middle of the song).

It may seem simple, but actually it is a very non-trivial thing to implement. You can read this SO question for more information. There are some quality links in the answers.

If I am completely misinterpreting what you are trying to do, and you need to do FFT for something else, then you may need to use one of the existing FFT libraries to do the hard work for you. Some examples are FFTW and KissFFT .

+3
source

It seems like you are probably trying to get your visualizer to blink a screen in a timely manner with the help of music somehow. I do not think that the calculation of the FFT will help you here. At any given point in time, there will be many simultaneous frequency components throughout the sound spectrum (from about 20 Hz to 20 kHz). But you will probably be much more interested in the music tempo (beats per minute - more like 5 Hz or lower), and this is not going to show the raw audio signal anywhere in the FFT.

You probably need something much simpler - a kind of real-time peak detection. Whenever you see a peak that exceeds a certain threshold above the average volume, make your screen blink.

Of course, more complex renderings may make good use of FFT, but not the one you are describing.

0
source

My recommendation is to find a library that does this for you. If you don’t have a lot of math to support you, I think you will spend a lot of time studying FFT, when all you really need is a kind of “basic hits per minute” number, which you can set up the graphs accordingly .

Check out this post: here

It took me about three weeks to understand the math behind the FFT, and then another week to write something in Matlab using these concepts. If you despair after three days, do not try to quit your own.

I hope this is useful advice, not discouraging.

-Brian J. Stinar -

0
source

As noted in previous answers, FFT is probably not the tool needed to solve your problem, which requires tempo detection, not spectral analysis.

For an example of what can be done using FFT, and how a specific FFT implementation was integrated into the Qt application, check out this post blog , which describes the demo version of the spectrum analyzer that I developed. The demo code comes with Qt itself in the demos / spectrum directory.

0
source

All Articles