Skip to content

Commit

Permalink
Update ForwardTrackAlgorithm.cs
Browse files Browse the repository at this point in the history
Issue #370 Change the decibel intensity array that is displayed with the spectrogram. Helps in debugging results.
  • Loading branch information
towsey authored and atruskie committed Oct 14, 2020
1 parent c3bfb48 commit 9575f90
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/AudioAnalysisTools/Tracks/ForwardTrackAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ public static (List<EventCommon> Events, double[] CombinedIntensity) GetForwardT
// Initialise events with tracks.
foreach (var track in tracks)
{
// fill the intensity array with decibel values
var startRow = converter.FrameFromStartTime(track.StartTimeSeconds);
var amplitudeTrack = track.GetAmplitudeOverTimeFrames();
for (int i = 0; i < amplitudeTrack.Length; i++)
{
combinedIntensityArray[startRow + i] = Math.Max(combinedIntensityArray[startRow + i], amplitudeTrack[i]);
}

// Skip tracks that do not have duration within required duration bounds.
if (track.DurationSeconds < minDuration || track.DurationSeconds > maxDuration)
{
continue;
}

//Following line used only for debug purposes. Can save as image.
//spectrogram.Mutate(x => track.Draw(x, options));
var maxScore = decibelThreshold * 5;
Expand All @@ -97,14 +111,6 @@ public static (List<EventCommon> Events, double[] CombinedIntensity) GetForwardT
};

events.Add(ae);

// fill the intensity array with decibel values
var startRow = converter.FrameFromStartTime(track.StartTimeSeconds);
var amplitudeTrack = track.GetAmplitudeOverTimeFrames();
for (int i = 0; i < amplitudeTrack.Length; i++)
{
combinedIntensityArray[startRow + i] = Math.Max(combinedIntensityArray[startRow + i], amplitudeTrack[i]);
}
}

List<EventCommon> returnEvents = events.Cast<EventCommon>().ToList();
Expand Down Expand Up @@ -152,12 +158,7 @@ public static List<Track> GetForwardTracks(double[,] peaks, double minDuration,

// Visit each spectral peak in order. Each may be start of possible track
var track = GetForwardTrack(peaks, row, col, threshold, converter);

//If track has length within duration bounds, then add the track to list.
if (track.DurationSeconds >= minDuration && track.DurationSeconds <= maxDuration)
{
tracks.Add(track);
}
tracks.Add(track);
}
}

Expand Down

0 comments on commit 9575f90

Please sign in to comment.