private void Update() { if (Time.time >= NextBeat) { Beat?.Invoke(); } }
void Update() { if (_audioSoruce.isPlaying && _song.CheckBeat()) { _beatNumber++; Beat?.Invoke(_beatNumber); } }
IEnumerator beat() { yield return(new WaitForSecondsRealtime(delay)); while (true) { yield return(new WaitForSecondsRealtime(beatTime)); Beat?.Invoke(); } }
IEnumerator Counter() { var i = 1; ElapsedTime = 0; var iniTime = 0f; while (true) { if (!_canPlay) { i = 0; TotalBeats = 0; ElapsedTime = 0; yield return(null); iniTime = Time.time; continue; } var lastTime = ElapsedTime; _t = 0f; while (_t <= 60f / Bpm) { yield return(null); var delta = ElapsedTime - lastTime; lastTime = ElapsedTime; _t += delta; } TotalBeats++; //ElapsedTime = TotalBeats * (60f / Bpm); Beat?.Invoke(i); foreach (var action in _routineBeat) { StartCoroutine(action(i)); } i = (i + 1) % Tempo; } }
private void Update() { if (ended) { if (!audioSource.isPlaying) { audioSource.Stop(); SceneManager.LoadScene("Menu"); } } else { if (started) { elapsedTime = audioSource.time + extraTime; elapsedNormalTime = (float)normalSecondsBetweenBeats * beatCounter; elapsedFastTime = (float)fastSecondsBetweenBeats * fastBeatCounter; CheckRange(); if (elapsedTime >= elapsedNormalTime + elapsedFastTime - 0.3d + 0.04d && elapsedTime < elapsedNormalTime + elapsedFastTime + 0.04d) { currentlyInBeat = true; postBeatInvoked = false; if (earlyBeat != null) { earlyBeat.Invoke(); } } else if (elapsedTime >= elapsedNormalTime + elapsedFastTime + 0.04d /*&& elapsedTime <= elapsedNormalTime + elapsedFastTime + 0.05d + 0.033d*/) { BeatCount(); BeatAnim(); Instantiate(beatTick, GameObject.Find("BeatCounter").transform).GetComponent <BeatTick>().direction = 1; Transform leftBeatTick = Instantiate(beatTick, GameObject.Find("BeatCounter").transform).transform; leftBeatTick.GetComponent <BeatTick>().direction = -1; leftBeatTick.position = new Vector2(Screen.width, leftBeatTick.position.y); if (beat != null) { beat.Invoke(); } } else if (elapsedTime > normalSecondsBetweenBeats * (beatCounter - 1) + fastSecondsBetweenBeats * (fastBeatCounter - 1) + 0.04d && elapsedTime <= normalSecondsBetweenBeats * (beatCounter - 1) + fastSecondsBetweenBeats * (fastBeatCounter - 1) + 0.3d + 0.04d) { if (lateBeat != null) { lateBeat.Invoke(); } } else { if (!postBeatInvoked) { postBeatInvoked = true; postBeat.Invoke(); PostBeat(); } } } } }
private void Tick(object state) => Beat?.Invoke(this, new HeartbeatEventArgs(BeatCycleTimeMillis, ++CurrentBeat));
protected virtual void OnBeat(MetronomeEventArgs e) { //Console.WriteLine(currentBar + "/" + currentBeat); label_beat.Text = (e.BeatNumber + 1).ToString() + "/" + numericUpDown_metronomeMeasuse.Value.ToString(); Beat?.Invoke(this, e); }
protected virtual void OnBeat() { Beat?.Invoke(this, EventArgs.Empty); }
protected virtual void OnBeat(SongSynchronizer sender) { Beat?.Invoke(sender, EventArgs.Empty); }