#pragma once #include #include namespace monostep { static constexpr int numSteps = 16; static constexpr int minSemitone = -12; static constexpr int maxSemitone = 12; static constexpr int numRows = maxSemitone - minSemitone + 1; struct Step { bool gate = false; int semitone = 0; // -12 .. +12 float cents = 0.0f; // -50 .. +50 bool slide = false; }; class StepSequencer { public: Step& step (int i) { return steps[i]; } const Step& step (int i) const { return steps[i]; } void clear() { for (auto& s : steps) s = Step{}; } int stepsPerBeatFromRate (int rateIndex) const { // 0: 1/4, 1: 1/8, 2: 1/8T, 3: 1/16, 4: 1/32 switch (rateIndex) { case 0: return 1; case 1: return 2; case 2: return 3; case 4: return 8; default: return 4; } } float stepLenPpq (int rateIndex) const { return 1.0f / (float) stepsPerBeatFromRate (rateIndex); } private: std::array steps; }; } // namespace monostep