Пример #1
0
 private float RandomDelay()
 {
     return(MathfExtended.RoundToMultiple(
                Random.Range(
                    Mathf.Max(0f, delayBeats - delayRandomRange),
                    delayBeats + delayRandomRange),
                0.125f));
 }
Пример #2
0
    public IEnumerator WaitForBeatValue(Metronome metro, float beat)
    {
        float totalBeats = metro.currentTiming.totalBeats;
        float start      = totalBeats % beat;

        // if things seem out of time:
        //while (metro.currentTiming.totalBeats % beat >= start) {
        while (metro.currentTiming.totalBeats % beat > start)
        {
            yield return(null);
        }

        if (doNotOverlap)
        {
            // This ensures that we don't overlap another clip if the two were triggered close together
            float snap = MathfExtended.RoundToMultiple(metro.currentTiming.totalBeats, beat);
            while (beatWithClips.Contains(snap))
            {
                snap = MathfExtended.RoundToMultiple(metro.currentTiming.totalBeats, beat);
                yield return(null);
            }
            beatWithClips.Add(snap);
        }
    }