private void Analyze() { if (analysisDone) { return; } if (_preCalculate) { _lead += 300; } _lead = Mathf.Max(300, _lead); for (int i = _lastFrame + 1; i < currentFrame + _lead + 300; i++) { if (i >= totalFrames) { EndOfAnalysis(); break; } audioSource.clip.GetData(samples, Mathf.Max((i * frameSpacing) - (fftWindowSize / 2), 0)); float[] spectrum = Util.GetSpectrum(samples); foreach (Analysis s in analyses) { s.Analyze(spectrum, i); } if (_calculateTempo) { if (i - 10 >= 0) { float flux = all.flux[i - 10]; beatTracker.TrackBeat(flux); } } segmenter.DetectChanges(i - 350); _lastFrame = i; } }
private void Analyze(float[] samples, int index) { Util.GetMono(samples, monoSamples, channels); Util.GetSpectrum(monoSamples); Util.GetSpectrumMagnitude(monoSamples, spectrum); foreach (Analysis analysis in analyses) { analysis.Analyze(spectrum, index); } if (_trackBeat) { beatTracker.TrackBeat(all.flux[index], index); } segmenter.DetectChanges(index - 200); }