mirror of
https://github.com/erik-toth/audio-synth.git
synced 2025-12-06 12:00:02 +00:00
Firmware MCU: Update sequencer block to support dynamic step count and enhance documentation
This commit is contained in:
@@ -235,12 +235,12 @@ uint8_t CV::_getKeyToVoltageIndex(Key k)
|
||||
|
||||
/*!
|
||||
* @param maxDurationMS maximum loop duration of recording in milliseconds
|
||||
* @param minStepDurationMS minimum duration for a step to be recorded (prevents ultra-short steps)
|
||||
* @param maxStepCount maximum number of steps that can be recorded
|
||||
*/
|
||||
SequencerBlock::SequencerBlock(uint16_t maxDurationMS, uint16_t minStepDurationMS)
|
||||
SequencerBlock::SequencerBlock(uint16_t maxDurationMS, uint16_t maxStepCount)
|
||||
{
|
||||
_maxDurationMS = maxDurationMS;
|
||||
_minStepDurationMS = minStepDurationMS;
|
||||
_maxStepCount = maxStepCount;
|
||||
_stepCount = 0;
|
||||
_currentStep = 0;
|
||||
_isRecording = false;
|
||||
@@ -386,7 +386,7 @@ void SequencerBlock::clear()
|
||||
_lastVoltageCh1 = 0;
|
||||
_lastVoltageCh2 = 0;
|
||||
|
||||
for(uint8_t i = 0; i < N_MAX_SEQUENCE_STEPS; i++)
|
||||
for(uint8_t i = 0; i < _MAX_SEQUENCE_STEPS; i++)
|
||||
{
|
||||
_sequence[i].voltage_ch1 = 0;
|
||||
_sequence[i].voltage_ch2 = 0;
|
||||
@@ -409,7 +409,12 @@ bool SequencerBlock::timeLimitReached()
|
||||
return (elapsed >= _maxDurationMS);
|
||||
}
|
||||
|
||||
uint8_t SequencerBlock::getStepCount()
|
||||
bool SequencerBlock::stepLimitReached()
|
||||
{
|
||||
return (_stepCount >= _maxStepCount);
|
||||
}
|
||||
|
||||
uint16_t SequencerBlock::getStepCount()
|
||||
{
|
||||
return _stepCount;
|
||||
}
|
||||
@@ -447,21 +452,13 @@ void SequencerBlock::_finishCurrentStep()
|
||||
unsigned long now = millis();
|
||||
uint16_t duration = now - _lastStepTime;
|
||||
|
||||
// Nur Steps mit ausreichender Dauer speichern
|
||||
if(duration >= _minStepDurationMS)
|
||||
{
|
||||
_sequence[_stepCount - 1].duration = duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Step war zu kurz, verwerfen
|
||||
_stepCount--;
|
||||
}
|
||||
_sequence[_stepCount - 1].duration = duration;
|
||||
}
|
||||
|
||||
bool SequencerBlock::_canAddStep()
|
||||
{
|
||||
if(_stepCount >= N_MAX_SEQUENCE_STEPS) return false;
|
||||
if(_stepCount >= _maxStepCount) return false;
|
||||
if(_stepCount >= _MAX_SEQUENCE_STEPS) return false;
|
||||
if(timeLimitReached()) return false;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user