예제 #1
0
        public void GetTimedEventsAndNotes_SameNotesInTail()
        {
            var events = new MidiEvent[]
            {
                new NoteOnEvent((SevenBitNumber)1, (SevenBitNumber)100)
                {
                    DeltaTime = 10
                },
                new NoteOnEvent((SevenBitNumber)2, (SevenBitNumber)70)
                {
                    DeltaTime = 10
                },
                new NoteOffEvent((SevenBitNumber)2, (SevenBitNumber)1),
                new NoteOnEvent((SevenBitNumber)2, (SevenBitNumber)0),
                new NoteOffEvent((SevenBitNumber)2, (SevenBitNumber)0)
                {
                    DeltaTime = 10
                },
                new NoteOffEvent((SevenBitNumber)1, (SevenBitNumber)0)
                {
                    DeltaTime = 10
                }
            };

            var timedEvents   = new TrackChunk(events).GetTimedEvents().Concat(new[] { default(TimedEvent) });
            var actualObjects = timedEvents.GetTimedEventsAndNotes().ToList();

            var expectedObjects = new ITimedObject[]
            {
                new Note((SevenBitNumber)1, 30, 10)
                {
                    Velocity = (SevenBitNumber)100
                },
                new Note((SevenBitNumber)2, 0, 20)
                {
                    Velocity = (SevenBitNumber)70, OffVelocity = (SevenBitNumber)1
                },
                new Note((SevenBitNumber)2, 10, 20)
                {
                    Velocity = (SevenBitNumber)0
                },
                null
            };

            CollectionAssert.AreEqual(expectedObjects, actualObjects, new TimedObjectComparer());
        }
예제 #2
0
        public void GetTimedEventsAndNotes_AllProcessed()
        {
            var events = new MidiEvent[]
            {
                new SetTempoEvent(1234),
                new NoteOnEvent((SevenBitNumber)1, (SevenBitNumber)100)
                {
                    DeltaTime = 10, Channel = (FourBitNumber)1
                },
                new NoteOnEvent((SevenBitNumber)2, (SevenBitNumber)70)
                {
                    DeltaTime = 10, Channel = (FourBitNumber)1
                },
                new PitchBendEvent(123)
                {
                    DeltaTime = 10
                },
                new MarkerEvent("Marker")
                {
                    DeltaTime = 10
                },
                new NoteOnEvent((SevenBitNumber)3, (SevenBitNumber)1)
                {
                    Channel = (FourBitNumber)1
                },
                new MarkerEvent("Marker 2")
                {
                    DeltaTime = 10
                },
                new TextEvent("Text")
                {
                    DeltaTime = 10
                },
                new TextEvent("Text 2")
                {
                    DeltaTime = 10
                },
                new NoteOnEvent((SevenBitNumber)2, (SevenBitNumber)1)
                {
                    Channel = (FourBitNumber)10
                },
                new CuePointEvent("Point")
                {
                    DeltaTime = 10
                },
                new NoteOffEvent((SevenBitNumber)3, (SevenBitNumber)1)
                {
                    Channel = (FourBitNumber)1
                },
                new NoteOffEvent((SevenBitNumber)1, (SevenBitNumber)0)
                {
                    DeltaTime = 10, Channel = (FourBitNumber)1
                },
                new NoteOffEvent((SevenBitNumber)2, (SevenBitNumber)0)
                {
                    Channel = (FourBitNumber)10
                },
                new NoteOffEvent((SevenBitNumber)2, (SevenBitNumber)0)
                {
                    DeltaTime = 10, Channel = (FourBitNumber)1
                }
            };

            var timedEvents   = new TrackChunk(events).GetTimedEvents();
            var actualObjects = timedEvents.GetTimedEventsAndNotes().ToList();

            var expectedObjects = new ITimedObject[]
            {
                new TimedEvent(new SetTempoEvent(1234), 0),
                new Note((SevenBitNumber)1, 80, 10)
                {
                    Channel = (FourBitNumber)1, Velocity = (SevenBitNumber)100
                },
                new Note((SevenBitNumber)2, 80, 20)
                {
                    Channel = (FourBitNumber)1, Velocity = (SevenBitNumber)70
                },
                new TimedEvent(new PitchBendEvent(123), 30),
                new TimedEvent(new MarkerEvent("Marker"), 40),
                new Note((SevenBitNumber)3, 40, 40)
                {
                    Channel = (FourBitNumber)1, Velocity = (SevenBitNumber)1, OffVelocity = (SevenBitNumber)1
                },
                new TimedEvent(new MarkerEvent("Marker 2"), 50),
                new TimedEvent(new TextEvent("Text"), 60),
                new TimedEvent(new TextEvent("Text 2"), 70),
                new Note((SevenBitNumber)2, 20, 70)
                {
                    Channel = (FourBitNumber)10, Velocity = (SevenBitNumber)1
                },
                new TimedEvent(new CuePointEvent("Point"), 80)
            };

            CollectionAssert.AreEqual(expectedObjects, actualObjects, new TimedObjectComparer());
        }