
Comments and Discussions



Method not found: .ctor System.ArgumentOutOfRangeException
I get this error on all the overloads for the DSP.Fourier calls. I have tried both float and double arrays too. For example:
Exocortex.DSP.ComplexF[] cf = new Exocortex.DSP.ComplexF[4096];
....omitted: populate the ComplexF array...
Exocortex.DSP.Fourier.FFT(cf, Exocortex.DSP.FourierDirection.Forward);//this errors on the WM5 device.
However, this same code works fine on the full .net framework on a desktop machine.
Anyone able to use this lib on cf.net?





I am trying to use Exocortex to extract the pitch (fundamental frequency) of a wav file. The wav sample is just a single tone. I am able to create a Complex array and FFT it, but how to determine pitch from the FFT'd array? Numerical Recipes in C hinted that you find the maximum absolute value of the array and the index is the pitch:
Exocortex.DSP.ComplexF[] cf = new Exocortex.DSP.ComplexF[1024];
for(int i=0;i<1024;i++)
{
cf[i] = Exocortex.DSP.ComplexF.FromRealImaginary(Convert.ToSingle(raw[i]), 0F);
}//raw contains the bytes of the mono, 8 bits per sample data chunk of the .wav
Exocortex.DSP.Fourier.FFT(cf, Exocortex.DSP.FourierDirection.Forward);
int fundamental_frequency = 0;
for (int i = 0; i < 1024; i++)
{
if ((Math.Pow(cf[i].Re, 2) + Math.Pow(cf[i].Im, 2)) > (Math.Pow(cf[fundamental_frequency].Re, 2) + Math.Pow(cf[fundamental_frequency].Im, 2)))
{
fundamental_frequency = i;
}
}
textBox1.Text += fundamental_frequency.ToString();
But these results dont make much scense.
Tnx for any help with this.





Hi.
First of all, I just want to say, nice article =)
I read some papers around image processing, which uses DFT. There are also some formula that uses complexconjugate of DFT (invert the negative sign in the imaginary part of DFT formula).
I was wondering can your library do that? If not, how can I modify it?
Thanks before hand
"If Mohammed won't go to the mountain, then the mountain must go to Mohammed"  Gil Grissom, CSI





Hi,
I couldn't find what license you're using for the code. Can I include it in my own opensource projects if I keep the "header" (with your name etc) intact? Would it be OK to change the namespace?
Thanks!





Has anyone experienced problems with the backward FFT, I can't seem to get the right results. Also the results from the FFT seem to be the complex conjugate according to the same calculations in Matlab. Here is a snippet of my code  First i generate a 64 pts. Sinusvector then I do the FFT and afterwards the inverse FFT and expect to get the Sinus back, but this is not the case  I would really appreciate some inputs...
class Complex_Data
{
const int dimr = 64;
protected Complex[] data = new Complex[dimr];
public Complex[] DataVector
{
get { return data;}
}
public void generate_data()
{
int integer = 1;
for (int i = 0; i < dimr; i++)
{
data[i] = (Complex)Math.Cos(integer);
integer++;
}
}
public void TransformFoward()
{
Fourier.FFT(data,data.Length,FourierDirection.Forward);
}
public void TransformBackward()
{
Fourier.FFT(data,data.Length,FourierDirection.Backward);
}
}
Thanks in advance
AL





Hi Al,
After running "Fourier.FFT(data,data.Length,FourierDirection.Backward)", you can recover the inverse FFT values that you're expecting by multiplying the real part of the complex numbers in your "data" array by 1/n, which in your case would be (1 / (double)data.Length).
Hope this helps!
Dan






///
/// Subtract a complex number from a real
///
///
///
///
public static Complex operator( double f, Complex a ) {
a.Re = (double)( a.Re  f );
return a;
}
as can be seen the operator is wrong...
 modified at 19:10 Friday 10th November, 2006





Hi anyone,
how can I use FFT single dimension in Ben's Fourier library in order to plot the frequency spectrum of an input signal? What must I take out of the output of the Fourier.FFT to be able to draw the amplitude for each frequency correctly?
I took the data that was converted by the Fourier.FFT to the frequency domain and I having a sampling frequency of 8000Hz just divided the 8000 by 2000 (being the number of sample data input) therefore every sample(sqrt(real*real + imaginary*imaginary)) returned is the amplitude for the next 4Hz but that is not giving me an accurate result. I ignored the other 48 samples that I padded with my input signal to give a power of 2 input signal. Should I ignore them since they are input as all zeros or should I use them too?
Any other solution for my problem please?
Thanks
Kenneth Micallef
Malta





Did you ever find a solution to your question??
Carmen





Hi!
I'm successfully using that library but have an issue when my input array is 8192 entries long. In that case I get an "Index was outside the bounds of the array." error.
With 4096 values it works as expected.
I just use the Fourier.FFT function with real data (complex entries set to 0).
Any idea what the reason could be?
Thanks
Christof





