public void Analyze() { amplitudeDetection = new AmplitudeDetection(); onsetDetection = new OnsetDetection(sampleRate, sampleSize, timePerSample); heldNoteDetection = new HeldNoteDetection(); pcmStream.Position = 0; int nSample = 0; do { float[] samples = ReadMonoPCM(); if (samples == null) { break; } float time = nSample * timePerSample; fft.RealFFT(samples, true); float[] fftSpectrum = fft.GetPowerSpectrum(); amplitudeDetection.AnalyzeSpectrum(fftSpectrum, time); heldNoteDetection.AnalyzeSpectrum(fftSpectrum, time); onsetDetection.AddFlux(fftSpectrum); nSample++; }while (true); amplitudeDetection.AbsAndNormalize(); // Find peaks onsetDetection.FindOnsets(1.5f); onsetDetection.NormalizeOnsets(); AddOnsets(SongElements); heldNoteDetection.AddHeldNotes(SongElements); }
public void NormalizeOnsets(int type) { onsetDetection.NormalizeOnsets(type); }