public void DetectOnsets(float sensitivity = 1.5f) { heldNoteDetection = new HeldNoteDetection(PCMStream, 1024); // Has finished reading in the audio file bool finished = false; // Set the pcm data back to the beginning SetTrackPosition(0); do { // Read in audio data and find the flux values until end of audio file finished = heldNoteDetection.AnalyzeSpectrum(ReadMonoPCM()); }while (!finished); }
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); }