FFT help needed

I don’t know if Xojo can do FFT, in fact, to be honest, I barely understand FFT myself!

I am trying to port some code, it would look something like this, if it worked in Xojo…

For i As Integer = 0 To Ubound(frequency)
Dim w As Double = 2.0 * 3.14159 * frequency(i)
Dim z As Double = Complex.Conjugate(Complex.Conjugate(resistance) + Complex.Imaginary(inductance * w))
Dim y As Double = Complex.Inverse(z)
magnitude(i) = magnitude(i) + 20.0 * Log10(Abs(1.0 / z))
phase(i) = phase(i) + (180.0 / 3.14159) * Arg(y)
Next

Is there anyway to make something like this work in Xojo?

Thanks!

I guess I should learn how to post formatted/indented code…

in your example there was a module Complex with methods Conjugate,Imaginary,Inverse
maybe you have the source code too?

here is a example code with a Class Complex below this page
https://www.monkeybreadsoftware.net/example-datatypes-fft.shtml

https://www.monkeybreadsoftware.net/pluginpart-fft.shtml

Fast Fourier Transformation

Select your code including an empty line before it and click in the ’</> icon (in write mode…).

Another good thing to do is no not use FFT as is: define what it is, and place FFT inside parents;, then you can use the acronym. TIA (for those who do not know what is FFT: French Federation of Tennis players, for example…) :smiley:

If you need a complex math class, I’ve written one that you can download from here:
http://electronbunker.ca/XojoProjects/ComplexMath.xojo_binary_project.zip

Thanks everyone!
I will take a close look at all your suggestions.