Exemple #1
0
    /// <summary>
    /// Responds to tick events from the ticker.
    /// </summary>
    /// <param name="tickTime">Tick time.</param>
    /// <param name="midiNoteNumber">Midi note number.</param>
    public void HandleTicked(double tickTime, int midiNoteNumber, float volume)
    {
        int numSteps = _steps.Count;

        // if there are no steps, don't do anything
        if (numSteps == 0)
        {
            return;
        }

        Step step = _steps[_currentTick];

        // if the current step is active, send a tick through
        if (step.Active && !suspended)
        {
            if (_keyController != null)
            {
                midiNoteNumber = _keyController.GetMIDINote(step.ScaleTone,
                                                            step.Octave);
            }
            DoTick(tickTime, midiNoteNumber, step.Volume);
        }

        // increment and wrap the tick counter
        _currentTick = (_currentTick + 1) % numSteps;
    }