Esempio n. 1
0
        public IEnumerable <int> ReaderIterator(int startPosition, ChannelChaser chaser, MessageDispatcher dispatcher)
        {
            if (startPosition < 0)
            {
                throw new ArgumentOutOfRangeException("startPosition", startPosition, "Start position out of range.");
            }
            IEnumerator <MidiEvent> enumerator = this.Iterator().GetEnumerator();
            bool notFinished = enumerator.MoveNext();
            int  ticks       = 0;

            while (notFinished)
            {
                IMidiMessage message = enumerator.Current.MidiMessage;
                if (message.MessageType == MessageType.Channel)
                {
                    chaser.Process((ChannelMessage)message);
                }
                else if (message.MessageType == MessageType.Meta)
                {
                    dispatcher.Dispatch(message);
                }
                ticks++;
                notFinished = enumerator.MoveNext();
            }
            chaser.Chase();
            yield return(ticks);
        }
Esempio n. 2
0
        public IEnumerable <int> TickIterator(int startPosition,
                                              ChannelChaser chaser, MessageDispatcher dispatcher)
        {
            #region Require

            if (startPosition < 0)
            {
                throw new ArgumentOutOfRangeException("startPosition", startPosition,
                                                      "Start position out of range.");
            }

            #endregion

            IEnumerator <MidiEvent> enumerator = Iterator().GetEnumerator();

            bool         notFinished = enumerator.MoveNext();
            IMidiMessage message;

            while (notFinished && enumerator.Current.AbsoluteTicks < startPosition)
            {
                message = enumerator.Current.MidiMessage;

                if (message.MessageType == MessageType.Channel)
                {
                    chaser.Process((ChannelMessage)message);
                }
                else if (message.MessageType == MessageType.Meta)
                {
                    dispatcher.Dispatch(message);
                }

                notFinished = enumerator.MoveNext();
            }

            chaser.Chase();

            int ticks = startPosition;

            while (notFinished)
            {
                while (ticks < enumerator.Current.AbsoluteTicks)
                {
                    yield return(ticks);

                    ticks++;
                }

                yield return(ticks);

                while (notFinished && enumerator.Current.AbsoluteTicks == ticks)
                {
                    dispatcher.Dispatch(enumerator.Current.MidiMessage);

                    notFinished = enumerator.MoveNext();
                }

                ticks++;
            }
        }
Esempio n. 3
0
        public IEnumerable <int> TickIterator(int startPosition,
                                              ChannelChaser chaser, MessageDispatcher dispatcher)
        {
            var enumerator = Iterator().GetEnumerator();

            bool notFinished = enumerator.MoveNext();

            while (notFinished && enumerator.Current.AbsoluteTicks < startPosition)
            {
                var cur = enumerator.Current;

                if (cur.MessageType == MessageType.Channel)
                {
                    chaser.Process((ChannelMessage)cur.Clone());
                }
                else if (cur.MessageType == MessageType.Meta)
                {
                    dispatcher.Dispatch(cur.Clone());
                }

                notFinished = enumerator.MoveNext();
            }

            chaser.Chase();

            int ticks = startPosition;

            while (notFinished)
            {
                while (ticks < enumerator.Current.AbsoluteTicks)
                {
                    yield return(ticks);

                    ticks++;
                }

                yield return(ticks);

                while (notFinished && enumerator.Current.AbsoluteTicks == ticks)
                {
                    dispatcher.Dispatch(enumerator.Current.Clone());

                    notFinished = enumerator.MoveNext();
                }

                ticks++;
            }
        }
        public IEnumerable<int> TickIterator(int startPosition,
            ChannelChaser chaser, MessageDispatcher dispatcher)
        {
            var enumerator = Iterator().GetEnumerator();

            bool notFinished = enumerator.MoveNext();

            while (notFinished && enumerator.Current.AbsoluteTicks < startPosition)
            {
                var cur = enumerator.Current;

                if (cur.MessageType == MessageType.Channel)
                {
                    chaser.Process((ChannelMessage)cur.Clone());
                }
                else if (cur.MessageType == MessageType.Meta)
                {
                    dispatcher.Dispatch(cur.Clone());
                }

                notFinished = enumerator.MoveNext();
            }

            chaser.Chase();

            int ticks = startPosition;

            while (notFinished)
            {
                while (ticks < enumerator.Current.AbsoluteTicks)
                {
                    yield return ticks;

                    ticks++;
                }

                yield return ticks;

                while (notFinished && enumerator.Current.AbsoluteTicks == ticks)
                {
                    dispatcher.Dispatch(enumerator.Current.Clone());

                    notFinished = enumerator.MoveNext();
                }

                ticks++;
            }
        }
Esempio n. 5
0
        public IEnumerable<int> TickIterator(int startPosition, 
            ChannelChaser chaser, MessageDispatcher dispatcher)
        {
            #region Require

            if(startPosition < 0)
            {
                throw new ArgumentOutOfRangeException("startPosition", startPosition,
                    "Start position out of range.");
            }

            #endregion

            IEnumerator<MidiEvent> enumerator = Iterator().GetEnumerator();

            bool notFinished = enumerator.MoveNext();
            IMidiMessage message;

            while(notFinished && enumerator.Current.AbsoluteTicks < startPosition)
            {
                message = enumerator.Current.MidiMessage;

                if(message.MessageType == MessageType.Channel)
                {
                    chaser.Process((ChannelMessage)message);
                }
                else if(message.MessageType == MessageType.Meta)
                {
                    dispatcher.Dispatch(message);
                }

                notFinished = enumerator.MoveNext();
            }

            chaser.Chase();

            int ticks = startPosition;

            while(notFinished)
            {
                while(ticks < enumerator.Current.AbsoluteTicks)
                {
                    yield return ticks;

                    ticks++;
                }

                yield return ticks;

                while(notFinished && enumerator.Current.AbsoluteTicks == ticks)
                {
                    dispatcher.Dispatch(enumerator.Current.MidiMessage);

                    notFinished = enumerator.MoveNext();    
                }

                ticks++;
            }
        }