From 1cd841202edfd765eb88b04aa53c73468cabae9b Mon Sep 17 00:00:00 2001 From: towsey Date: Fri, 17 Apr 2020 11:20:46 +1000 Subject: [PATCH] Renamed class and methods to reflect new nomenclature Issue #297 Have adopted new nomenclature for track types and incorporated the track type as a field in the Track class --- ...Parameters.cs => FowardTrackParameters.cs} | 23 +++++++--- ...Parameters.cs => UpwardTrackParameters.cs} | 26 +++++++---- .../Recognizers/GenericRecognizer.cs | 28 ++++++------ src/AudioAnalysisTools/Events/Tracks/Track.cs | 21 +++++---- .../Events/Tracks/TrackExtractor.cs | 44 ++++++++++--------- .../GenericRecognizerTests.cs | 21 ++++----- .../Events/Tracks/TrackTests.cs | 11 ++--- 7 files changed, 99 insertions(+), 75 deletions(-) rename src/AnalysisPrograms/Recognizers/Base/{HorizontalTrackParameters.cs => FowardTrackParameters.cs} (77%) rename src/AnalysisPrograms/Recognizers/Base/{VerticalTrackParameters.cs => UpwardTrackParameters.cs} (78%) diff --git a/src/AnalysisPrograms/Recognizers/Base/HorizontalTrackParameters.cs b/src/AnalysisPrograms/Recognizers/Base/FowardTrackParameters.cs similarity index 77% rename from src/AnalysisPrograms/Recognizers/Base/HorizontalTrackParameters.cs rename to src/AnalysisPrograms/Recognizers/Base/FowardTrackParameters.cs index db3a6d9e4..c7bb67e2c 100644 --- a/src/AnalysisPrograms/Recognizers/Base/HorizontalTrackParameters.cs +++ b/src/AnalysisPrograms/Recognizers/Base/FowardTrackParameters.cs @@ -1,4 +1,4 @@ -// +// // All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). // @@ -14,10 +14,11 @@ namespace AnalysisPrograms.Recognizers.Base using TowseyLibrary; /// - /// Parameters needed from a config file to detect spectral peak tracks. + /// Parameters needed from a config file to detect fowards spectral peak tracks. + /// A FowardTrack sounds like a fluctuating tone or technically, a chirp. Each track point advances one time step. Points may move up or down by at most two frequency bins. /// - [YamlTypeTag(typeof(HorizontalTrackParameters))] - public class HorizontalTrackParameters : CommonParameters + [YamlTypeTag(typeof(FowardTrackParameters))] + public class FowardTrackParameters : CommonParameters { /// /// Gets or sets a value indicating whether coincident tracks stacked on top of one another are to be combined. @@ -31,14 +32,22 @@ public class HorizontalTrackParameters : CommonParameters public int HertzGap { get; set; } /// - /// This method returns spectral peak tracks enclosed in acoustic events. + /// This method returns foward (spectral peak) tracks enclosed in acoustic events. /// It averages dB log values incorrectly but it is faster than doing many log conversions. /// + /// The spectrogram to be searched. + /// Bottom of the frequency band to be searched. + /// Top of the frequency band to be searched. + /// Ignore spectrogram cells below this amplitude. + /// Minimum duration of a valid event. + /// Maximum duration of a valid event. + /// Combine tracks that are likely to be harmonics/formants. + /// The start time of the current recording segment under analysis. + /// A list of acoustic events containing foward tracks. public static (List Events, double[] CombinedIntensity) GetFowardTracks( SpectrogramStandard sonogram, int minHz, int maxHz, - int nyquist, double decibelThreshold, double minDuration, double maxDuration, @@ -48,7 +57,7 @@ public static (List Events, double[] CombinedIntensity) GetFoward var sonogramData = sonogram.Data; int frameCount = sonogramData.GetLength(0); int binCount = sonogramData.GetLength(1); - + int nyquist = sonogram.NyquistFrequency; double binWidth = nyquist / (double)binCount; int minBin = (int)Math.Round(minHz / binWidth); int maxBin = (int)Math.Round(maxHz / binWidth); diff --git a/src/AnalysisPrograms/Recognizers/Base/VerticalTrackParameters.cs b/src/AnalysisPrograms/Recognizers/Base/UpwardTrackParameters.cs similarity index 78% rename from src/AnalysisPrograms/Recognizers/Base/VerticalTrackParameters.cs rename to src/AnalysisPrograms/Recognizers/Base/UpwardTrackParameters.cs index ed5941e0a..ee87af862 100644 --- a/src/AnalysisPrograms/Recognizers/Base/VerticalTrackParameters.cs +++ b/src/AnalysisPrograms/Recognizers/Base/UpwardTrackParameters.cs @@ -1,4 +1,4 @@ -// +// // All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). // @@ -15,9 +15,10 @@ namespace AnalysisPrograms.Recognizers.Base /// /// Parameters needed from a config file to detect vertical track components i.e. events which are completed within very few time frames, i.e. whips and near clicks. + /// An UpwardTrack sounds like a whip. Each track point ascends one frequency bin. Points may move forwards or back one frame step. /// - [YamlTypeTag(typeof(VerticalTrackParameters))] - public class VerticalTrackParameters : CommonParameters + [YamlTypeTag(typeof(UpwardTrackParameters))] + public class UpwardTrackParameters : CommonParameters { /// /// Gets or sets the minimum bandwidth, units = Hertz. @@ -45,11 +46,19 @@ public class VerticalTrackParameters : CommonParameters /// They would typically be only a few time-frames duration. /// THis method averages dB log values incorrectly but it is faster than doing many log conversions and is accurate enough for the purpose. /// - public static (List Events, double[] CombinedIntensity) GetVerticalTracks( + /// The spectrogram to be searched. + /// Bottom of the frequency band to be searched. + /// Top of the frequency band to be searched. + /// Ignore spectrogram cells below this amplitude. + /// Minimum bandwidth (Hertz) of a valid event. + /// Maximum bandwidth (Hertz) of a valid event. + /// Combine tracks that are likely to be repeated chatter. + /// The start time of the current recording segment under analysis. + /// A list of acoustic events containing foward tracks. + public static (List Events, double[] CombinedIntensity) GetUpwardTracks( SpectrogramStandard sonogram, int minHz, int maxHz, - int nyquist, double decibelThreshold, int minBandwidthHertz, int maxBandwidthHertz, @@ -60,7 +69,7 @@ public static (List Events, double[] CombinedIntensity) GetVertic int frameCount = sonogramData.GetLength(0); int binCount = sonogramData.GetLength(1); var frameStep = sonogram.FrameStep; - + int nyquist = sonogram.NyquistFrequency; double binWidth = nyquist / (double)binCount; int minBin = (int)Math.Round(minHz / binWidth); int maxBin = (int)Math.Round(maxHz / binWidth); @@ -71,7 +80,8 @@ public static (List Events, double[] CombinedIntensity) GetVertic frameSize: sonogram.Configuration.WindowSize, frameOverlap: sonogram.Configuration.WindowOverlap); - //Find all frame peaks and place in peaks matrix + // Find all frame peaks and place in peaks matrix + // avoid row edge effects. var peaks = new double[frameCount, binCount]; for (int row = 1; row < frameCount - 1; row++) { @@ -92,7 +102,7 @@ public static (List Events, double[] CombinedIntensity) GetVertic } //NOTE: the Peaks matrix is same size as the sonogram. - var tracks = TrackExtractor.GetVerticalTracks(peaks, minBin, maxBin, minBandwidthHertz, maxBandwidthHertz, decibelThreshold, converter); + var tracks = TrackExtractor.GetUpwardTracks(peaks, minBin, maxBin, minBandwidthHertz, maxBandwidthHertz, decibelThreshold, converter); // initialise tracks as events and get the combined intensity array. var events = new List(); diff --git a/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs b/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs index 94e1f2854..7163e5322 100644 --- a/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs +++ b/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs @@ -28,10 +28,10 @@ namespace AnalysisPrograms.Recognizers /// public class GenericRecognizer : RecognizerBase { - private bool combineOverlappedEvents = false; - private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool combineOverlappedEvents = false; + /// public override string Author => "Ecosounds"; @@ -51,7 +51,6 @@ public override AnalyzerConfig ParseConfig(FileInfo file) // validation of configs can be done here // sanity check the algorithm - string algorithmName; foreach (var (profileName, profile) in result.Profiles) { if (profile is CommonParameters c) @@ -60,6 +59,7 @@ public override AnalyzerConfig ParseConfig(FileInfo file) c.MaxHertz.ConfigNotNull(nameof(c.MaxHertz), file); } + string algorithmName; switch (profile) { case BlobParameters _: @@ -74,10 +74,10 @@ public override AnalyzerConfig ParseConfig(FileInfo file) case HarmonicParameters _: algorithmName = "Harmonics"; break; - case HorizontalTrackParameters _: + case FowardTrackParameters _: algorithmName = "SpectralTrack"; break; - case VerticalTrackParameters _: + case UpwardTrackParameters _: algorithmName = "VerticalTrack"; break; case ClickParameters _: @@ -93,8 +93,8 @@ public override AnalyzerConfig ParseConfig(FileInfo file) $"{nameof(OscillationParameters)}," + $"{nameof(WhistleParameters)}," + $"{nameof(HarmonicParameters)}," + - $"{nameof(HorizontalTrackParameters)}," + - $"{nameof(VerticalTrackParameters)}," + + $"{nameof(FowardTrackParameters)}," + + $"{nameof(UpwardTrackParameters)}," + $"{nameof(ClickParameters)}," + $"{nameof(Aed.AedConfiguration)}"; throw new ConfigFileException($"The algorithm type in profile {profileName} is not recognized. It must be one of {allowedAlgorithms}"); @@ -150,8 +150,8 @@ public override RecognizerResults Recognize( || profileConfig is OscillationParameters || profileConfig is WhistleParameters || profileConfig is HarmonicParameters - || profileConfig is HorizontalTrackParameters - || profileConfig is VerticalTrackParameters + || profileConfig is FowardTrackParameters + || profileConfig is UpwardTrackParameters || profileConfig is ClickParameters) { sonogram = new SpectrogramStandard(ParametersToSonogramConfig(parameters), audioRecording.WavReader); @@ -244,14 +244,13 @@ public override RecognizerResults Recognize( var plot = PreparePlot(harmonicIntensityScores, $"{profileName} (Harmonics:dct intensity)", hp.DctThreshold.Value); plots.Add(plot); } - else if (profileConfig is HorizontalTrackParameters tp) + else if (profileConfig is FowardTrackParameters tp) { double[] decibelArray; - (acousticEvents, decibelArray) = HorizontalTrackParameters.GetFowardTracks( + (acousticEvents, decibelArray) = FowardTrackParameters.GetFowardTracks( sonogram, tp.MinHertz.Value, tp.MaxHertz.Value, - sonogram.NyquistFrequency, tp.DecibelThreshold.Value, tp.MinDuration.Value, tp.MaxDuration.Value, @@ -278,14 +277,13 @@ public override RecognizerResults Recognize( var plot = PreparePlot(decibelArray, $"{profileName} (Click:dB Intensity)", cp.DecibelThreshold.Value); plots.Add(plot); } - else if (profileConfig is VerticalTrackParameters vtp) + else if (profileConfig is UpwardTrackParameters vtp) { double[] decibelArray; - (acousticEvents, decibelArray) = VerticalTrackParameters.GetVerticalTracks( + (acousticEvents, decibelArray) = UpwardTrackParameters.GetUpwardTracks( sonogram, vtp.MinHertz.Value, vtp.MaxHertz.Value, - sonogram.NyquistFrequency, vtp.DecibelThreshold.Value, vtp.MinBandwidthHertz.Value, vtp.MaxBandwidthHertz.Value, diff --git a/src/AudioAnalysisTools/Events/Tracks/Track.cs b/src/AudioAnalysisTools/Events/Tracks/Track.cs index eb2b376a3..6de9938c5 100644 --- a/src/AudioAnalysisTools/Events/Tracks/Track.cs +++ b/src/AudioAnalysisTools/Events/Tracks/Track.cs @@ -17,12 +17,15 @@ public enum TrackType FowardTrack, // Sounds like fluctuating tone/chirp. Each track point advances one time step. Points may move up or down two frequency bins. UpwardTrack, // Sounds like whip. Each track point ascends one frequency bin. Points may move forwards or back one frame step. VerticalTrack, // Sounds like click. Each track point ascends one frequency bin. All points remain in the same time frame. + MixedTrack, // A track containing segments of two or more of the above. At present time, only created to accomodate test at TrackTests at Line 116. } public class Track : ITrack { private readonly UnitConverters converter; + private readonly TrackType trackType; + /// /// Initializes a new instance of the class. /// Constructor. @@ -31,20 +34,23 @@ public class Track : ITrack /// A reference to unit conversions this track class should use to /// convert spectrogram data to real units. /// - public Track(UnitConverters converter) + /// The type of track - see enum above. + public Track(UnitConverters converter, TrackType aTrackType) { this.converter = converter; + this.trackType = aTrackType; this.Points = new SortedSet(); } - /// + /// /// /// A set of initial points to add into the point data collection. /// public Track( UnitConverters converter, + TrackType trackType, params (int Frame, int Bin, double Amplitude)[] initialPoints) - : this(converter) + : this(converter, trackType) { foreach (var point in initialPoints) { @@ -52,8 +58,6 @@ public Track( } } - public TrackType trackType { get; } - public int PointCount => this.Points.Count; public double StartTimeSeconds => this.converter.SegmentStartOffset + this.Points.Min(x => x.Seconds.Minimum); @@ -126,6 +130,7 @@ public string CheckPoint(int frame, int bin) if (frame != outFrame || bin != outBin) { LoggedConsole.WriteWarnLine("WARNING" + info); + //throw new Exception("WARNING" + info); } else { @@ -179,6 +184,7 @@ public double[] GetTrackFrequencyProfile() /// /// Returns the maximum amplitude in each time frame. + /// TODO /// public double[] GetAmplitudeOverTimeFrames() { @@ -221,11 +227,10 @@ public void Draw(IImageProcessingContext graphics, EventRenderingOptions options ((IPointData)this).DrawPointsAsPath(graphics, options); break; case TrackType.FowardTrack: - ((IPointData)this).DrawPointsAsPath(graphics, options); + ((IPointData)this).DrawPointsAsFill(graphics, options); break; default: - //((IPointData)this).DrawPointsAsPath(graphics, options); - ((IPointData)this).DrawPointsAsFill(graphics, options); + ((IPointData)this).DrawPointsAsPath(graphics, options); break; } } diff --git a/src/AudioAnalysisTools/Events/Tracks/TrackExtractor.cs b/src/AudioAnalysisTools/Events/Tracks/TrackExtractor.cs index 918a0d2bb..fae233bd3 100644 --- a/src/AudioAnalysisTools/Events/Tracks/TrackExtractor.cs +++ b/src/AudioAnalysisTools/Events/Tracks/TrackExtractor.cs @@ -25,7 +25,7 @@ public static List GetFowardTracks(double[,] peaks, double minDuration, d for (int col = 3; col < bandwidthBinCount - 3; col++) { // Visit each spectral peak in order. Each may be start of possible track - var track = GetHorizontalTrack(peaks, row, col, threshold, converter); + var track = GetFowardTrack(peaks, row, col, threshold, converter); //If track has length within duration bounds, then add the track to list. if (track.TrackDurationSeconds >= minDuration && track.TrackDurationSeconds <= maxDuration) @@ -38,9 +38,9 @@ public static List GetFowardTracks(double[,] peaks, double minDuration, d return tracks; } - public static Track GetHorizontalTrack(double[,] peaks, int startRow, int startBin, double threshold, UnitConverters converter) + public static Track GetFowardTrack(double[,] peaks, int startRow, int startBin, double threshold, UnitConverters converter) { - var track = new Track(converter); + var track = new Track(converter, TrackType.FowardTrack); track.SetPoint(startRow, startBin, peaks[startRow, startBin]); // set the start point in peaks matrix to zero to prevent return to this point. @@ -87,7 +87,7 @@ public static Track GetHorizontalTrack(double[,] peaks, int startRow, int startB var maxId = DataTools.GetMaxIndex(options); // if track has come to an end - var maxValue = options[maxId] / 2; + var maxValue = options[maxId] / 2.0; if (maxValue < threshold) { break; @@ -129,7 +129,7 @@ public static Track GetHorizontalTrack(double[,] peaks, int startRow, int startB return track; } - public static List GetVerticalTracks(double[,] peaks, int minBin, int maxBin, double minBandwidthHertz, double maxBandwidthHertz, double threshold, UnitConverters converter) + public static List GetUpwardTracks(double[,] peaks, int minBin, int maxBin, double minBandwidthHertz, double maxBandwidthHertz, double threshold, UnitConverters converter) { int frameCount = peaks.GetLength(0); var tracks = new List(); @@ -146,9 +146,9 @@ public static List GetVerticalTracks(double[,] peaks, int minBin, int max } // Visit each spectral peak in order. Each may be start of possible track - var track = GetVerticalTrack(peaks, row, col, maxBin, threshold, converter); + var track = GetUpwardTrack(peaks, row, col, maxBin, threshold, converter); - //If track has lies within the correct bandWidth range, then create an event + //If track lies within the correct bandWidth range, then return as track. if (track.TrackBandWidthHertz >= minBandwidthHertz && track.TrackBandWidthHertz <= maxBandwidthHertz) { tracks.Add(track); @@ -159,15 +159,15 @@ public static List GetVerticalTracks(double[,] peaks, int minBin, int max return tracks; } - public static Track GetVerticalTrack(double[,] peaks, int startRow, int startBin, int maxBin, double threshold, UnitConverters converter) + public static Track GetUpwardTrack(double[,] peaks, int startRow, int startBin, int maxBin, double threshold, UnitConverters converter) { - var track = new Track(converter); + var track = new Track(converter, TrackType.UpwardTrack); track.SetPoint(startRow, startBin, peaks[startRow, startBin]); // set the start point in peaks matrix to zero to prevent return to this point. peaks[startRow, startBin] = 0.0; - int row = startRow; + int row = startRow; for (int bin = startBin; bin < maxBin - 1; bin++) { // Avoid row edge effects. @@ -184,24 +184,28 @@ public static Track GetVerticalTrack(double[,] peaks, int startRow, int startBin return track; } - // explore options for track vertical - double optionStraight = Math.Max(peaks[row, bin] + peaks[row, bin + 1], peaks[row, bin] + peaks[row - 1, bin + 1]); - optionStraight = Math.Max(optionStraight, peaks[row, bin] + peaks[row + 1, bin + 1]); + // explore options for track moving to next higher frequency bin + // We are looking for the option which has the highest combined amplitude. + double optionStraight = Math.Max(peaks[row, bin + 1], peaks[row - 1, bin + 1]); + optionStraight = Math.Max(optionStraight, peaks[row + 1, bin + 1]); + optionStraight = peaks[row, bin] + optionStraight; // option for track with negative slope i.e. return to previous row/frame. - double optionDown = Math.Max(peaks[row - 1, bin] + peaks[row - 1, bin + 1], peaks[row - 1, bin] + peaks[row - 2, bin + 1]); - optionDown = Math.Max(optionDown, peaks[row - 1, bin] + peaks[row - 1, bin + 1]); + //double optionNeg = Math.Max(peaks[row - 1, bin + 1], peaks[row, bin + 1]); + double optionNeg = Math.Max(peaks[row - 1, bin + 1], peaks[row - 2, bin + 1]); + optionNeg = peaks[row - 1, bin] + optionNeg; // option for track with positive slope - double optionUp = Math.Max(peaks[row + 1, bin] + peaks[row + 1, bin + 1], peaks[row + 1, bin] + peaks[row + 2, bin + 1]); - optionUp = Math.Max(optionUp, peaks[row + 1, bin] + peaks[row + 2, bin + 1]); + //double optionPos = Math.Max(peaks[row + 1, bin + 1], peaks[row, bin + 1]); + double optionPos = Math.Max(peaks[row + 1, bin + 1], peaks[row + 2, bin + 1]); + optionPos = peaks[row + 1, bin] + optionPos; // get max of the three next possible steps - double[] options = { optionStraight, optionDown, optionUp }; - var maxId = DataTools.GetMaxIndex(options); + double[] directionOptions = { optionStraight, optionNeg, optionPos }; + var maxId = DataTools.GetMaxIndex(directionOptions); // Check if track has come to an end - average value of the two values is less than threshold. - var maxValue = options[maxId] / 2; + var maxValue = directionOptions[maxId] / 2.0; if (maxValue < threshold) { return track; diff --git a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizer/GenericRecognizerTests.cs b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizer/GenericRecognizerTests.cs index 95ff71db0..1dbb101b9 100644 --- a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizer/GenericRecognizerTests.cs +++ b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizer/GenericRecognizerTests.cs @@ -311,7 +311,7 @@ public void TestHarmonicsAlgorithm() } [TestMethod] - public void TestFowardsTrackAlgorithm() + public void TestFowardTrackAlgorithm() { // Set up the recognizer parameters. var windowSize = 512; @@ -349,11 +349,10 @@ public void TestFowardsTrackAlgorithm() var plots = new List(); double[] dBArray; List acousticEvents; - (acousticEvents, dBArray) = HorizontalTrackParameters.GetFowardTracks( + (acousticEvents, dBArray) = FowardTrackParameters.GetFowardTracks( spectrogram, minHertz, maxHertz, - spectrogram.NyquistFrequency, decibelThreshold, minDuration, maxDuration, @@ -385,7 +384,7 @@ public void TestFowardsTrackAlgorithm() // DEBUG PURPOSES COMMENT NEXT LINE var outputDirectory = new DirectoryInfo("C:\\temp"); - GenericRecognizer.SaveDebugSpectrogram(allResults, null, outputDirectory, "FowardsTrack"); + GenericRecognizer.SaveDebugSpectrogram(allResults, null, outputDirectory, "FowardTrack"); Assert.AreEqual(23, allResults.Events.Count); @@ -495,7 +494,7 @@ public void TestClickAlgorithm() } /// - /// Tests the upwards-track recognizer on the same artifical spectrogram as used for fowards-tracks and harmonics. + /// Tests the upward-track recognizer on the same artifical spectrogram as used for foward-tracks and harmonics. /// [TestMethod] public void TestUpwardsTrackAlgorithm() @@ -536,11 +535,10 @@ public void TestUpwardsTrackAlgorithm() var plots = new List(); double[] dBArray; List acousticEvents; - (acousticEvents, dBArray) = VerticalTrackParameters.GetVerticalTracks( + (acousticEvents, dBArray) = UpwardTrackParameters.GetUpwardTracks( spectrogram, minHertz, maxHertz, - spectrogram.NyquistFrequency, decibelThreshold, minBandwidthHertz, maxBandwidthHertz, @@ -572,7 +570,7 @@ public void TestUpwardsTrackAlgorithm() // DEBUG PURPOSES ONLY - COMMENT NEXT LINE var outputDirectory = new DirectoryInfo("C:\\temp"); - GenericRecognizer.SaveDebugSpectrogram(allResults, null, outputDirectory, "VerticalTracks1"); + GenericRecognizer.SaveDebugSpectrogram(allResults, null, outputDirectory, "UpwardTracks1"); Assert.AreEqual(2, allResults.Events.Count); @@ -591,13 +589,12 @@ public void TestUpwardsTrackAlgorithm() // do a SECOND TEST of the vertical tracks minHertz = 500; maxHertz = 6000; - minBandwidthHertz = 200; + minBandwidthHertz = 100; maxBandwidthHertz = 5000; - (acousticEvents, dBArray) = VerticalTrackParameters.GetVerticalTracks( + (acousticEvents, dBArray) = UpwardTrackParameters.GetUpwardTracks( spectrogram, minHertz, maxHertz, - spectrogram.NyquistFrequency, decibelThreshold, minBandwidthHertz, maxBandwidthHertz, @@ -626,7 +623,7 @@ public void TestUpwardsTrackAlgorithm() allResults2.Sonogram = spectrogram; // DEBUG PURPOSES ONLY - COMMENT NEXT LINE - GenericRecognizer.SaveDebugSpectrogram(allResults2, null, outputDirectory, "VerticalTracks2"); + GenericRecognizer.SaveDebugSpectrogram(allResults2, null, outputDirectory, "UpwardTracks2"); Assert.AreEqual(5, allResults2.Events.Count); } diff --git a/tests/Acoustics.Test/AudioAnalysisTools/Events/Tracks/TrackTests.cs b/tests/Acoustics.Test/AudioAnalysisTools/Events/Tracks/TrackTests.cs index 495d367e3..8267d3c34 100644 --- a/tests/Acoustics.Test/AudioAnalysisTools/Events/Tracks/TrackTests.cs +++ b/tests/Acoustics.Test/AudioAnalysisTools/Events/Tracks/TrackTests.cs @@ -29,6 +29,7 @@ public class TrackTests public static readonly Track TestTrack_TimePositive_FrequencyPositive = new Track( NiceTestConverter, + TrackType.FowardTrack, (5, 5, 1), (6, 6, 2), (7, 7, 3), @@ -63,9 +64,9 @@ public void TestTrackProperties() [TestMethod] public void TestWhistleProperties() - { + { //create new track with whistle - var track = new Track(NiceTestConverter); + var track = new Track(NiceTestConverter, TrackType.HorizontalTrack); track.SetPoint(5, 5, 1); track.SetPoint(6, 5, 2); track.SetPoint(7, 5, 3); @@ -90,7 +91,7 @@ public void TestWhistleProperties() public void TestClickProperties() { //Create new track with click - var track = new Track(NiceTestConverter); + var track = new Track(NiceTestConverter, TrackType.VerticalTrack); track.SetPoint(5, 5, 1); track.SetPoint(5, 6, 2); track.SetPoint(5, 7, 3); @@ -117,7 +118,7 @@ public void TestTrackAsSequenceOfHertzValues() // Create new track with flat and vertical parts // frame duration = 0.1 seconds. // Bin width = 10 Hz. - var track = new Track(NiceTestConverter); + var track = new Track(NiceTestConverter, TrackType.MixedTrack); track.SetPoint(5, 5, 1); track.SetPoint(6, 5, 2); track.SetPoint(7, 6, 3); @@ -132,7 +133,7 @@ public void TestTrackAsSequenceOfHertzValues() CollectionAssert.AreEqual(expectedArray, hertzTrack); // Create new track that apparently goes backwards in time! - track = new Track(NiceTestConverter); + track = new Track(NiceTestConverter, TrackType.UpwardTrack); track.SetPoint(10, 4, 1); track.SetPoint(9, 5, 2); track.SetPoint(8, 6, 3);