From 7ed5281c5d0e9454e245d7e800e8e73aed9ff3c9 Mon Sep 17 00:00:00 2001 From: towsey Date: Tue, 11 Aug 2020 17:19:17 +1000 Subject: [PATCH] Remove unused code Issue #332 --- src/AudioAnalysisTools/DSP/FrequencyScale.cs | 34 +----------- .../SpectrogramCepstral.cs | 52 +------------------ 2 files changed, 2 insertions(+), 84 deletions(-) diff --git a/src/AudioAnalysisTools/DSP/FrequencyScale.cs b/src/AudioAnalysisTools/DSP/FrequencyScale.cs index d64bade75..3328d513b 100644 --- a/src/AudioAnalysisTools/DSP/FrequencyScale.cs +++ b/src/AudioAnalysisTools/DSP/FrequencyScale.cs @@ -124,7 +124,7 @@ public FrequencyScale(FreqScaleType fst) /// /// Gets or sets step size for the FFT window. /// - public int FrameStep { get; set; } + public int WindowStep { get; set; } /// /// Gets or sets number of frequency bins in the final spectrogram. @@ -242,38 +242,6 @@ public int GetBinIdInReducedSpectrogramForHerzValue(int herzValue) return gridLineLocations; } - /// - /// This method is only called from Basesonogram.GetImage_ReducedSonogram(int factor, bool drawGridLines) - /// when drawing a reduced sonogram. - /// - public static int[] CreateLinearYaxis(int herzInterval, int nyquistFreq, int imageHt) - { - int minFreq = 0; - int maxFreq = nyquistFreq; - int freqRange = maxFreq - minFreq + 1; - double pixelPerHz = imageHt / (double)freqRange; - int[] vScale = new int[imageHt]; - - for (int f = minFreq + 1; f < maxFreq; f++) - { - // convert freq value to pixel id - if (f % 1000 == 0) - { - int hzOffset = f - minFreq; - int pixelId = (int)(hzOffset * pixelPerHz) + 1; - if (pixelId >= imageHt) - { - pixelId = imageHt - 1; - } - - // LoggedConsole.WriteLine("f=" + f + " hzOffset=" + hzOffset + " pixelID=" + pixelID); - vScale[pixelId] = 1; - } - } - - return vScale; - } - public static void DrawFrequencyLinesOnImage(Image bmp, FrequencyScale freqScale, bool includeLabels) { DrawFrequencyLinesOnImage(bmp, freqScale.GridLineLocations, includeLabels); diff --git a/src/AudioAnalysisTools/StandardSpectrograms/SpectrogramCepstral.cs b/src/AudioAnalysisTools/StandardSpectrograms/SpectrogramCepstral.cs index cf51991ea..7b249d298 100644 --- a/src/AudioAnalysisTools/StandardSpectrograms/SpectrogramCepstral.cs +++ b/src/AudioAnalysisTools/StandardSpectrograms/SpectrogramCepstral.cs @@ -7,7 +7,6 @@ namespace AudioAnalysisTools.StandardSpectrograms using System; using Acoustics.Tools.Wav; using AudioAnalysisTools.DSP; - using AudioAnalysisTools.WavTools; using TowseyLibrary; public class SpectrogramCepstral : BaseSonogram @@ -53,13 +52,6 @@ public SpectrogramCepstral(AmplitudeSonogram sg, int minHz, int maxHz) this.SampleRate = sg.SampleRate; this.SigState = sg.SigState; this.SnrData = sg.SnrData; - - // sub-band highlighting no longer available - //this.subBandMinHz = minHz; - //this.subBandMaxHz = maxHz; - //double[] noise_subband = BaseSonogram.ExtractModalNoiseSubband(this.SnrData.ModalNoiseProfile, minHz, maxHz, sg.doMelScale, - // sonogram.Configuration.FreqBinCount, sonogram.FBinWidth); - this.Data = SpectrogramTools.ExtractFreqSubband(sg.Data, minHz, maxHz, this.Configuration.DoMelScale, sg.Configuration.FreqBinCount, sg.FBinWidth); //converts amplitude matrix to cepstral sonogram @@ -133,49 +125,7 @@ protected static Tuple MakeCepstrogram(SonogramConfig confi // return matrix and full bandwidth modal noise profile return tuple2; } - - /// - /// Returns a Spectrogram and Cepstrogram from the passed recording. These are NOT noise reduced. - /// however, tuple also returns the modal noise and sub-band modal noise. - /// - public static Tuple GetAllSonograms(AudioRecording recording, SonogramConfig sonoConfig, int minHz, int maxHz) - { - int sr = recording.SampleRate; - bool doMelScale = sonoConfig.DoMelScale; - int ccCount = sonoConfig.mfccConfig.CcCount; - bool includeDelta = sonoConfig.mfccConfig.IncludeDelta; - bool includeDoubleDelta = sonoConfig.mfccConfig.IncludeDoubleDelta; - sonoConfig.SourceFName = recording.BaseName; - - var basegram = new AmplitudeSonogram(sonoConfig, recording.WavReader); - var sonogram = new SpectrogramStandard(basegram); //spectrogram has dim[N,257] - - Log.WriteLine("Signal: Duration={0}, Sample Rate={1}", sonogram.Duration, sr); - Log.WriteLine( - $"Frames: Size={0}, Count={1}, Duration={2:f1}ms, Overlap={5:f0}%, Offset={3:f1}ms, Frames/s={4:f1}", - sonogram.Configuration.WindowSize, - sonogram.FrameCount, - sonogram.FrameDuration * 1000, - sonogram.FrameStep * 1000, - sonogram.FramesPerSecond, - sonoConfig.WindowOverlap * 100); - - int binCount = (int)(maxHz / sonogram.FBinWidth) - (int)(minHz / sonogram.FBinWidth) + 1; - Log.WriteLine("Freqs : {0} Hz - {1} Hz. (Freq bin count = {2})", minHz, maxHz, binCount); - Log.WriteLine("MFCCs : doMelScale=" + doMelScale + "; ccCount=" + ccCount + "; includeDelta=" + includeDelta + "; includeDoubleDelta=" + includeDoubleDelta); - - //CALCULATE MODAL NOISE PROFILE - USER MAY REQUIRE IT FOR NOISE REDUCTION - double[] modalNoise = sonogram.SnrData.ModalNoiseProfile; - - //extract sub-band modal noise profile - double[] noiseSubband = SpectrogramTools.ExtractModalNoiseSubband(modalNoise, minHz, maxHz, doMelScale, sonogram.NyquistFrequency, sonogram.FBinWidth); - - // CALCULATE CEPSTRO-GRAM. //cepstrogram has dim[N,13] - var cepstrogram = new SpectrogramCepstral(basegram, minHz, maxHz); - var tuple = Tuple.Create(sonogram, cepstrogram, modalNoise, noiseSubband); - return tuple; - } - } // end class CepstralSonogram + } // class CepstralSonogram //################################################################################################################################## //##################################################################################################################################