Skip to content

Commit

Permalink
Update AcousticEvent.cs
Browse files Browse the repository at this point in the history
Issue #297 Create new constructor for ACousticEvent class to init with a track.
  • Loading branch information
towsey committed Apr 21, 2020
1 parent 99d3394 commit 07ac99f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/AudioAnalysisTools/AcousticEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,29 @@ public AcousticEvent(TimeSpan segmentStartOffset, double eventStartSegmentRelati
this.Oblong = null;
}

/// <summary>
/// Initializes a new instance of the <see cref="AcousticEvent"/> class.
/// This constructor is passed a track.
/// NOTE: The track is already in time relative to recording start.
/// </summary>
public AcousticEvent(TimeSpan segmentStartOffset, Track track)
: this()
{
var eventStartSegmentRelative = track.StartTimeSeconds - segmentStartOffset.TotalSeconds;
var eventEndSegmentRelative = eventStartSegmentRelative + track.TrackDurationSeconds;
this.SetEventPositionRelative(segmentStartOffset, eventStartSegmentRelative, eventEndSegmentRelative);
this.LowFrequencyHertz = track.LowFreqHertz;
this.HighFrequencyHertz = track.HighFreqHertz;
//this.SegmentDurationSeconds = frameCount * frameStep;
this.tracks = new List<Track>
{
track,
};

// have no info to convert time/Hz values to coordinates
this.Oblong = null;
}

/// <summary>
/// Initializes a new instance of the <see cref="AcousticEvent"/> class.
/// This constructor currently works ONLY for linear Hertz scale events.
Expand Down

0 comments on commit 07ac99f

Please sign in to comment.