Пример #1
0
        public void Generate()
        {
            // initialize tracks
            for (int i = 0, j = _score.Tracks.Count; i < j; i++)
            {
                GenerateTrack(_score.Tracks[i]);
            }

            var controller = new MidiPlaybackController(_score);
            MasterBar previousMasterBar = null; // store the previous played bar for repeats
            while (!controller.Finished)
            {
                var index = controller.Index;
                var bar = _score.MasterBars[index];
                var currentTick = controller.CurrentTick;
                controller.ProcessCurrent();
                if (controller.ShouldPlay)
                {
                    GenerateMasterBar(bar, previousMasterBar, currentTick);
                    for (int i = 0, j = _score.Tracks.Count; i < j; i++)
                    {
                        GenerateBar(_score.Tracks[i].Bars[index], currentTick);
                    }
                }
                controller.MoveNext();
                previousMasterBar = bar;
            }
        }
Пример #2
0
        public void Generate()
        {
            // initialize tracks
            for (int i = 0, j = _score.Tracks.Count; i < j; i++)
            {
                GenerateTrack(_score.Tracks[i]);
            }

            var       controller        = new MidiPlaybackController(_score);
            MasterBar previousMasterBar = null; // store the previous played bar for repeats

            while (!controller.Finished)
            {
                var index       = controller.Index;
                var bar         = _score.MasterBars[index];
                var currentTick = controller.CurrentTick;
                controller.ProcessCurrent();
                if (controller.ShouldPlay)
                {
                    GenerateMasterBar(bar, previousMasterBar, currentTick);
                    for (int i = 0, j = _score.Tracks.Count; i < j; i++)
                    {
                        GenerateBar(_score.Tracks[i].Bars[index], currentTick);
                    }
                }
                controller.MoveNext();
                previousMasterBar = bar;
            }
        }
Пример #3
0
        /// <inheritdoc />
        public void Generate()
        {
            // initialize tracks
            for (int i = 0, j = _score.Tracks.Count; i < j; i++)
            {
                GenerateTrack(_score.Tracks[i]);
            }

            Logger.Info("Midi", "Begin midi generation");
            var       controller        = new MidiPlaybackController(_score);
            MasterBar previousMasterBar = null; // store the previous played bar for repeats

            while (!controller.Finished)
            {
                var index       = controller.Index;
                var bar         = _score.MasterBars[index];
                var currentTick = controller.CurrentTick;
                controller.ProcessCurrent();
                if (controller.ShouldPlay)
                {
                    GenerateMasterBar(bar, previousMasterBar, currentTick);
                    for (int i = 0, j = _score.Tracks.Count; i < j; i++)
                    {
                        var track = _score.Tracks[i];
                        for (int k = 0, l = track.Staves.Count; k < l; k++)
                        {
                            var staff = track.Staves[k];
                            if (index < staff.Bars.Count)
                            {
                                GenerateBar(staff.Bars[index], currentTick);
                            }
                        }
                    }
                }
                controller.MoveNext();
                previousMasterBar = bar;
            }

            for (int i = 0, j = _score.Tracks.Count; i < j; i++)
            {
                _handler.FinishTrack(_score.Tracks[i].Index, controller.CurrentTick);
            }

            TickLookup.Finish();
            Logger.Info("Midi", "Midi generation done");
        }
        private void TestRepeat(Score score, int[] expectedIndexes)
        {
            var controller = new MidiPlaybackController(score);
            int i = 0;
            while (!controller.Finished)
            {
                var index = controller.Index;
                controller.ProcessCurrent();
                if (controller.ShouldPlay)
                {
                    Trace.WriteLine(string.Format("Checking index {0}, expected[{1}]", i, expectedIndexes[i]));
                    Assert.AreEqual(expectedIndexes[i], index);
                    i++;
                }
                controller.MoveNext();
            }

            Assert.AreEqual(expectedIndexes.Length, i);
            Assert.IsTrue(controller.Finished);
        }
Пример #5
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;
        }
Пример #6
0
        public void Generate()
        {
            // initialize tracks
            for (int i = 0, j = _score.Tracks.Count; i < j; i++)
            {
                GenerateTrack(_score.Tracks[i]);
            }

            var controller = new MidiPlaybackController(_score);
            MasterBar previousMasterBar = null; // store the previous played bar for repeats
            while (!controller.Finished)
            {
                var index = controller.Index;
                var bar = _score.MasterBars[index];
                var currentTick = controller.CurrentTick;
                controller.ProcessCurrent();
                if (controller.ShouldPlay)
                {
                    GenerateMasterBar(bar, previousMasterBar, currentTick);
                    for (int i = 0, j = _score.Tracks.Count; i < j; i++)
                    {
                        var track = _score.Tracks[i];
                        for (int k = 0, l = track.Staves.Count; k < l; k++)
                        {
                            var staff = track.Staves[k];
                            if (index < staff.Bars.Count)
                            {
                                GenerateBar(staff.Bars[index], currentTick);
                            }
                        }
                    }
                }
                controller.MoveNext();
                previousMasterBar = bar;
            }

            for (int i = 0, j = _score.Tracks.Count; i < j; i++)
            {
                _handler.FinishTrack(_score.Tracks[i].Index, controller.CurrentTick);
            }

            TickLookup.Finish();
        }
Пример #7
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;
        }