public static double[][] computeSpectrogram(double[] wavedata, int fft_window_length,
            int fft_window_inc, String window_type) {
        int segSize = wavedata.length;

        int numWin = ((segSize - fft_window_length) / fft_window_inc) + 1;

        FFT FFTreal = new FFT();
        Window windowfunc = new Window(window_type);

        double[][] spectrogram = new double[numWin][fft_window_length];
        double[] frame = new double[fft_window_length];

        int pos = 0; // start position for frame (considering overlap)

        for (int i = 0; i < numWin; i++) {
            /* take a frame from the input wavedata */
            for (int k = 0; k < fft_window_length; k++) {
                frame[k] = wavedata[pos + k];
            }

            /* multiply with window function */
            frame = windowfunc.apply(frame);

            /* compute power spectrum from real FFT and construct spectrogram */
            spectrogram[i] = FFTreal.computeMagnitude(frame);
    
            pos = pos + fft_window_inc;
        }

        /*
         * NB: would need only fft_window_length/2 + 1 values. 1st value: DC, next
         * fft_window_length/2 values are spectrum
         */

        return spectrogram;
    }