private void Merge_OffVelocityMergingPolicy(VelocityMergingPolicy offVelocityMergingPolicy, SevenBitNumber expectedVelocity) { var noteNumber = (SevenBitNumber)100; var channel = (FourBitNumber)10; var tempoMap = TempoMap.Default; var inputNotes = CreateNotes( new[] { "0; 0:0:2", "0:0:1; 0:2:0" }, noteNumber, channel, tempoMap).ToArray(); inputNotes[0].OffVelocity = (SevenBitNumber)100; inputNotes[1].OffVelocity = (SevenBitNumber)50; var expectedNotes = CreateNotes( new[] { "0; 0:2:1" }, noteNumber, channel, tempoMap).ToArray(); expectedNotes[0].OffVelocity = expectedVelocity; Merge( inputNotes, expectedNotes, tempoMap, offVelocityMergingPolicy: offVelocityMergingPolicy); }
private void Merge(IEnumerable <Note> inputNotes, IEnumerable <Note> expectedNotes, TempoMap tempoMap, VelocityMergingPolicy velocityMergingPolicy = VelocityMergingPolicy.First, VelocityMergingPolicy offVelocityMergingPolicy = VelocityMergingPolicy.Last, ITimeSpan tolerance = null) { var settings = new NotesMergingSettings { VelocityMergingPolicy = velocityMergingPolicy, OffVelocityMergingPolicy = offVelocityMergingPolicy, Tolerance = tolerance ?? new MidiTimeSpan() }; var actualNotes = new NotesMerger().Merge(inputNotes, tempoMap, settings); MidiAsserts.AreEqual( expectedNotes.OrderBy(n => n.Time), actualNotes.OrderBy(n => n.Time), "Merging detached notes failed."); // var trackChunk = inputNotes.ToTrackChunk(); trackChunk.MergeNotes(tempoMap, settings); MidiAsserts.AreEqual( expectedNotes.OrderBy(n => n.Time), trackChunk.GetNotes(), "Merging notes inside a track chunk failed."); // var midiFile = inputNotes.ToFile(); midiFile.MergeNotes(settings); MidiAsserts.AreEqual( expectedNotes.OrderBy(n => n.Time), midiFile.GetNotes(), "Merging notes inside a file failed."); }
public void Merge_OffVelocityMergingPolicy_First(VelocityMergingPolicy policy, byte expectedVelocity) { Merge_OffVelocityMergingPolicy(policy, (SevenBitNumber)expectedVelocity); }