public void Dispose() { largestTimestamp = -1; CurTimestamp = -1; lastGC = 0; SpectrogramHandler.Clear(); Analyser.DisposeAnalyser(); }
// Creates a spectrogram frame at specified update rate containing the current spectrum data, timestamp and analysis public void WriteToSpectrogram() { double curAudioPos = app.AudioSource.AudioAnalysis.CurrentTime.TotalMilliseconds; if (curAudioPos >= largestTimestamp) { if (SpectrogramHandler.Spectrogram.Frames.Count / (curAudioPos / 1000) <= Prefs.SPEC_UPDATE_RATE / app.AudioSource.SpeedControl.PlaybackRate) { byte[] specData = SpectrogramQuantiser(spectrumData, out double quantScale); specData = FilterSpectrogramData(specData); if (SpectrogramHandler.Spectrogram.FrequencyScale == null) { SpectrogramHandler.Spectrogram.FrequencyScale = GetScriptVal("SCALE"); } if (scriptSet != startingScriptSet || specData.Length != SpectrogramHandler.Spectrogram.FrequencyBins || curAudioPos - largestTimestamp > 1000) { SpectrogramHandler.Clear(); // Clears previous spectrogram frames if scripts are changed SpectrogramHandler.Spectrogram.AudioFilename = app.AudioSource.Filename; SpectrogramHandler.Spectrogram.ScriptProperties = app.GetScriptSettingValues(app.GetScriptChainData()); startingScriptSet = scriptSet; } SpectrogramHandler.CreateFrame(curAudioPos, specData, Analyser.Notes.ToArray(), Analyser.Chords.ToArray(), Analyser.CurrentKey, quantScale); CurTimestamp = curAudioPos; largestTimestamp = curAudioPos; if (curAudioPos - lastGC >= 1000) // Garbage collection every second { GC.Collect(); lastGC = curAudioPos; } } else { CurTimestamp = 0; } } else { CurTimestamp = 0; } }