Skip to content

Commit

Permalink
Removed PlaybackHint
Browse files Browse the repository at this point in the history
  • Loading branch information
melanchall committed Sep 30, 2024
1 parent c29851d commit 1674565
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 297 deletions.
37 changes: 0 additions & 37 deletions DryWetMidi.Tests/Multimedia/Playback/PlaybackTests.Asserts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,6 @@ namespace Melanchall.DryWetMidi.Tests.Multimedia
[TestFixture]
public sealed partial class PlaybackTests
{
private void CheckNoEventsFiredTrackingDisabled(
ICollection<ITimedObject> objects,
PlaybackHint playbackHint)
{
var tempoMap = TempoMap.Default;
var playedEvents = new List<MidiEvent>();

using (var playback = new Playback(objects, tempoMap, new PlaybackSettings { Hint = playbackHint }))
{
playback.EventPlayed += (_, e) => playedEvents.Add(e.Event);

playback.Start();
playback.MoveToTime(new MetricTimeSpan(0, 0, 0, 750));
playback.MoveToStart();
playback.Stop();
}

CollectionAssert.IsEmpty(playedEvents, "Events are played.");
}

private void CheckFailOnEnableTracking(
PlaybackHint playbackHint,
Action<Playback> enableTracking)
{
var objects = new[]
{
new TimedEvent(new NoteOnEvent()),
};

using (var playback = new Playback(objects, TempoMap.Default, new PlaybackSettings { Hint = playbackHint }))
{
Assert.Throws<InvalidOperationException>(
() => enableTracking(playback),
"No exception thrown.");
}
}

private IEnumerable<SnapPoint> GetActiveSnapPoints(Playback playback)
{
return playback.Snapping.GetActiveSnapPoints().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,16 @@
using System.Collections.Generic;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Multimedia;
using NUnit.Framework;

namespace Melanchall.DryWetMidi.Tests.Multimedia
{
// TODO: check tracking disabled
[TestFixture]
public sealed partial class PlaybackTests
{
#region Test methods

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisableControlValueTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisableControlValueTracking_NoEventsFired(PlaybackHint playbackHint) => CheckNoEventsFiredTrackingDisabled(
objects: new[]
{
new TimedEvent(new NoteOnEvent()).SetTime(new MetricTimeSpan(0, 0, 0, 500), TempoMap.Default),
new TimedEvent(new ControlChangeEvent((SevenBitNumber)70, (SevenBitNumber)10)).SetTime(new MetricTimeSpan(0, 0, 0, 600), TempoMap.Default),
new TimedEvent(new NoteOffEvent()).SetTime(new MetricTimeSpan(0, 0, 1), TempoMap.Default),
},
playbackHint: playbackHint);

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisableControlValueTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisableControlValueTracking_FailOnEnableTracking(PlaybackHint playbackHint) => CheckFailOnEnableTracking(
playbackHint: playbackHint,
enableTracking: playback => playback.TrackControlValue = true);

[Retry(RetriesNumber)]
[TestCase(true, 0)]
[TestCase(true, 100)]
Expand Down
23 changes: 0 additions & 23 deletions DryWetMidi.Tests/Multimedia/Playback/PlaybackTests.TrackNotes.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Multimedia;
using Melanchall.DryWetMidi.Tests.Common;
using NUnit.Framework;

namespace Melanchall.DryWetMidi.Tests.Multimedia
Expand All @@ -15,24 +10,6 @@ public sealed partial class PlaybackTests
{
#region Test methods

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisableNotesTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisableNotesTracking_NoEventsFired(PlaybackHint playbackHint) => CheckNoEventsFiredTrackingDisabled(
objects: new[]
{
new TimedEvent(new NoteOnEvent()).SetTime(new MetricTimeSpan(0, 0, 0, 500), TempoMap.Default),
new TimedEvent(new NoteOffEvent()).SetTime(new MetricTimeSpan(0, 0, 1), TempoMap.Default),
},
playbackHint: playbackHint);

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisableNotesTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisableNotesTracking_FailOnEnableTracking(PlaybackHint playbackHint) => CheckFailOnEnableTracking(
playbackHint: playbackHint,
enableTracking: playback => playback.TrackNotes = true);

[Retry(RetriesNumber)]
[TestCase(true)]
[TestCase(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,16 @@
using System.Collections.Generic;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Multimedia;
using NUnit.Framework;

namespace Melanchall.DryWetMidi.Tests.Multimedia
{
// TODO: check tracking disabled
[TestFixture]
public sealed partial class PlaybackTests
{
#region Test methods

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisablePitchValueTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisablePitchValueTracking_NoEventsFired(PlaybackHint playbackHint) => CheckNoEventsFiredTrackingDisabled(
objects: new[]
{
new TimedEvent(new NoteOnEvent()).SetTime(new MetricTimeSpan(0, 0, 0, 500), TempoMap.Default),
new TimedEvent(new PitchBendEvent(1200)).SetTime(new MetricTimeSpan(0, 0, 0, 600), TempoMap.Default),
new TimedEvent(new NoteOffEvent()).SetTime(new MetricTimeSpan(0, 0, 1), TempoMap.Default),
},
playbackHint: playbackHint);

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisablePitchValueTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisablePitchValueTracking_FailOnEnableTracking(PlaybackHint playbackHint) => CheckFailOnEnableTracking(
playbackHint: playbackHint,
enableTracking: playback => playback.TrackPitchValue = true);

[Retry(RetriesNumber)]
[TestCase(true, 0)]
[TestCase(true, 100)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,16 @@
using System.Collections.Generic;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Multimedia;
using NUnit.Framework;

namespace Melanchall.DryWetMidi.Tests.Multimedia
{
// TODO: check tracking disabled
[TestFixture]
public sealed partial class PlaybackTests
{
#region Test methods

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisableProgramTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisableProgramTracking_NoEventsFired(PlaybackHint playbackHint) => CheckNoEventsFiredTrackingDisabled(
objects: new[]
{
new TimedEvent(new NoteOnEvent()).SetTime(new MetricTimeSpan(0, 0, 0, 500), TempoMap.Default),
new TimedEvent(new ProgramChangeEvent((SevenBitNumber)70)).SetTime(new MetricTimeSpan(0, 0, 0, 600), TempoMap.Default),
new TimedEvent(new NoteOffEvent()).SetTime(new MetricTimeSpan(0, 0, 1), TempoMap.Default),
},
playbackHint: playbackHint);

[Retry(RetriesNumber)]
[TestCase(PlaybackHint.DisableProgramTracking)]
[TestCase(PlaybackHint.DisableDataTracking)]
public void DisableProgramTracking_FailOnEnableTracking(PlaybackHint playbackHint) => CheckFailOnEnableTracking(
playbackHint: playbackHint,
enableTracking: playback => playback.TrackProgram = true);

[Retry(RetriesNumber)]
[TestCase(true, 0)]
[TestCase(true, 100)]
Expand Down
Loading

0 comments on commit 1674565

Please sign in to comment.