Skip to content

Commit

Permalink
Try versions of difference spectrogram
Browse files Browse the repository at this point in the history
Issue #278 Try versions of difference spectrogram. Decide that the original is the best.
  • Loading branch information
towsey committed Dec 14, 2019
1 parent b1ba0c8 commit 996d564
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/AnalysisConfigFiles/Towsey.SpectrogramGenerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ FrameLength: 512
# Following frame step yields 50 frames/s which can make some subsequent operations a bit easier.
FrameStep: 441

Waveform: false
DecibelSpectrogram: false
DecibelSpectrogram_NoiseReduced: false
CepstralSpectrogram: false
DifferenceSpectrogram: false
Waveform: true
DecibelSpectrogram: true
DecibelSpectrogram_NoiseReduced: true
CepstralSpectrogram: true
DifferenceSpectrogram: true
AmplitudeSpectrogram_LocalContrastNormalization: true
Experimental: false
Experimental: true

#NOISE REDUCTION PARAMETERS
DoNoiseReduction: true
Expand Down
21 changes: 17 additions & 4 deletions src/AnalysisPrograms/Audio2Sonogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static AudioToSonogramResult GenerateSpectrogramImages(
// IMAGE 5) draw difference spectrogram
if (doDifferenceSpectrogram)
{
double threshold = 3.0;
double threshold = 4.0;
var image6 = GetDifferenceSpectrogram(dbSpectrogramData, threshold);
image6 = BaseSonogram.GetImageAnnotatedWithLinearHertzScale(image6, sampleRate, frameStep, $"DECIBEL DIFFERENCE SPECTROGRAM ({sourceRecordingName})");
list.Add(image6);
Expand Down Expand Up @@ -315,18 +315,31 @@ public static Image GetDifferenceSpectrogram(double[,] spectrogramData, double t
{
var dx = spectrogramData[r, c] - spectrogramData[r - 1, c];
var dy = spectrogramData[r, c] - spectrogramData[r, c - 1];
var dd = spectrogramData[r, c] - spectrogramData[r - 1, c - 1];
var dpd = spectrogramData[r, c] - spectrogramData[r - 1, c - 1];

//var dy2 = spectrogramData[r, c] - spectrogramData[r, c + 1];
//var dnd = spectrogramData[r, c] - spectrogramData[r - 1, c + 1];
dM[r, c] = dx;
if (dy > dx)
{
dM[r, c] = dy;
}

if (dd > dy)
if (dpd > dy)
{
dM[r, c] = dd;
dM[r, c] = dpd;
}

//if (dnd > dpd)
//{
// dM[r, c] = dnd;
//}

//if (dy2 > dpd)
//{
// dM[r, c] = dy2;
//}

if (dM[r, c] < threshold)
{
dM[r, c] = 0.0;
Expand Down

0 comments on commit 996d564

Please sign in to comment.