From d50ccf7b481118200bf3614186c0df5d3cd40daa Mon Sep 17 00:00:00 2001 From: Maxim Dobroselsky Date: Sun, 18 Aug 2024 18:19:09 +0300 Subject: [PATCH] Changed default value of SanitizingSettings.Trim to false --- Docs/articles/tools/Sanitizer.md | 2 +- .../SanitizerTests.RemoveEventsOnUnusedChannels.cs | 13 ++++++++++--- .../Tools/Sanitizer/SanitizerTests.Trim.cs | 12 ++++++++---- DryWetMidi/Tools/Sanitizer/SanitizingSettings.cs | 4 ++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Docs/articles/tools/Sanitizer.md b/Docs/articles/tools/Sanitizer.md index 50e075773..546272e3f 100644 --- a/Docs/articles/tools/Sanitizer.md +++ b/Docs/articles/tools/Sanitizer.md @@ -135,7 +135,7 @@ var midiFile = new MidiFile( new TextEvent("C") { DeltaTime = 15 })); ``` -Here we have a silence of 20 ticks at the start of the file. So after sanitizing with `Trim` property set to `true` (the default value) we will have this file: +Here we have a silence of 20 ticks at the start of the file. So after sanitizing with `Trim` property set to `true` we will have this file: ```csharp var midiFile = new MidiFile( diff --git a/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.RemoveEventsOnUnusedChannels.cs b/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.RemoveEventsOnUnusedChannels.cs index 96ac00398..31ee81f7b 100644 --- a/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.RemoveEventsOnUnusedChannels.cs +++ b/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.RemoveEventsOnUnusedChannels.cs @@ -28,7 +28,10 @@ public void Sanitize_RemoveEventsOnUnusedChannels_AllChannelsInUse() => Sanitize new TrackChunk( new NoteOnEvent() { Channel = (FourBitNumber)7 }, new NoteOffEvent() { Channel = (FourBitNumber)7 })), - settings: null, + settings: new SanitizingSettings + { + RemoveDuplicatedNotes = false, + }, expectedMidiFile: new MidiFile( new TrackChunk( new NoteOnEvent(), @@ -52,7 +55,10 @@ public void Sanitize_RemoveEventsOnUnusedChannels_1() => Sanitize( new TrackChunk( new NoteOnEvent(), new NoteOffEvent())), - settings: null, + settings: new SanitizingSettings + { + RemoveDuplicatedNotes = false, + }, expectedMidiFile: new MidiFile( new TrackChunk( new NoteOnEvent(), @@ -174,7 +180,8 @@ public void Sanitize_RemoveEventsOnUnusedChannels_False_1() => Sanitize( new NoteOffEvent())), settings: new SanitizingSettings { - RemoveEventsOnUnusedChannels = false + RemoveEventsOnUnusedChannels = false, + RemoveDuplicatedNotes = false, }, expectedMidiFile: new MidiFile( new TrackChunk( diff --git a/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.Trim.cs b/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.Trim.cs index 90fa038f3..2b0a870a0 100644 --- a/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.Trim.cs +++ b/DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.Trim.cs @@ -36,7 +36,8 @@ public void Sanitize_Trim_SingleTrackChunk_1([Values(0, 100, 1000)] long firstEv new TextEvent("A") { DeltaTime = firstEventTime })), settings: new SanitizingSettings { - RemoveEmptyTrackChunks = false + RemoveEmptyTrackChunks = false, + Trim = true, }, expectedMidiFile: new MidiFile( new TrackChunk( @@ -50,7 +51,8 @@ public void Sanitize_Trim_SingleTrackChunk_2([Values(0, 100, 1000)] long firstEv new TrackChunk()), settings: new SanitizingSettings { - RemoveEmptyTrackChunks = false + RemoveEmptyTrackChunks = false, + Trim = true, }, expectedMidiFile: new MidiFile( new TrackChunk( @@ -71,7 +73,8 @@ public void Sanitize_Trim_MultipleTrackChunks_1( new TextEvent("B") { DeltaTime = bFirstEventTime })), settings: new SanitizingSettings { - RemoveEmptyTrackChunks = false + RemoveEmptyTrackChunks = false, + Trim = true, }, expectedMidiFile: new MidiFile( new TrackChunk( @@ -95,7 +98,8 @@ public void Sanitize_Trim_MultipleTrackChunks_2( new TextEvent("B") { DeltaTime = bFirstEventTime })), settings: new SanitizingSettings { - RemoveEmptyTrackChunks = false + RemoveEmptyTrackChunks = false, + Trim = true, }, expectedMidiFile: new MidiFile( new TrackChunk( diff --git a/DryWetMidi/Tools/Sanitizer/SanitizingSettings.cs b/DryWetMidi/Tools/Sanitizer/SanitizingSettings.cs index 11c139038..470f1a96e 100644 --- a/DryWetMidi/Tools/Sanitizer/SanitizingSettings.cs +++ b/DryWetMidi/Tools/Sanitizer/SanitizingSettings.cs @@ -87,10 +87,10 @@ public sealed class SanitizingSettings /// /// Gets or sets a value indicating whether a silence at the start of a MIDI file should be - /// removed or not. The default value is true. More info in the + /// removed or not. The default value is false. More info in the /// Sanitizer: Trim article. /// - public bool Trim { get; set; } = true; + public bool Trim { get; set; } = false; #endregion }