예제 #1
0
 public BeatArgs(TickValue beatVal, double beatTime, double nextBeatTime, TickMask <bool> beatTickMask)
 {
     BeatVal      = beatVal;
     BeatTime     = beatTime;
     NextBeatTime = nextBeatTime;
     TickMask     = beatTickMask;
 }
예제 #2
0
 /// <summary>
 /// Creates a tick mask array based on the number of ticks per measure
 /// </summary>
 void BuildTickMaskArray()
 {
     _tickMaskArray = new TickMask <bool> [_ticksPerMeasure + 1];
     for (int i = 1; i <= _ticksPerMeasure; i++)
     {
         _tickMaskArray[i] = new TickMask <bool>();
         if (i % (int)TickValue.ThirtySecond == 0)
         {
             _tickMaskArray[i][TickValue.ThirtySecond] = true;
         }
         if (i % (int)TickValue.SixteenthTriplet == 0)
         {
             _tickMaskArray[i][TickValue.SixteenthTriplet] = true;
         }
         if (i % (int)TickValue.Sixteenth == 0)
         {
             _tickMaskArray[i][TickValue.Sixteenth] = true;
         }
         if (i % (int)TickValue.EighthTriplet == 0)
         {
             _tickMaskArray[i][TickValue.EighthTriplet] = true;
         }
         if (i % (int)TickValue.Eighth == 0)
         {
             _tickMaskArray[i][TickValue.Eighth] = true;
         }
         if (i % (int)TickValue.QuarterTriplet == 0)
         {
             _tickMaskArray[i][TickValue.QuarterTriplet] = true;
         }
         if (i % (int)TickValue.Quarter == 0)
         {
             _tickMaskArray[i][TickValue.Quarter] = true;
         }
         if (i % (int)TickValue.Half == 0)
         {
             _tickMaskArray[i][TickValue.Half] = true;
         }
         if (i % (int)TickValue.Measure == 0)
         {
             _tickMaskArray[i][TickValue.Measure] = true;
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Function to update beat counts, called after every new tick
 /// </summary>
 void UpdateTicks()
 {
     TickMask = _tickMaskArray[_tickCounter];
     if (TickMask[TickValue.ThirtySecond])
     {
         if (ThirtySecond != null)
         {
             ThirtySecond(new BeatArgs(TickValue.ThirtySecond, _nextThirtySecond,
                                       _nextThirtySecond + _thirtySecondLength, TickMask));
         }
         _nextThirtySecond += _thirtySecondLength;
         _thirtySecondCount++;
     }
     if (TickMask[TickValue.SixteenthTriplet])
     {
         _nextSixteenthTriplet += _sixteenthTripletLength;
     }
     if (TickMask[TickValue.Sixteenth])
     {
         if (Sixteenth != null)
         {
             Sixteenth(new BeatArgs(TickValue.Sixteenth, _nextSixteenth,
                                    _nextSixteenth + _sixteenthLength, TickMask));
         }
         _nextSixteenth += _sixteenthLength;
     }
     if (TickMask[TickValue.EighthTriplet])
     {
         _nextEighthTriplet += _eighthTripletLength;
     }
     if (TickMask[TickValue.Eighth])
     {
         if (Eighth != null)
         {
             Eighth(new BeatArgs(TickValue.Eighth, _nextEighth,
                                 _nextEighth + _eighthLength, TickMask));
         }
         _nextEighth += _eighthLength;
     }
     if (TickMask[TickValue.QuarterTriplet])
     {
         _nextQuarterTriplet += _quarterTripletLength;
     }
     if (TickMask[TickValue.Quarter])
     {
         if (Beat != null)
         {
             Beat(new BeatArgs(TickValue.Quarter, _nextQuarter,
                               _nextQuarter + _quarterLength, TickMask));
         }
         _nextQuarter += _quarterLength;
     }
     if (TickMask[TickValue.Half])
     {
         _nextHalf += _halfLength;
     }
     if (TickMask[TickValue.Measure])
     {
         if (Measure != null)
         {
             Measure(new BeatArgs(TickValue.Measure, _nextMeasure,
                                  _nextMeasure + _measureLength, TickMask));
         }
         _nextMeasure += _measureLength;
         //_thirtySecondCount = 0;
     }
 }