Skip to content

Commit

Permalink
Create two new event typ0es
Browse files Browse the repository at this point in the history
Issue #297
  • Loading branch information
towsey committed Apr 20, 2020
1 parent 04a0808 commit 3f0e9c6
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/AudioAnalysisTools/Events/Types/ChatterEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// <copyright file="ChatterEvent.cs" company="QutEcoacoustics">
// 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).
// </copyright>

namespace AudioAnalysisTools.Events.Types
{
using System;
using System.Collections.Generic;
using AudioAnalysisTools.Events;
using AudioAnalysisTools.Events.Drawing;
using AudioAnalysisTools.Events.Interfaces;
using SixLabors.ImageSharp.Processing;

public class ChatterEvent : SpectralEvent, ITracks
{
public ChatterEvent(List<ITrack> chitters)
{
this.Tracks = chitters;
}

public List<ITrack> Tracks { get; }
}
}
62 changes: 62 additions & 0 deletions src/AudioAnalysisTools/Events/Types/CompositeEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// <copyright file="CompositeEvent.cs" company="QutEcoacoustics">
// 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).
// </copyright>

namespace AudioAnalysisTools.Events.Types
{
using System;
using System.Collections.Generic;
using System.Linq;
using AnalysisBase.ResultBases;
using AudioAnalysisTools.Events;
using AudioAnalysisTools.Events.Drawing;
using AudioAnalysisTools.Events.Interfaces;
using SixLabors.ImageSharp.Processing;

public class CompositeEvent : SpectralEvent
{
public List<EventCommon> ComponentEvents { get; set; } = new List<EventCommon>();

public override double EventStartSeconds =>
this.ComponentEvents.Min(x => x.EventStartSeconds);

public override double EventEndSeconds =>
this.ComponentEvents.Max(x => (x as ITemporalEvent)?.EventEndSeconds) ?? double.PositiveInfinity;

public override double LowFrequencyHertz =>
this.ComponentEvents.Min(x => (x as ISpectralEvent)?.LowFrequencyHertz) ?? 0;

public override double HighFrequencyHertz =>
this.ComponentEvents.Max(x => (x as ISpectralEvent)?.HighFrequencyHertz) ?? double.PositiveInfinity;

public IEnumerable<ITrack> Tracks
{
get
{
foreach (var @event in this.ComponentEvents)
{
if (@event is ITracks eventWithTracks)
{
foreach (var track in eventWithTracks.Tracks)
{
yield return track;
}
}
}
}
}

public override void Draw(IImageProcessingContext graphics, EventRenderingOptions options)
{
foreach (var @event in this.ComponentEvents)
{
// disable border
// options.DisableBorder = true
@event.Draw(graphics, options);
}

// draw a border around all of it
base.Draw(graphics, options);
}
}
}

0 comments on commit 3f0e9c6

Please sign in to comment.