41 namespace Parameters {
75 _rawFreq(Parameters::FREQ.defaultValue),
77 _rawDepth(Parameters::DEPTH.defaultValue),
135 _patterns[patternIndex].steps.emplace_back();
144 if (pattern.
steps.size() > 1) {
145 pattern.
steps.pop_back();
159 return static_cast<int>(
_patterns[patternIndex].steps.size());
166 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
173 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
176 _patterns[patternIndex].steps[stepIndex].shape = shape;
180 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
183 _patterns[patternIndex].steps[stepIndex].reverse = reverse;
187 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
194 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
201 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
204 return _patterns[patternIndex].steps[stepIndex].value;
208 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
212 return _patterns[patternIndex].steps[stepIndex].shape;
216 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
219 return _patterns[patternIndex].steps[stepIndex].reverse;
223 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
226 return _patterns[patternIndex].steps[stepIndex].repeat;
230 if (patternIndex >=
_patterns.size() || stepIndex >=
static_cast<int>(
_patterns[patternIndex].steps.size())) {
233 return _patterns[patternIndex].steps[stepIndex].lengthMultiplier;
327 const int numSteps =
static_cast<int>(pattern.
steps.size());
331 double totalCycleSamples = 0;
332 for (
int i = 0; i < numSteps; i++) {
333 totalCycleSamples += baseDuration * pattern.
steps[i].lengthMultiplier;
337 const double positionInSamples = std::fmod(timeInSeconds *
_sampleRate, totalCycleSamples);
340 double accumulated = 0;
341 for (
int i = 0; i < numSteps; i++) {
342 const double stepDuration = baseDuration * pattern.
steps[i].lengthMultiplier;
344 if (accumulated + stepDuration > positionInSamples) {
350 accumulated += stepDuration;
387 const int numSteps =
static_cast<int>(pattern.
steps.size());
406 const double repetitionDuration = currentStepDuration / step.
repeat;
407 const double t = std::fmod(
_samplePosition, repetitionDuration) / repetitionDuration;
410 const double tShaped = step.
reverse ? 1.0 - t : t;
426 if (existingSource.source == source) {
437 if ((*it).source == source) {
456 if (existingSource.source == source) {
467 if ((*it).source == source) {
void setTempoSyncSwitch(bool val)
double _modulatedFreqValue
std::vector< ModulationSourceWrapper< double > > getFreqModulationSources() const
int getNumSteps(int patternIndex) const
void setTempoNumer(int val)
bool getStepReverse(int patternIndex, int stepIndex) const
void setDepth(double val)
int getNumPatterns() const
StepShape getStepShape(int patternIndex, int stepIndex) const
bool _needsSeekOffsetCalc
std::vector< Pattern > _patterns
void setStepShape(int patternIndex, int stepIndex, StepShape shape)
bool addFreqModulationSource(std::shared_ptr< ModulationSource > source)
double _getNextOutputImpl(double inSample) override
bool removeDepthModulationSource(std::shared_ptr< ModulationSource > source)
double _calcShapedValue(double t, StepShape shape) const
double _calcBaseStepDuration() const
void setStepValue(int patternIndex, int stepIndex, double value)
double getStepLengthMultiplier(int patternIndex, int stepIndex) const
double getModulatedFreqValue() const
void setStepRepeat(int patternIndex, int stepIndex, int repeat)
int getCurrentStep() const
void prepareForNextBuffer(double bpm, double timeInSeconds)
int getTempoNumer() const
void addStep(int patternIndex)
double _modulatedDepthValue
bool addDepthModulationSource(std::shared_ptr< ModulationSource > source)
virtual ~StepSequencer() override=default
double getModulatedDepthValue() const
StepSequencer(const StepSequencer &other)
void setDepthModulationSources(std::vector< ModulationSourceWrapper< double > > sources)
bool setFreqModulationAmount(size_t index, double amount)
void removeStep(int patternIndex)
int getTempoDenom() const
StepSequencer * clone() const
void setTempoDenom(int val)
const Pattern & getPattern(int patternIndex) const
double getStepValue(int patternIndex, int stepIndex) const
void setStepLengthMultiplier(int patternIndex, int stepIndex, double lengthMultiplier)
std::vector< ModulationSourceWrapper< double > > _freqModulationSources
int getStepRepeat(int patternIndex, int stepIndex) const
std::vector< ModulationSourceWrapper< double > > _depthModulationSources
std::vector< ModulationSourceWrapper< double > > getDepthModulationSources() const
void _calcPhaseOffset(double timeInSeconds)
StepSequencer operator=(StepSequencer &other)=delete
bool setDepthModulationAmount(size_t index, double amount)
void setStepReverse(int patternIndex, int stepIndex, bool reverse)
void setSampleRate(double val)
bool getTempoSyncSwitch() const
void setFreqModulationSources(std::vector< ModulationSourceWrapper< double > > sources)
bool removeFreqModulationSource(std::shared_ptr< ModulationSource > source)
void _resetImpl() override
const ParameterDefinition::RangedParameter< double > FREQ(0.05, 20, 2)
const ParameterDefinition::RangedParameter< int > TEMPONUMER(1, 32, 1)
const ParameterDefinition::RangedParameter< double > STEP_VALUE(0, 1, 0)
constexpr bool TEMPOSYNC_OFF
constexpr bool TEMPOSYNC_ON
const ParameterDefinition::RangedParameter< int > STEP_REPEAT(1, 8, 1)
const ParameterDefinition::RangedParameter< double > STEP_LENGTH_MULTIPLIER(0.25, 4.0, 1.0)
const ParameterDefinition::RangedParameter< int > TEMPODENOM(1, 32, 1)
constexpr bool TEMPOSYNC_DEFAULT
const ParameterDefinition::RangedParameter< double > DEPTH(0, 1, 0.5)
static constexpr int DEFAULT_NUM_STEPS
SampleType calcModValue(const std::vector< ModulationSourceWrapper< SampleType > > &sources)
Pattern(int numSteps=DEFAULT_NUM_STEPS)
std::vector< Step > steps