public Preprocessing(int samplingFrequency, int step)
        {
            shortWindow  = new PreprocessingWindow(SHORT_SAMPLE, samplingFrequency, step);
            mediumWindow = new PreprocessingWindow(MEDIUM_SAMPLE, samplingFrequency, step);
            longWindow   = new PreprocessingWindow(LONG_SAMPLE, samplingFrequency, step);

            this.Step = step;
            this.SamplingFrequency = samplingFrequency;
            sample         = 0;
            buffer         = new double[LONG_SAMPLE];
            bufferPosition = 0;
        }
Beispiel #2
0
        private static double[] CalculateEnergies(TrackInfo trackInfo)
        {
            using (WaveFile wave = trackInfo.GetWaveFile())
            {
                wave.Open();
                Debug.Assert(wave.SampleRate == 44100);
                PreprocessingWindow window  = new PreprocessingWindow(512, 44100, AccuracyInSamples);
                double[]            samples = new double[wave.Length + 512];
                double[]            result  = new double[wave.Length / AccuracyInSamples];
                Debug.Assert(wave.Read(samples) == wave.Length);

                double[] bands = new double[window.OutputSize];

                for (int i = 0; i < result.Length; i++)
                {
                    window.Process(samples, i * AccuracyInSamples);
                    window.PrepareDifferenceFrame(bands, 0);
                    result[i] = bands.Sum();
                }
                return(result);
            }
        }