Esempio n. 1
0
        public void Convert(SmfContainer input)
        {
            this.output = new List <SequenceItem>();
            this.info   = new SequenceInfo()
            {
                Resolution    = input.Resolution,
                EndOfTick     = input.MaxTick,
                LoopBeginTick = this.DetectLoopBegin(input)
            };

            this.ResetHandles();

            foreach (Event @event in input.Tracks.SelectMany(t => t.Events).OrderBy(e => e.Tick))
            {
                this.nowTick = @event.Tick;

                if (@event is MidiEvent)
                {
                    this.ConvertHandles((MidiEvent)@event);
                }
                else if (@event is MetaEvent)
                {
                    MetaEvent metaevent = (MetaEvent)@event;
                    if (metaevent.MetaType == MetaType.Tempo)
                    {
                        this.AddTempo(metaevent.GetTempo());
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// SMF データを格納したストリームを読み込み、シーケンスを開始します。
        /// </summary>
        /// <param name="stream">読み込まれるストリーム。</param>
        public void Load(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (!stream.CanRead)
            {
                throw new NotSupportedException();
            }

            SmfContainer    container = new SmfContainer(stream);
            HandleConverter hc        = new HandleConverter(this.preset);

            hc.Convert(container);

            if (this.sequencer != null)
            {
                this.sequencer.Stop();
            }

            this.sequencer = new Sequencer(hc.Output, hc.Info);
            this.sequencer.Start();
            this.sequencer.OnTrackEvent += this.OnTrackEvent;
        }
Esempio n. 3
0
        public void Convert(SmfContainer input)
        {
            this.output = new List<SequenceItem>();
            this.info = new SequenceInfo()
            {
                Resolution = input.Resolution,
                EndOfTick = input.MaxTick,
                LoopBeginTick = this.DetectLoopBegin(input)
            };

            this.ResetHandles();

            foreach (Event @event in input.Tracks.SelectMany(t => t.Events).OrderBy(e => e.Tick))
            {
                this.nowTick = @event.Tick;

                if (@event is MidiEvent)
                    this.ConvertHandles((MidiEvent)@event);
                else if (@event is MetaEvent)
                {
                    MetaEvent metaevent = (MetaEvent)@event;
                    if (metaevent.MetaType == MetaType.Tempo)
                        this.AddTempo(metaevent.GetTempo());
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// SMF データを格納したストリームを読み込み、シーケンスを開始します。
        /// </summary>
        /// <param name="stream">読み込まれるストリーム。</param>
        public void Load(Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            if (!stream.CanRead)
                throw new NotSupportedException();

            SmfContainer container = new SmfContainer(stream);
            HandleConverter hc = new HandleConverter(this.preset);
            hc.Convert(container);

            if (this.sequencer != null)
                this.sequencer.Stop();

            this.sequencer = new Sequencer(hc.Output, hc.Info);
            this.sequencer.Start();
            this.sequencer.OnTrackEvent += this.OnTrackEvent;
        }
Esempio n. 5
0
        private long DetectLoopBegin(SmfContainer input)
        {
            var k = input.Tracks.SelectMany(t => t.Events).OfType <MidiEvent>().Where(e => e.Type == EventType.ControlChange && e.Data1 == 111).LastOrDefault();

            return((k == null) ? 0 : k.Tick);
        }
Esempio n. 6
0
 private long DetectLoopBegin(SmfContainer input)
 {
     var k = input.Tracks.SelectMany(t => t.Events).OfType<MidiEvent>().Where(e => e.Type == EventType.ControlChange && e.Data1 == 111).LastOrDefault();
     return (k == null) ? 0 : k.Tick;
 }