Skip to content

Commit

Permalink
Set up config for doing test of GenericRecognizers
Browse files Browse the repository at this point in the history
Issue #281 Set up config for doing test of generic recognizers using Anthony's artificial test recording.
  • Loading branch information
towsey committed Feb 6, 2020
1 parent f9d4f9d commit 39e6a38
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---

# This yml config is designed to detect acoustic objects in an artificial test file prepared by Anthony Trukinger.
# The file contains a whistle, a rectangular blob and a group of 12 smaller whistles in a 6x2 grid that can be used to detect oscillations and harmonics (perhaps)
# Resample rate must be 2 X the desired Nyquist
ResampleRate: 22050
# SegmentDuration: units=seconds;
Expand All @@ -9,7 +10,35 @@ SegmentOverlap: 0

# Each of these profiles will be analyzed
Profiles:
Territorial: !BlobParameters
FiveSecondwhistle: !WhistleParameters
FrameSize: 512
FrameStep: 512
BgNoiseThreshold: 6.0
# min and max of the freq band to search
MinHertz: 800
MaxHertz: 8000
BottomHertzBuffer: 0
TopHertzBuffer: 0
MinDuration: 0.15
MaxDuration: 0.8
DecibelThreshold: 9.0
ComponentName: Blob
SpeciesName: PteropusSp
HalfSecondwhistle: !WhistleParameters
FrameSize: 512
FrameStep: 512
BgNoiseThreshold: 6.0
# min and max of the freq band to search
MinHertz: 800
MaxHertz: 8000
BottomHertzBuffer: 0
TopHertzBuffer: 0
MinDuration: 0.15
MaxDuration: 0.8
DecibelThreshold: 9.0
ComponentName: Blob
SpeciesName: PteropusSp
LargeBlob: !WhistleParameters
FrameSize: 512
FrameStep: 512
BgNoiseThreshold: 6.0
Expand Down
23 changes: 12 additions & 11 deletions src/AnalysisPrograms/Recognizers/Base/WhistleParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public static (List<AcousticEvent>, double[]) GetWhistles(
int maxBin = (int)Math.Round(maxHz / binWidth);
//int binCountInBand = maxBin - minBin + 1;

// buffer zone around whistle is three bins wide.
int N = 3;
// buffer zone around whistle is four bins wide.
int N = 4;

// list of accumulated acoustic events
var events = new List<AcousticEvent>();
var combinedIntensityArray = new double[frameCount];

// for all frequency bins
for (int bin = minBin; bin < maxBin - 1; bin++)
// for all frequency bins except top and bottom
for (int bin = minBin + 1; bin < maxBin - 1; bin++)
{
// set up an intensity array for the frequency bin.
double[] intensity = new double[frameCount];
Expand All @@ -59,9 +59,9 @@ public static (List<AcousticEvent>, double[]) GetWhistles(
// for all time frames in this frequency bin
for (int t = 0; t < frameCount; t++)
{
var bandIntensity = (sonogramData[t, bin] + sonogramData[t, bin + 1]) / 2.0;
var sideBandIntensity = ((0.5 * sonogramData[t, bin + 2]) + sonogramData[t, bin + 3]) / (double)2.0;
intensity[t] = bandIntensity - sideBandIntensity;
var bandIntensity = (sonogramData[t, bin - 1] + sonogramData[t, bin] + sonogramData[t, bin + 1]) / 3.0;
var topSideBandIntensity = (sonogramData[t, bin + 3] + sonogramData[t, bin + 4] + sonogramData[t, bin + 5]) / 3.0;
intensity[t] = bandIntensity - topSideBandIntensity;
intensity[t] = Math.Max(0.0, intensity[t]);
}
}
Expand All @@ -70,15 +70,16 @@ public static (List<AcousticEvent>, double[]) GetWhistles(
// for all time frames in this frequency bin
for (int t = 0; t < frameCount; t++)
{
var bandIntensity = (sonogramData[t, bin] + sonogramData[t, bin + 1]) / 2.0;
var sideBandIntensity = ((0.5 * sonogramData[t, bin + 2]) + sonogramData[t, bin + 3] + (0.5 * sonogramData[t, bin - 2]) + sonogramData[t, bin - 3]) / (double)4.0;
intensity[t] = bandIntensity - sideBandIntensity;
var bandIntensity = (sonogramData[t, bin - 1] + sonogramData[t, bin] + sonogramData[t, bin + 1]) / 3.0;
var topSideBandIntensity = (sonogramData[t, bin + 3] + sonogramData[t, bin + 4] + sonogramData[t, bin + 5]) / 6.0;
var bottomSideBandIntensity = (sonogramData[t, bin - 3] + sonogramData[t, bin - 4] + sonogramData[t, bin - 5]) / 6.0;
intensity[t] = bandIntensity - topSideBandIntensity - bottomSideBandIntensity;
intensity[t] = Math.Max(0.0, intensity[t]);
}
}

// smooth the decibel array to allow for brief gaps.
intensity = DataTools.filterMovingAverageOdd(intensity, 5);
intensity = DataTools.filterMovingAverageOdd(intensity, 7);

//calculate the Hertz bounds of the acoustic events for these freq bins
int bottomHzBound = (int)Math.Floor(sonogram.FBinWidth * (bin - 1));
Expand Down

0 comments on commit 39e6a38

Please sign in to comment.