Exemple #1
0
        public bool CheckBeat(Beat beat)
        {
            if (Voice == null)
            {
                Voice = beat.Voice;
            }
            // allow adding if there are no beats yet
            var add = false;

            if (Beats.Count == 0)
            {
                add = true;
            }
            else if (CanJoin(_lastBeat, beat))
            {
                add = true;
            }

            if (add)
            {
                _lastBeat = beat;
                Beats.Add(beat);
                CheckNote(beat.MinNote);
                CheckNote(beat.MaxNote);
                if (MaxDuration < beat.Duration)
                {
                    MaxDuration = beat.Duration;
                }
            }

            return(add);
        }
Exemple #2
0
 public void AddBeat(Beat beat)
 {
     // chaining
     beat.Voice = this;
     beat.Index = Beats.Count;
     Beats.Add(beat);
 }
        public bool CheckBeat(Beat beat)
        {
            if (Voice == null)
            {
                Voice = beat.Voice;
            }
            // allow adding if there are no beats yet
            var add = false;

            if (Beats.Count == 0)
            {
                add = true;
            }
            else if (CanJoin(_lastBeat, beat))
            {
                add = true;
            }

            if (add)
            {
                _lastBeat = beat;
                Beats.Add(beat);

                if (beat.HasTuplet)
                {
                    HasTuplet = true;
                }

                int fingeringCount = 0;
                for (var n = 0; n < beat.Notes.Count; n++)
                {
                    var note = beat.Notes[n];
                    if (note.LeftHandFinger != Fingers.Unknown || note.RightHandFinger != Fingers.Unknown)
                    {
                        fingeringCount++;
                    }
                }

                if (fingeringCount > FingeringCount)
                {
                    FingeringCount = fingeringCount;
                }

                CheckNote(beat.MinNote);
                CheckNote(beat.MaxNote);
                if (MaxDuration < beat.Duration)
                {
                    MaxDuration = beat.Duration;
                }

                if (beat.HasTuplet)
                {
                    HasTuplet = true;
                }
            }

            return(add);
        }
Exemple #4
0
 internal void AddBeat(Beat beat)
 {
     beat.Voice = this;
     beat.Index = Beats.Count;
     Beats.Add(beat);
     if (!beat.IsEmpty)
     {
         IsEmpty = false;
     }
 }
Exemple #5
0
 public void AddBeat(Beat beat)
 {
     // chaining
     beat.Voice = this;
     beat.Index = Beats.Count;
     Beats.Add(beat);
     if (!beat.IsEmpty)
     {
         IsEmpty = false;
     }
 }
Exemple #6
0
 public bool Check(Beat beat)
 {
     if (Beats.Count == 0)
     {
         Tuplet = beat.TupletNumerator;
     }
     else if (beat.Voice.Index != VoiceIndex || beat.TupletNumerator != Tuplet || IsFull || _isFinished)
     {
         return(false);
     }
     Beats.Add(beat);
     return(true);
 }
Exemple #7
0
        private void BeatBar_OnTimeMouseDown(object sender, TimeSpan e)
        {
            if ((Keyboard.Modifiers & ModifierKeys.Control) != 0)
            {
                RemoveClosestBeat(e);
            }
            else
            {
                Beats.Add(e);
                Beats.Sort();
            }

            BeatBar.InvalidateVisual();
        }
        /// <summary>
        /// Adds a beat at the current offset, and sets the offset to zero.
        /// Use the skip and rewind methods to modify the offset first,
        /// as beats cannot be added with an offset of zero.
        /// </summary>
        public BeatSequence AddBeat()
        {
            if (this.NextBeatOffset == 0)
            {
                throw new InvalidOperationException(
                          "Cannot add a beat without first skipping forward "
                          + "(" + nameof(NextBeatOffset) + " is zero). "
                          + "Please call one of the skip methods first."
                          );
            }

            return(new BeatSequence(
                       beats: Beats.Add(this.LastBeatTime + this.NextBeatOffset),
                       beatPositioner: this.BeatPositioner,
                       nextBeatOffset: 0
                       ));
        }
