public void TestAddNamedTrack() { var manualMidi = new MidiEventCollection(1, 200); var noteEvent = new NoteOnEvent(0, 1, 1, 1, 1); const string trackName = "name"; var trackNameEvent = new TextEvent(trackName, MetaEventType.SequenceTrackName, 0); var endTrackEvent = new MetaEvent(MetaEventType.EndTrack, 0, noteEvent.OffEvent.AbsoluteTime); var track = manualMidi.AddTrack(); track.Add(trackNameEvent); track.Add(noteEvent); track.Add(noteEvent.OffEvent); track.Add(endTrackEvent); var extensionMidi = new MidiEventCollection(1, 200); var events = new MidiEvent[] { noteEvent, noteEvent.OffEvent }; extensionMidi.AddNamedTrack(trackName, events); MidiAssert.Equal(manualMidi, extensionMidi); // Assert events (not name / end) are the same objects var manualTrack = manualMidi[0]; var extensionTrack = extensionMidi[0]; for (var e = 1; e < manualTrack.Count - 1; e++) { Assert.That(extensionTrack[e], Is.SameAs(manualTrack[e])); } }
public void TestAddNamedTrackCopyWithOwnEnd() { var manualMidi = new MidiEventCollection(1, 200); var noteEvent = new NoteOnEvent(0, 1, 1, 1, 1); const string trackName = "name"; var trackNameEvent = new TextEvent(trackName, MetaEventType.SequenceTrackName, 0); var endTrackEvent = new MetaEvent(MetaEventType.EndTrack, 0, 90); var track = manualMidi.AddTrack(); track.Add(trackNameEvent); track.Add(noteEvent); track.Add(noteEvent.OffEvent); track.Add(endTrackEvent); var extensionMidi = new MidiEventCollection(1, 200); var events = new MidiEvent[] { noteEvent, noteEvent.OffEvent, endTrackEvent }; extensionMidi.AddNamedTrackCopy(trackName, events); MidiAssert.Equal(manualMidi, extensionMidi); // Assert they aren't the same objects var manualTrack = manualMidi[0]; var extensionTrack = extensionMidi[0]; for (var e = 0; e < manualTrack.Count; e++) { Assert.That(extensionTrack[e], Is.Not.SameAs(manualTrack[e])); } // Verify the NoteOnEvent.OffEvent link Assert.AreEqual(extensionMidi[0][2], ((NoteOnEvent)extensionMidi[0][1]).OffEvent); }
public void TestAddTrackCopyParams() { var manualMidi = new MidiEventCollection(1, 200); var noteEvent = new NoteOnEvent(0, 1, 1, 1, 1); var track = manualMidi.AddTrack(); track.Add(noteEvent); track.Add(noteEvent.OffEvent); var extensionMidi = new MidiEventCollection(1, 200); extensionMidi.AddTrackCopy(noteEvent, noteEvent.OffEvent); MidiAssert.Equal(manualMidi, extensionMidi); // Assert they aren't the same objects var manualTrack = manualMidi[0]; var extensionTrack = extensionMidi[0]; for (var e = 0; e < manualTrack.Count; e++) { Assert.That(extensionTrack[e], Is.Not.SameAs(manualTrack[e])); } // Verify the NoteOnEvent.OffEvent link Assert.AreEqual(extensionMidi[0][1], ((NoteOnEvent)extensionMidi[0][0]).OffEvent); }
public void TestClone() { var manualMidi = new MidiEventCollection(1, 200); var noteEvent1 = new NoteOnEvent(0, 1, 1, 1, 1); const string trackName1 = "name"; var trackNameEvent1 = new TextEvent(trackName1, MetaEventType.SequenceTrackName, 0); var endTrackEvent1 = new MetaEvent(MetaEventType.EndTrack, 0, noteEvent1.OffEvent.AbsoluteTime); var track1 = manualMidi.AddTrack(); track1.Add(trackNameEvent1); track1.Add(noteEvent1); track1.Add(noteEvent1.OffEvent); track1.Add(endTrackEvent1); var noteEvent2 = new NoteOnEvent(0, 1, 1, 1, 1); const string trackName2 = "name"; var trackNameEvent2 = new TextEvent(trackName2, MetaEventType.SequenceTrackName, 0); var endTrackEvent2 = new MetaEvent(MetaEventType.EndTrack, 0, noteEvent2.OffEvent.AbsoluteTime); var track2 = manualMidi.AddTrack(); track2.Add(trackNameEvent2); track2.Add(noteEvent2); track2.Add(noteEvent2.OffEvent); track2.Add(endTrackEvent2); var clone = manualMidi.Clone(); MidiAssert.Equal(manualMidi, clone); for (var t = 0; t < manualMidi.Tracks; t++) { var manualTrack = manualMidi[t]; var extensionTrack = clone[t]; for (var e = 1; e < manualTrack.Count - 1; e++) { Assert.That(extensionTrack[e], Is.Not.SameAs(manualTrack[e])); } } }