I’d like to analyse a buffer of samples (a percussion hit about 1sec long) and get the frequencies (even just the ratio between the frequencies) and volumes for each harmonic. I don’t need it in realtime as long as it’s accurate. What should I do? The FFT example is quite confusing.

An FFT based approach is definetively the most common approach. Are you aware of the pure mathematical background of this kind of FFT analysis? If not, you should make yourself familiar with that before trying to do or understand it in C++. If the mathematical part is clear to you, what is confusing about the example for you?

I suggest you to read this to understand what it is, and how to use the FFT. From there, you can get a grasp of JUCE’s fft and how to use it from the example.

Edit: the link is actually about iFFT but really insightful

The Juce SimpleFFTDemo just does the FFT and draws the data on the screen. There isn’t really anything useful in terms of trying to find the true frequency peaks in the signal etc. More sophisticated methods are needed for that. (FFT can still used for that but the data needs to be further processed.)

If you’re learning this area, it’s usually a lot easier to do that in an environment like Matlab (or Octave if you don’t want to splash out on that, although the personal use licenses are quite reasonably priced if you’re not using it as a business). Being able to quickly graph and play around with arrays usually helps out.

You can use Python, Numpy and Matplotlib for free. Probably the best bet.