示例#1
0
        private void GenerateMasterBar(MasterBar masterBar, MasterBar previousMasterBar, int currentTick)
        {
            // time signature
            if (previousMasterBar == null ||
                previousMasterBar.TimeSignatureDenominator != masterBar.TimeSignatureDenominator ||
                previousMasterBar.TimeSignatureNumerator != masterBar.TimeSignatureNumerator)
            {
                _handler.AddTimeSignature(currentTick, masterBar.TimeSignatureNumerator, masterBar.TimeSignatureDenominator);
            }

            // tempo
            if (previousMasterBar == null)
            {
                _handler.AddTempo(currentTick, masterBar.Score.Tempo);
                _currentTempo = masterBar.Score.Tempo;
            }
            else if (masterBar.TempoAutomation != null)
            {
                _handler.AddTempo(currentTick, (int)masterBar.TempoAutomation.Value);
                _currentTempo = (int)(masterBar.TempoAutomation.Value);
            }

            // metronome
            if (GenerateMetronome)
            {
                var start  = currentTick;
                var length = MidiUtils.ValueToTicks(masterBar.TimeSignatureDenominator);
                for (int i = 0; i < masterBar.TimeSignatureNumerator; i++)
                {
                    _handler.AddMetronome(start, length);
                    start += length;
                }
            }
        }
        private void GenerateMasterBar(MasterBar masterBar, MasterBar previousMasterBar, int currentTick)
        {
            // time signature
            if (previousMasterBar == null ||
                previousMasterBar.TimeSignatureDenominator != masterBar.TimeSignatureDenominator ||
                previousMasterBar.TimeSignatureNumerator != masterBar.TimeSignatureNumerator)
            {
                _handler.AddTimeSignature(currentTick, masterBar.TimeSignatureNumerator, masterBar.TimeSignatureDenominator);
            }

            // tempo
            if (previousMasterBar == null)
            {
                _handler.AddTempo(currentTick, masterBar.Score.Tempo);
                _currentTempo = masterBar.Score.Tempo;
            }
            else if (masterBar.TempoAutomation != null)
            {
                _handler.AddTempo(currentTick, (int)masterBar.TempoAutomation.Value);
                _currentTempo = (int)(masterBar.TempoAutomation.Value);
            }

            var masterBarLookup = new MasterBarTickLookup();

            masterBarLookup.MasterBar = masterBar;
            masterBarLookup.Start     = currentTick;
            masterBarLookup.Tempo     = _currentTempo;
            masterBarLookup.End       = masterBarLookup.Start + masterBar.CalculateDuration();
            TickLookup.AddMasterBar(masterBarLookup);
        }