Beispiel #1
0
        // Update is called once per frame
        public virtual void Update()
        {
            if (currBpm != bpm || currNoteMode != noteMode)
            {
                currBpm               = bpm;
                currNoteMode          = noteMode;
                tickIntervalInSamples = 60.0f / bpm / (float)GetBeatDivision(noteMode);
            }

            if (running)
            {
                if (nextTick <= AudioSettings.dspTime)
                {
                    // Trigger note
                    HandleBeat();

                    nextTick += tickIntervalInSamples;

                    // add swing???
                    if (totalBeats % 2 == 1)
                    {
                        nextTick += swing * 0.9f * tickIntervalInSamples;                         // max at 90% between beats
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void StartSequencer()
        {
            currBpm      = bpm;
            currTimeSig  = timeSignature;
            currSwing    = swing;
            currNoteMode = noteMode;

            tickIntervalInSamples = 60.0f / bpm / (float)GetBeatDivision(noteMode);
            nextTick = AudioSettings.dspTime;
            running  = true;
        }
Beispiel #3
0
        private int GetBeatDivision(BeatDivision div)
        {
            switch (div)
            {
            case BeatDivision.EIGHT_NOTE:
                return(2);

            case BeatDivision.QUARTER_NOTE:
                return(1);

            case BeatDivision.SIXTEENTH_NOTE:
                return(4);

            case BeatDivision.TRIPLET:
                return(3);

            default:
                return(4);
            }
        }