Skip to content

Commit

Permalink
allow a step to be triggered only every n'th time when a pattern loops
Browse files Browse the repository at this point in the history
  • Loading branch information
zueblin committed Apr 13, 2020
1 parent 0555fcc commit d1bbc35
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Software/Polaron/Sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void Sequencer::doStep() {
break;
}
}
if (!tracks[i].isMuted() && step.isTriggerOn()) {
if (!tracks[i].isMuted() && step.isTriggerOn() && step.isTriggerConditionOn()) {
ParameterSet & stepParams = step.params;
audioChannels[i]->setParam1(stepParams.parameter1);
audioChannels[i]->setParam2(stepParams.parameter2);
Expand Down
5 changes: 4 additions & 1 deletion Software/Polaron/SequencerPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SequencerPattern::SequencerPattern() : trackLength(NUMBER_OF_STEPS_PER_PATTERN)

void SequencerPattern::init(ParameterSet &defaultValues) {
for (int i = 0; i < NUMBER_OF_STEPS_PER_PATTERN; i++) {
steps[i].init(defaultValues,i, &triggerState, &pLockArmState);
steps[i].init(defaultValues,i, &triggerState, &pLockArmState, &loopCount);
}
}

Expand All @@ -36,6 +36,9 @@ SequencerStep & SequencerPattern::doStep() {
if (autoMutate){
triggerState ^= triggerState << 2;
}
if (++loopCount >= 4){
loopCount = 0;
}
}
return getCurrentStep();
}
Expand Down
4 changes: 4 additions & 0 deletions Software/Polaron/SequencerPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class SequencerPattern {
void setCurrentStepIndex(uint8_t index){
currentStep = index % NUMBER_OF_STEPS_PER_PATTERN;
}
void setLoopCount(uint8_t index){
loopCount = index;
}

void init(ParameterSet &defaultValues);
void copyValuesFrom(SequencerPattern sourcePattern);
Expand Down Expand Up @@ -71,6 +74,7 @@ class SequencerPattern {

private:
int8_t currentStep = 16;
uint8_t loopCount = 4;



Expand Down
18 changes: 13 additions & 5 deletions Software/Polaron/SequencerStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@

SequencerStep::SequencerStep() {}

void SequencerStep::init(ParameterSet &defaultValues, uint8_t stepIdx, uint16_t *trState, uint16_t *pLState) {
void SequencerStep::init(ParameterSet &defaultValues, uint8_t stepIdx, uint16_t *trState, uint16_t *pLState, uint8_t *loopCnt) {

params = defaultValues;
stepIndex = stepIdx;
triggerState = trState;
pLockArmState = pLState;
params = defaultValues;
loopCount = loopCnt;
triggerMask = 0b00001101;

}

void SequencerStep::toggleTriggerState() {
Expand All @@ -46,6 +49,10 @@ bool SequencerStep::isTriggerOn() {
return *triggerState & _BV(stepIndex);
}

bool SequencerStep::isTriggerConditionOn() {
return triggerMask & _BV(*loopCount%4);
}

void SequencerStep::toggleParameterLockRecord() {
// toggle the plock bit
*pLockArmState ^= _BV(stepIndex);
Expand Down Expand Up @@ -106,13 +113,14 @@ uint8_t SequencerStep::getState(){

CRGB SequencerStep::getColor() {
bool triggerOn = isTriggerOn();
bool triggerConditionOn = isTriggerConditionOn();
bool pLockOn = isParameterLockOn();

if (triggerOn && pLockOn){
return CRGB::DarkOrange;
return triggerConditionOn ? CRGB::DarkOrange : 0x692A04;
} else if (triggerOn){
return CRGB::CornflowerBlue;
}else {
return triggerConditionOn ? CRGB::CornflowerBlue: 0x21224F;
} else {
return CRGB::Black;
}
}
5 changes: 4 additions & 1 deletion Software/Polaron/SequencerStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SequencerStep {

void toggleTriggerState();
bool isTriggerOn();
bool isTriggerConditionOn();
void setTriggerOn();
void setTriggerOff();

Expand All @@ -41,7 +42,7 @@ class SequencerStep {
void setParameterLockRecordOff();
bool isParameterLockOn();
void copyValuesFrom(SequencerStep sourceStep);
void init(ParameterSet &defaultValues, uint8_t stepIdx, uint16_t *trState, uint16_t *pLState);
void init(ParameterSet &defaultValues, uint8_t stepIdx, uint16_t *trState, uint16_t *pLState, uint8_t *loopCnt);

//uint8_t getState();
CRGB getColor();
Expand All @@ -52,6 +53,8 @@ class SequencerStep {
uint8_t stepIndex;
uint16_t *triggerState;
uint16_t *pLockArmState;
uint8_t *loopCount;
uint8_t triggerMask;



Expand Down

0 comments on commit d1bbc35

Please sign in to comment.