Пример #1
0
 public MidiFileGenerator(Score score, IMidiFileHandler handler, bool generateMetronome = false)
 {
     _score = score;
     _currentTempo = _score.Tempo;
     _handler = handler;
     GenerateMetronome = generateMetronome;
     TickLookup = new MidiTickLookup();
 }
Пример #2
0
        public static MidiTickLookup BuildTickLookup(Score score)
        {
            var lookup = new MidiTickLookup();

            var controller = new MidiPlaybackController(score);
            while (!controller.Finished)
            {
                var index = controller.Index;
                controller.Process();

                if (controller.ShouldPlay)
                {
                    var bar = new BarTickLookup();
                    bar.Bar = score.MasterBars[index];
                    bar.Start = controller.RepeatMove + bar.Bar.Start;
                    bar.End = bar.Start + bar.Bar.CalculateDuration();
                    lookup.Bars.Add(bar);
                }
            }

            return lookup;
        }
Пример #3
0
        public static MidiTickLookup BuildTickLookup(Score score)
        {
            var lookup = new MidiTickLookup();

            var controller = new MidiPlaybackController(score);
            while (!controller.Finished)
            {
                var index = controller.Index;
                var currentTick = controller.CurrentTick;
                controller.ProcessCurrent();
                if (controller.ShouldPlay)
                {
                    var bar = new BarTickLookup();
                    bar.Bar = score.MasterBars[index];
                    bar.Start = currentTick;
                    bar.End = bar.Start + bar.Bar.CalculateDuration();
                    lookup.AddBar(bar);
                }
                controller.MoveNext();
            }

            return lookup;
        }