Beispiel #1
0
        float[][] stft(Complex[] x, int wSamp)
        {
            Timelogger totalRuntime = new Timelogger(@"totalTime\sequential", "time for freqDomain() sequentially");
            totalRuntime.Start();
            int N = x.Length;
            float fftMax = 0;
            float[] fftMaxes = new float[2 * (int)Math.Floor((double)N / (double)wSamp)];

            float[][] Y = new float[wSamp / 2][];
            float[][] Z = new float[wSamp / 2][];

            for (int ll = 0; ll < wSamp / 2; ll++)
            {
                Y[ll] = new float[2 * (int)Math.Floor((double)N / (double)wSamp)];
                Z[ll] = new float[2 * (int)Math.Floor((double)N / (double)wSamp)];
            }

            //Timelogger sw = new Timelogger(@"fft\fftSplitParallel.txt", "time for fft with splitting loop paralellised");
            for (int ii = 0; ii < 2 * Math.Floor((double)N / (double)wSamp) - 1; ++ii)
            {

                Complex[] temp = new Complex[wSamp];
                Complex[] tempFFT = new Complex[wSamp];

                for (int jj = 0; jj < wSamp; jj++)
                {
                    temp[jj] = x[ii * (wSamp / 2) + jj];
                }

                //sw.Start();
                tempFFT = fft(temp);
                //sw.Stop();

                //#TODO parallelisable if you can keep track of highest
                for (int kk = 0; kk < wSamp / 2; kk++)
                {
                    Y[kk][ii] = (float)Complex.Abs(tempFFT[kk]);

                    if (Y[kk][ii] > fftMax)
                    {
                        fftMax = Y[kk][ii];
                    }
                }

            }
            //sw.log();
            //time.log();

            for (int ii = 0; ii < 2 * Math.Floor((double)N / (double)wSamp) - 1; ii++)
            {
                for (int kk = 0; kk < wSamp / 2; kk++)
                {
                    Y[kk][ii] /= fftMax;
                }
            }

            totalRuntime.Stop();
            totalRuntime.log();
            return Y;
        }
Beispiel #2
0
        float[][] stft(Complex[] x, int wSamp)
        {
            Timelogger totalRuntime = new Timelogger(@"totalTime\sequential", "time for freqDomain() sequentially");

            totalRuntime.Start();
            int   N      = x.Length;
            float fftMax = 0;

            float[] fftMaxes = new float[2 * (int)Math.Floor((double)N / (double)wSamp)];

            float[][] Y = new float[wSamp / 2][];
            float[][] Z = new float[wSamp / 2][];

            for (int ll = 0; ll < wSamp / 2; ll++)
            {
                Y[ll] = new float[2 * (int)Math.Floor((double)N / (double)wSamp)];
                Z[ll] = new float[2 * (int)Math.Floor((double)N / (double)wSamp)];
            }



            //Timelogger sw = new Timelogger(@"fft\fftSplitParallel.txt", "time for fft with splitting loop paralellised");
            for (int ii = 0; ii < 2 * Math.Floor((double)N / (double)wSamp) - 1; ++ii)
            {
                Complex[] temp    = new Complex[wSamp];
                Complex[] tempFFT = new Complex[wSamp];

                for (int jj = 0; jj < wSamp; jj++)
                {
                    temp[jj] = x[ii * (wSamp / 2) + jj];
                }

                //sw.Start();
                tempFFT = fft(temp);
                //sw.Stop();

                //#TODO parallelisable if you can keep track of highest
                for (int kk = 0; kk < wSamp / 2; kk++)
                {
                    Y[kk][ii] = (float)Complex.Abs(tempFFT[kk]);

                    if (Y[kk][ii] > fftMax)
                    {
                        fftMax = Y[kk][ii];
                    }
                }
            }
            //sw.log();
            //time.log();

            for (int ii = 0; ii < 2 * Math.Floor((double)N / (double)wSamp) - 1; ii++)
            {
                for (int kk = 0; kk < wSamp / 2; kk++)
                {
                    Y[kk][ii] /= fftMax;
                }
            }

            totalRuntime.Stop();
            totalRuntime.log();
            return(Y);
        }