Ejemplo n.º 1
0
 public void AddMasterBar(MasterBarTickLookup masterBar)
 {
     MasterBars.Add(masterBar);
     _currentMasterBar = masterBar;
     if (!MasterBarLookup.ContainsKey(masterBar.MasterBar.Index))
     {
         MasterBarLookup[masterBar.MasterBar.Index] = masterBar;
     }
 }
Ejemplo n.º 2
0
 public void AddMasterBar(MasterBarTickLookup masterBar)
 {
     MasterBars.Add(masterBar);
     _currentMasterBar = masterBar;
     if (!MasterBarLookup.ContainsKey(masterBar.MasterBar.Index))
     {
         MasterBarLookup[masterBar.MasterBar.Index] = masterBar;
     }
 }
Ejemplo n.º 3
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;
                }
            }

            var masterBarLookup = new MasterBarTickLookup();
            masterBarLookup.MasterBar = masterBar;
            masterBarLookup.Start = currentTick;
            masterBarLookup.End = masterBarLookup.Start + masterBar.CalculateDuration();
            TickLookup.AddMasterBar(masterBarLookup);
        }