Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
Issue #332
  • Loading branch information
towsey committed Aug 11, 2020
1 parent 834fa95 commit 7ed5281
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 84 deletions.
34 changes: 1 addition & 33 deletions src/AudioAnalysisTools/DSP/FrequencyScale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public FrequencyScale(FreqScaleType fst)
/// <summary>
/// Gets or sets step size for the FFT window.
/// </summary>
public int FrameStep { get; set; }
public int WindowStep { get; set; }

/// <summary>
/// Gets or sets number of frequency bins in the final spectrogram.
Expand Down Expand Up @@ -242,38 +242,6 @@ public int GetBinIdInReducedSpectrogramForHerzValue(int herzValue)
return gridLineLocations;
}

/// <summary>
/// This method is only called from Basesonogram.GetImage_ReducedSonogram(int factor, bool drawGridLines)
/// when drawing a reduced sonogram.
/// </summary>
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<Rgb24> bmp, FrequencyScale freqScale, bool includeLabels)
{
DrawFrequencyLinesOnImage(bmp, freqScale.GridLineLocations, includeLabels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -133,49 +125,7 @@ protected static Tuple<double[,], double[]> MakeCepstrogram(SonogramConfig confi
// return matrix and full bandwidth modal noise profile
return tuple2;
}

/// <summary>
/// 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.
/// </summary>
public static Tuple<SpectrogramStandard, SpectrogramCepstral, double[], double[]> 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

//##################################################################################################################################
//##################################################################################################################################
Expand Down

0 comments on commit 7ed5281

Please sign in to comment.