Hi. I’d like to know if anyone has a little demo project that contains the normal perform-method. i can only find examples of the realOnly-methods, but if i understood correctly then the perform-method is basically the one that is most flexible in terms of usage, so it’s advisable to learn it, right?
i tried a bit of stuff myself and atm i just have 2 vectors of Complex < float > of size * 2, just like in the fft tutorial with the other method. in the method where i push the fifo to the fft object i say:
fft->perform(&fifo.data()[0], &data.data()[0], false);
because if i understand correctly then this method asks for a reference to the first entry so it can read the whole array from there. then i made a method for testing the output:
void print(float relSize = 1.f) {
String p = "";
for (auto i = 0; i < data.size() * relSize; ++i)
p += String(data[i].real()) + ", " + String(data[i].imag()) + ": ";
DBG(p);
}
i gave it a sine wave at 1000hz and it produced this output to the console:
8.7641e+08, 0: -4.77772e+08, -3.98638e+08: 7.91343e+07, 0: -4.77772e+08, 3.98638e+08: 0, 0: 0, 0: 0, 0: 0, 0:
8.76411e+08, 0: -4.77773e+08, -3.98638e+08: 7.91343e+07, 0: -4.77773e+08, 3.98638e+08: 0, 0: 0, 0: 0, 0: 0, 0:
8.76412e+08, 0: -4.77773e+08, -3.98639e+08: 7.91342e+07, 0: -4.77773e+08, 3.98639e+08: 0, 0: 0, 0: 0, 0: 0, 0:
ok so… i know that it makes sense that the 2nd half of the array is empty. someone once explained to me that it’s only used for some calculations within the perform-method. but… what do i do with the actual values now? which are the calculations that get magnitude and phase from these bins? the 2nd bin doesn’t show 0 as imaginary number so i first thought that’s where the 1000hz wave is located but it seems to be the same when i shift the sine wave up to 20k or something which should clearly be the last bin.
EDIT:
i know i asked a similiar question before and in my last fft related post i was told to use std::abs() on the complex number to get its magnitude and std::arg() on it to get its phase. well i tried that but even then all bins show something with e+05 etc at the end, and i expect the normalized sine wave to stand out in the measurement with a high value.
in order to visualize to you my problem a bit better i show you this screenshot from my daw:
as you can see i wrote a little plug’n script script that can produce the first 8 of harmonics of any frequency as normalized value (-1 to 1). the visualizer is set to normalized as well which proves that it works so far. and as you can see the sine wave is set to a frequency of 2khz. i also tested that in a spectrum analyzer. so that’s not the problem. the problem is that when i do this on the data:
for (auto i = 0; i < size * relSize; ++i) {
auto magnitude = std::abs(data[i]);
p += String(magnitude) + ", ";
}
i get
2.05411e+09, 1.44914e+09, 2.04448e+08, 1.57981e+08, 1.46176e+08, 1.57981e+08, 2.04448e+08, 1.44914e+09,
(currently on order == 3 as you can see) why is my sine wave not represented in the numbers?
(FFTPlugin is the name of the juce plugin that performs fft)





now i know how to get normalized values of fft data. thank you so much!