Esempio n. 1
0
        public float[] CreateScalogram(float sinusoidFrequency, float cycles)
        {
            var signalFFT = new FastFourierTransformCPU(AudioContainer.Samples).CreateTransformZeroPadded();
            var sigma     = 6;

            return(CreateScalogram(sinusoidFrequency, signalFFT, AudioContainer.SampleRate, cycles, sigma));
        }
Esempio n. 2
0
        public static float[] CreateScalogram(float frequency, Complex[] signalFT, int sampleRate, float cyclesCount, double sigma)
        {
            var pointsCount = signalFT.Length;
            var wavelet     = GenerateMorletWavelet(frequency, sampleRate, cyclesCount, pointsCount, sigma);
            var kernelFFT   = new FastFourierTransformCPU(wavelet).CreateTransformZeroPadded();

            var pointwiseMultiplication = new Complex[pointsCount];

            for (int i = 0; i < pointsCount; i++)
            {
                pointwiseMultiplication[i] = signalFT[i] * kernelFFT[i];
            }

            var inverseFFT = new FastFourierTransformCPU(pointwiseMultiplication).CreateTransform(false);

            var amplitudes = new float[inverseFFT.Length];

            for (int i = 0; i < amplitudes.Length; i++)
            {
                //amplitudes[i] = (float)inverseFFT[i].Imaginary;
                var value = inverseFFT[i];
                //amplitudes[i] = (float)Math.Sqrt(value.Real * value.Real + value.Imaginary * value.Imaginary);
                //amplitudes[i] = (float)value.Real;
                amplitudes[i] = (float)value.Magnitude;
                //amplitudes[i] = (float)value.Imaginary;
            }

            return(amplitudes);
        }