mirror of
https://codeberg.org/armin/monostep.git
synced 2026-09-01 12:20:46 +02:00
MonoStep: monophonic 2-oscillator step-sequencer synth
This commit is contained in:
commit
e52e5cb161
14 changed files with 2674 additions and 0 deletions
56
Source/dsp/StepSequencer.h
Normal file
56
Source/dsp/StepSequencer.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
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<Step, numSteps> steps;
|
||||
};
|
||||
|
||||
} // namespace monostep
|
||||
Loading…
Add table
Add a link
Reference in a new issue