Example #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);
        }
Example #2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            TimeSpan tBegin = _marker1 < _marker2 ? _marker1 : _marker2;
            TimeSpan tEnd   = _marker1 < _marker2 ? _marker2 : _marker1;

            SetAllBeats(Beats.Where(t => t <tBegin || t> tEnd));
        }
Example #3
0
 public void AddBeat(Beat beat)
 {
     // chaining
     beat.Voice = this;
     beat.Index = Beats.Count;
     Chain(beat);
     Beats.Add(beat);
 }
Example #4
0
 public void UpdateBPM()
 {
     BPM            = Table.BPM;
     Beats          = Table.BeatVal;
     BPMText.text   = BPM.ToString();
     BeatsText.text = Beats.ToString();
     BlockTime      = (60f * Beats) / BPM;
 }
Example #5
0
 private void Start()
 {
     IndexText.text = Index.ToString();
     BPMText.text   = BPM.ToString();
     BeatsText.text = Beats.ToString();
     BlockTime      = (60f * Beats) / BPM;
     UpdateDivLine();
 }
Example #6
0
 private void UpdateHeatMap()
 {
     if (rectHeat == null)
     {
         return;
     }
     rectHeat.Fill = HeatMapGenerator.Generate(Beats.ToList(), TimeSpan.Zero, Duration, 100, true);
 }
Example #7
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);

                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);
        }
Example #8
0
 internal void AddBeat(Beat beat)
 {
     beat.Voice = this;
     beat.Index = Beats.Count;
     Beats.Add(beat);
     if (!beat.IsEmpty)
     {
         IsEmpty = false;
     }
 }
Example #9
0
 /// <summary>
 /// Returns the hash code for this instance.
 /// </summary>
 /// <returns>A 32-bit signed integer hash code.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var result = 17;
         result = result * 23 + Bars.GetHashCode();
         result = result * 23 + Beats.GetHashCode();
         result = result * 23 + Ticks.GetHashCode();
         return(result);
     }
 }
Example #10
0
 public void AddBeat(Beat beat)
 {
     // chaining
     beat.Voice = this;
     beat.Index = Beats.Count;
     Beats.Add(beat);
     if (!beat.IsEmpty)
     {
         IsEmpty = false;
     }
 }
Example #11
0
 internal void InsertBeat(Beat after, Beat newBeat)
 {
     newBeat.NextBeat = after.NextBeat;
     if (newBeat.NextBeat != null)
     {
         newBeat.NextBeat.PreviousBeat = newBeat;
     }
     newBeat.PreviousBeat = after;
     newBeat.Voice        = this;
     after.NextBeat       = newBeat;
     Beats.InsertAt(after.Index + 1, newBeat);
 }
 public LogStashConnector()
 {
     if (MusketeerConfiguration.LogStashUrl != null)
     {
         beatsClient = new Beats(MusketeerConfiguration.LogStashUrl.Host, MusketeerConfiguration.LogStashUrl.Port,
                                 MusketeerConfiguration.LogStashUseSsl, MusketeerConfiguration.LogStashCertThumb);
     }
     else
     {
         beatsClient = null;
     }
 }
Example #13
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);
 }
Example #14
0
	/*
	string serialInput = "";
	SerialPort sp; // */

	// Use this for initialization
	public override void Start()
	{
		base.Start();
		SetMovementSpeed(1.0f);

		gameManager = GameObject.Find("GameManager"); 
		beatsScript = gameManager.GetComponent<Beats>();

		/*
		sp = new SerialPort("COM" + comPortNumber, baudRate);
		sp.Open();
		sp.ReadTimeout = 1; // */

	}
Example #15
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();
        }
Example #16
0
        private void mnuJumpToLastBeat_Click(object sender, RoutedEventArgs e)
        {
            if (Beats == null)
            {
                return;
            }
            if (Beats.Count == 0)
            {
                return;
            }
            TimeSpan beat = Beats.Last();

            videoPlayer.SetPosition(beat);
        }
Example #17
0
        private void mnuShift_Click(object sender, RoutedEventArgs e)
        {
            if (_originalBeats == null)
            {
                return;
            }
            double shift = GetDouble(0);

            if (double.IsNaN(shift))
            {
                return;
            }

            Beats = Beats.Shift(TimeSpan.FromSeconds(shift));
        }
Example #18
0
        private void mnuSave_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog
            {
                FileName = Path.GetFileNameWithoutExtension(_openFile)
            };

            dialog.Filter = "Text-File|*.txt";
            if (dialog.ShowDialog(this) != true)
            {
                return;
            }

            Beats.Save(dialog.FileName);
        }
Example #19
0
        private void btnLoadBeatsFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "Text Files|*.txt"
            };

            if (dialog.ShowDialog(this) != true)
            {
                return;
            }

            Beats    = BeatCollection.Load(dialog.FileName);
            Duration = Beats.Max();
            UpdateHeatMap();
        }
Example #20
0
        private void mnuScale_Click(object sender, RoutedEventArgs e)
        {
            if (_originalBeats == null)
            {
                return;
            }
            double scale = GetDouble(1);

            if (double.IsNaN(scale))
            {
                return;
            }

            Beats = Beats.Scale(scale);
        }
        /// <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
                       ));
        }