Hi Christof,
I also tried EXOCORTEX_DSP DLL (version 1.2) fort my FFT needs.
Actually I have time arrays of 1000000 and more data points that I need to feed to FFT.
But EXOCORTEX fails for such large arrays with an error.
Later I found that EXOCORTEX has some severe issues:
===> The Fourier.FFT_Quick() function did not work in the beginning at all. Reason: The initialisation in the sources was commented out. Fix: Include the statement
Fourier.SyncLookupTableLength( length );
in the source code module Fourier.cs at line 722 .
===> Buffer size limitation: A little bit of debugging showed me that EXOCORTEX is limited to a maximum buffer size of 4096 data points. Look at these statements in Fourier.cs lines 7983.
private const int cMaxLength = 4096;
private const int cMinLength = 1;
private const int cMaxBits = 12;
private const int cMinBits = 0; This explains your buffer size issue.
EXOCORTEX's maximum buffer size is 4096.
You may try to edit these limits (don't forget cMaxBits!!!) in the sources, recompile and see what happens.
I did not try it yet.
This reply unfortunately is 4 years late, but I stumbled over this last week and it may help somebody else.





thanks HansPfaff..
and in the source code module Fourier.cs at line 982, too





There seem to be a few hardcoded limits to the amount of data that I can feed the RFFT function (and the other FFT functions, too, but I'm only using RFFT). I need to perform the operation on an array of length 500,000ish, but an assert fails when the array length is >= 1024*10 (in SyncLookupTableLength). An error occurs afterwards if I ignore the asserts. I suspect cMaxLength (set at 4096) might be a similar limit, but I'm not sure.
Anyway, I was wondering if you could point out how to raise the maximum limit, if it's possible.





I have the same problem and need to process a larger data set.
I have modified the code to make these limits larger and the code now appears to work on the larger data set. Their are 3 items that need to be changed.
The constant cMaxLength needs to be enlarged, in my case to 16384.
The constant cMaxBits needs to be enlarged, in my case to 16.
In the function private static void SyncLookupTableLength( int length ) the DebugAssert needs to be increased, again in my case to <= 1024 * 16.
I recompiled these changes and compared the results to those generated by our existing C++ package and the results where identical.
So, it appears as though you can increase the limits.
I would be greatful for any feedback regarding these modifications. i.e. are there any problems that changing these limits might generate.
If your listening Ben, I would appreciate some feedback.





I also modified the limits. If it would be helpful, I'm willing to post a VS.NET 2005 project, but I'll have to figure out how, since I've never posted files before.
"We may not be the smartest in the world, but we're the smartest you've got."
a coworker, speaking to our manager





Hi,
I don't know if it's a good way to use the operator(ComplexF) in a way like in your code:
public static ComplexF operator(ComplexF a) {
a.Re = a.Re;
a.Im = a.Im;
return a;
}
It's disadvantage is that if it will be used in code in this context:
// assume A is equal (1 + 2j)
B = A;
C = A;
// now B is equal (1  2j) and C is equal (1 + 2j)
B and C have different values  you change the value of A each time you use operator, and I guess it shouldn't be done this way...
Best regards,
Vigrid





Not exactly. The parameter 'a' to the function, since we are dealing with structs, is a copy of the original 'A'. This means that I can modify it any way I want and it will not affect the original 'A'.
I believe that the example that you give will not function as you expect it will. I believe that both 'C' and 'B' will be set to ( 1  2j).
All the best,
ben houston
http://www.exocortex.org/ben





I was writing a _class_ of complex numbers and got your source code as reference to the language (learning from more experienced is the best way to learn). When I changed my class to a struct it works just like you said.
I'm new to C# programming. My mistake...
Best regards,
Vigrid





Have you done any speed comparesments of this C# code to (similar) C++ ?
Specifically MS Visual C++ 7.0 and MS Visual C++ 6.0 (as some people say that 6.0 is faster than 7.0)?





okigan wrote:
as some people say that 6.0 is faster than 7.0
On what basis ? I suspect such people are just ignorant.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's.  Richard Stringer





The main question still stands: "Have you done any speed comparesments of this C# code to (similar) C++ ?"





Yes. It is slower than the FFTW C++ library.





I plainly have not.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's.  Richard Stringer





Hi all,
I found a bug on May 4th in the division operators of both structs ComplexF and ComplexF. I updated the code hosted on my exocortex.org site  listed as the "alternative" downloads above.
Sorry about that,
ben houston
www.exocortex.org/ben







General News Suggestion Question Bug Answer Joke Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Type  Article 
Licence  BSD 
First Posted  25 Apr 2002 
Views  119,353 
Bookmarked  41 times 