Exemple #9
0
        internal bool Check(Beat beat)
        {
            if (Beats.Count == 0)
            {
                // accept first beat
                Beats.Add(beat);
                _totalDuration += beat.PlaybackDuration;
                return(true);
            }

            if (beat.GraceType != GraceType.None)
            {
                // grace notes do not break tuplet group, but also do not contribute to them.
                return(true);
            }

            if (beat.Voice != Voice ||
                IsFull ||
                beat.TupletNumerator != Beats[0].TupletNumerator ||
                beat.TupletDenominator != Beats[0].TupletDenominator)
            {
                // only same tuplets are potentially accepted
                return(false);
            }

            // TBH: I do not really know how the 100% tuplet grouping of Guitar Pro might work
            // it sometimes has really strange rules where notes filling 3 quarters, are considered a full 3:2 tuplet

            // in alphaTab we have now 2 rules where we consider a tuplet full:
            // 1. if all beats have the same length, the tuplet must contain N notes of an N:M tuplet
            // 2. if we have mixed beats, we check if the current set of beats, matches a N:M tuplet
            //    by checking all potential note durations.

            // this logic is very likely not 100% correct but for most cases the tuplets
            // appeared correct.

            if (beat.PlaybackDuration != Beats[0].PlaybackDuration)
            {
                _isEqualLengthTuplet = false;
            }

            Beats.Add(beat);
            _totalDuration += beat.PlaybackDuration;

            if (_isEqualLengthTuplet)
            {
                if (Beats.Count == Beats[0].TupletNumerator)
                {
                    IsFull = true;
                }
            }
            else
            {
                var factor = Beats[0].TupletNumerator / Beats[0].TupletDenominator;
                foreach (var potentialMatch in AllTicks)
                {
                    if (_totalDuration == potentialMatch * factor)
                    {
                        IsFull = true;
                        break;
                    }
                }
            }

            return(true);
        }
Exemple #10
0
 public void AddBeat(SingleBeat beat)
 {
     Beats.Add(beat);
 }
Exemple #11
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     Beats.Add(videoPlayer.GetPosition());
     SetAllBeats(Beats);
 }
Exemple #12
0
 private void AddBeat(TimeSpan positionTotalSeconds)
 {
     Debug.WriteLine(positionTotalSeconds);
     Beats.Add(positionTotalSeconds);
     Beats.Sort();
 }
Exemple #13
0
 /// <summary>
 /// Adds a new <see cref="BeatTickLookup"/> to the list of played beats during this MasterBar period.
 /// </summary>
 /// <param name="beat"></param>
 public void AddBeat(BeatTickLookup beat)
 {
     Beats.Add(beat);
 }
Exemple #14
0
 public void AddBeat(Beat.Beat beat)
 {
     beat.Voice = this;
     Beats.Add(beat);
 }
Exemple #15
0
        public bool CheckBeat(Beat beat)
        {
            if (beat.InvertBeamDirection)
            {
                InvertBeamDirection = true;
            }

            if (Voice == null)
            {
                Voice = beat.Voice;
            }
            // allow adding if there are no beats yet
            var add = false;

            if (Beats.Count == 0)
            {
                add = true;
            }
            else if (CanJoin(Beats[Beats.Count - 1], beat))
            {
                add = true;
            }

            if (add)
            {
                Beats.Add(beat);
                if (beat.GraceType != GraceType.None)
                {
                    IsGrace = true;
                }

                var positions = GetOrCreateBeatPositions(beat);

                if (beat.HasTuplet)
                {
                    HasTuplet = true;
                }

                int fingeringCount = 0;
                for (var n = 0; n < beat.Notes.Count; n++)
                {
                    var note = beat.Notes[n];
                    if (note.LeftHandFinger != Fingers.Unknown || note.RightHandFinger != Fingers.Unknown)
                    {
                        fingeringCount++;
                    }
                }

                if (fingeringCount > FingeringCount)
                {
                    FingeringCount = fingeringCount;
                }

                LastMinNoteValue = int.MinValue;
                LastMaxNoteValue = int.MinValue;

                CheckNote(beat.MinNote);
                CheckNote(beat.MaxNote);

                positions.MinNoteValue = LastMinNoteValue;
                positions.MaxNoteValue = LastMaxNoteValue;

                if (ShortestDuration < beat.Duration)
                {
                    ShortestDuration = beat.Duration;
                }

                if (beat.HasTuplet)
                {
                    HasTuplet = true;
                }
            }

            return(add);
        }