Example #22
0
        private void SaveProjectAs(string filename)
        {
            BeatProject project = new BeatProject
            {
                VideoFile       = _videoFile,
                SampleCondition = _condition,
                BeatBarDuration = BeatBar.TotalDisplayedDuration.TotalSeconds,
                BeatBarMidpoint = BeatBar.Midpoint,
                Beats           = Beats.Select(b => b.Ticks).ToList(),
                Bookmarks       = Bookmarks.Select(b => b.Ticks).ToList()
            };

            project.Save(filename);
            _projectFile = filename;

            SaveAsFunscript(Path.ChangeExtension(_videoFile, "funscript"));
            SaveAsBeatsFile(Path.ChangeExtension(_videoFile, "txt"));
        }
Example #23
0
        public void AddGraceBeat(Beat beat)
        {
            if (Beats.Count == 0)
            {
                AddBeat(beat);
                return;
            }

            // remove last beat
            var lastBeat = Beats[Beats.Count - 1];

            Beats.RemoveAt(Beats.Count - 1);

            // insert grace beat
            AddBeat(beat);
            // reinsert last beat
            AddBeat(lastBeat);
        }
Example #24
0
        internal void AddGraceBeat(Beat beat)
        {
            if (Beats.Count == 0)
            {
                AddBeat(beat);
                return;
            }

            // remove last beat
            var lastBeat = Beats[Beats.Count - 1];

            Beats.RemoveAt(Beats.Count - 1);

            // insert grace beat
            AddBeat(beat);
            // reinsert last beat
            AddBeat(lastBeat);

            IsEmpty = false;
        }
Example #25
0
        private void btnDetectAll_Click(object sender, RoutedEventArgs e)
        {
            List <bool[]> knownPatterns = new List <bool[]>
            {
                new bool[] { true, false, false, false, false, false, false, false },
                new bool[] { true, false, false, false, true, false, false, false },
                new bool[] { true, false, true, false, true, false, true, false },
                new bool[] { true, true, true, true, true, true, true, true },
                new bool[] { true, true, true, false, true, false, true, false },
                new bool[] { true, true, true, true, true, false, true, false },
                new bool[] { true, true, true, true, true, true, true, false },
                new bool[] { true, true, false, false, false, false, false, false }
            };

            List <TimeSpan> beats = Beats.ToList();
            int             index = 0;

            BeatSegment segment;

            do
            {
                segment = null;
                int shifts = 0;

                while (segment == null && shifts < 8)
                {
                    segment = FindSegment(knownPatterns, beats, ref index);
                    if (segment == null)
                    {
                        shifts++;
                        index++;
                    }
                }

                if (segment != null)
                {
                    Segments.Add(segment);
                }
            }while(segment != null);
        }
Example #26
0
        private void btnDetect_Click(object sender, RoutedEventArgs e)
        {
            BeatPatternEditor editor =
                new BeatPatternEditor(new bool[] { true, false, false, false, false, false, false, false, });

            if (editor.ShowDialog() != true)
            {
                return;
            }

            bool[] pattern = editor.Result;
            var    beats   = Beats.GetBeats(_begin, _end).ToList();

            BeatSegment segment = GetSegment(beats, pattern);

            if (segment == null)
            {
                return;
            }

            Segments.Add(segment);
        }
Example #27
0
        private void Normalize(int additionalBeats, bool trimToBeats = true)
        {
            TimeSpan tBegin = _marker1 < _marker2 ? _marker1 : _marker2;
            TimeSpan tEnd   = _marker1 < _marker2 ? _marker2 : _marker1;

            List <TimeSpan> beatsToEvenOut = Beats.GetBeats(tBegin, tEnd).ToList();

            List <TimeSpan> otherBeats = Beats.Where(t => t <tBegin || t> tEnd).ToList();

            if (beatsToEvenOut.Count < 2 && trimToBeats)
            {
                return;
            }

            TimeSpan first = trimToBeats ? beatsToEvenOut.Min() : tBegin;
            TimeSpan last  = trimToBeats ? beatsToEvenOut.Max() : tEnd;

            int numberOfBeats = (int)(beatsToEvenOut.Count + additionalBeats);

            if (numberOfBeats < 2)
            {
                numberOfBeats = 2;
            }

            TimeSpan tStart    = first;
            TimeSpan intervall = (last - first).Divide(numberOfBeats - 1);

            for (int i = 0; i < numberOfBeats; i++)
            {
                otherBeats.Add(tStart + intervall.Multiply(i));
            }

            Fadeout.SetText(intervall.TotalMilliseconds.ToString("f0") + "ms", TimeSpan.FromSeconds(4));

            SetAllBeats(otherBeats);
        }
Example #28
0
 // Use this for initialization
 void Start()
 {
     text  = gameObject.GetComponent <TextMeshPro>();
     beats = GameObject.FindGameObjectWithTag("AudioSource").GetComponent <Beats>();
 }
Example #29
0
 // Use this for initialization
 void Start()
 {
     players = GameObject.FindGameObjectsWithTag("Player");
     beats   = GameObject.FindGameObjectWithTag("AudioSource").GetComponent <Beats>();
     button.onClick.AddListener(buttonClick);
 }
Example #30
0
 // Use this for initialization
 void Start()
 {
     _light  = GetComponent <Light>();
     beats   = GameObject.FindGameObjectWithTag("AudioSource").GetComponent <Beats>();
     players = GameObject.FindGameObjectsWithTag("Player");
 }
Example #31
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);
        }