protected void Beat() // Sequences beats in the propper order and triggers their events. Invoked by OnEnable() { lastBeat = Time.time; if (showTiming) { Debug.Log(lastMainIndex + "-" + lastOffIndex + ":\n" + System.DateTime.Now.Second + "." + System.DateTime.Now.Millisecond); } if (visualizeBeat && beatGraphic) { if (beatGraphic.localScale == Vector3.one) { beatGraphic.localScale *= 2; } else { beatGraphic.localScale = Vector3.one; // Displays the beat on-screen directly } } if (++lastOffIndex > offBeats) // Next Main Beat { lastOffIndex = 0; if (++lastMainIndex > beats) // Next Bar { lastMainIndex = 0; NewBar?.Invoke(); } OnBeat?.Invoke(); if (lastMainIndex == beats) { OnBeatLast?.Invoke(); } } else // Next Off Beat { OffBeat?.Invoke(); if (lastOffIndex == offBeats /* && lastMainIndex == beats*/) { OffBeatLast?.Invoke(); } } }
private void OnNewBar(string symbol, string datafeed) => NewBar?.Invoke(this, new Tuple <string, string>(symbol, datafeed));