Skip to content

Commit

Permalink
Changed default value of SanitizingSettings.Trim to false
Browse files Browse the repository at this point in the history
  • Loading branch information
melanchall committed Aug 18, 2024
1 parent 598cb1e commit d50ccf7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Docs/articles/tools/Sanitizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 8 additions & 4 deletions DryWetMidi.Tests/Tools/Sanitizer/SanitizerTests.Trim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions DryWetMidi/Tools/Sanitizer/SanitizingSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public sealed class SanitizingSettings

/// <summary>
/// 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 <c>true</c>. More info in the
/// removed or not. The default value is <c>false</c>. More info in the
/// <see href="xref:a_sanitizer#trim">Sanitizer: Trim</see> article.
/// </summary>
public bool Trim { get; set; } = true;
public bool Trim { get; set; } = false;

#endregion
}
Expand Down

0 comments on commit d50ccf7

Please sign in to comment.