Skip to content

Commit 9c1d093

Browse files
committed
Remove debug code and clean some if conditions up a bit
1 parent 49141f1 commit 9c1d093

2 files changed

Lines changed: 16 additions & 81 deletions

File tree

software/src/applets/ProbabilityDivider.h

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ProbabilityDivider : public HemisphereApplet {
4646
loop_index = 0;
4747
loop_step = 0;
4848
skip_steps = 0;
49+
bypass_loop = false;
4950
ForEachChannel(ch) {
5051
GateOut(ch, false);
5152
}
@@ -63,7 +64,7 @@ class ProbabilityDivider : public HemisphereApplet {
6364
// TODO: regenerate if changing from 0?
6465
}
6566

66-
loop_linker.SetLooping(loop_length_mod > 0);
67+
loop_linker.SetLooping(loop_length_mod > 0 && !bypass_loop);
6768

6869
// reset
6970
if (Clock(1)) {
@@ -87,6 +88,12 @@ class ProbabilityDivider : public HemisphereApplet {
8788
reseed_high = false;
8889
}
8990

91+
if (reseed < -(HEMISPHERE_MAX_CV >> 1)) {
92+
bypass_loop = true;
93+
} else {
94+
bypass_loop = false;
95+
}
96+
9097
// reset loop
9198
if (loop_length_mod > 0 && loop_step >= loop_length_mod) {
9299
loop_step = 0;
@@ -107,10 +114,12 @@ class ProbabilityDivider : public HemisphereApplet {
107114
return;
108115
}
109116

110-
// get next weighted div or next div from loop
117+
// always advance the loop if looping is active
111118
if (loop_length_mod > 0) {
112119
skip_steps = GetNextLoopDiv();
113-
} else {
120+
}
121+
// get a random div if loop is not active or if loop is in bypass, this might replace the value above
122+
if (loop_length_mod == 0 || bypass_loop) {
114123
skip_steps = GetNextWeightedDiv();
115124
}
116125

@@ -136,19 +145,11 @@ class ProbabilityDivider : public HemisphereApplet {
136145
}
137146

138147
void View() {
139-
if (showDebug) {
140-
DrawDebug();
141-
} else {
142-
DrawInterface();
143-
}
148+
DrawInterface();
144149
}
145150

146151
// void OnButtonPress() { }
147152

148-
void AuxButton() {
149-
showDebug = !showDebug;
150-
}
151-
152153
void OnEncoderMove(int direction) {
153154
if (!EditMode()) {
154155
MoveCursor(cursor, direction, LAST_SETTING);
@@ -230,8 +231,7 @@ class ProbabilityDivider : public HemisphereApplet {
230231
int loop_step;
231232
// used to keep track of reseed cv inputs so it only reseeds on rising edge
232233
bool reseed_high;
233-
234-
bool showDebug = false;
234+
bool bypass_loop;
235235

236236
int skip_steps;
237237
int pulse_animation = 0;
@@ -275,29 +275,6 @@ class ProbabilityDivider : public HemisphereApplet {
275275
}
276276
}
277277

278-
void DrawDebug() {
279-
int disp_seed = loop_linker.GetSeed(); //0xABCD // test display accuracy
280-
char sz[2];
281-
sz[1] = 0; // Null terminated string for easy print
282-
gfxPos(1, 15);
283-
for (int i = 3; i >= 0; --i) {
284-
// Grab each nibble in turn, starting with most significant
285-
int nib = (disp_seed >> (i * 4)) & 0xF;
286-
if (nib <= 9) {
287-
gfxPrint(nib);
288-
} else {
289-
sz[0] = 'a' + nib - 10;
290-
gfxPrint(static_cast<const char *>(sz));
291-
}
292-
}
293-
for (int i = 0; i < 16; i++) {
294-
int xOffset = (i % 4) * 12;
295-
int yOffset = (i / 4) * 10;
296-
gfxPrint(1 + xOffset, 25 + yOffset, loop[i]);
297-
gfxPrint(",");
298-
}
299-
}
300-
301278
int GetNextWeightedDiv() {
302279
int total_weights = 0;
303280

software/src/applets/ProbabilityMelody.h

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,12 @@ class ProbabilityMelody : public HemisphereApplet {
136136
}
137137

138138
void View() {
139-
if (showDebug) {
140-
DrawDebug();
141-
} else {
142-
DrawParams();
143-
DrawKeyboard();
144-
}
145-
139+
DrawParams();
140+
DrawKeyboard();
146141
}
147142

148143
// void OnButtonPress() { }
149144

150-
void AuxButton() {
151-
showDebug = !showDebug;
152-
}
153-
154145
void OnEncoderMove(int direction) {
155146
if (!EditMode()) {
156147
MoveCursor(cursor, direction, CV_MODE);
@@ -233,8 +224,6 @@ class ProbabilityMelody : public HemisphereApplet {
233224
int8_t cv_mode = 0;
234225
bool regen = false;
235226

236-
bool showDebug = false;
237-
238227
ProbLoopLinker &loop_linker = ProbLoopLinker::get();
239228

240229
int value_animation = 0;
@@ -464,37 +453,6 @@ class ProbabilityMelody : public HemisphereApplet {
464453
}
465454
}
466455

467-
void DrawDebug() {
468-
int full_seed = 0;
469-
for (int p = 0; p < 12; p++) {
470-
full_seed ^= (weights[p] < 0 ? 0 : weights[p]) << p;
471-
}
472-
full_seed ^= ((up_mod << 6) | down_mod);
473-
full_seed |= (loop_linker.GetSeed() << 16);
474-
char sz2[2];
475-
sz2[1] = 0; // Null terminated string for easy print
476-
gfxPos(1, 15);
477-
for (int i = 7; i >= 0; --i) {
478-
// Grab each nibble in turn, starting with most significant
479-
int nib2 = (full_seed >> (i * 4)) & 0xF;
480-
if (nib2 <= 9) {
481-
gfxPrint(nib2);
482-
} else {
483-
sz2[0] = 'a' + nib2 - 10;
484-
gfxPrint(static_cast<const char *>(sz2));
485-
}
486-
}
487-
// gfxPrint(1,35,down);
488-
// gfxPrint(20,35,up);
489-
490-
for (int i = 0; i < 16; i++) {
491-
int xOffset = (i % 4) * 16;
492-
int yOffset = (i / 4) * 10;
493-
gfxPrint(1 + xOffset, 25 + yOffset, seqloop[0][i]);
494-
gfxPrint(",");
495-
}
496-
}
497-
498456
void gfxPrintOctDotSemi(int x, int y, int semitone) {
499457
gfxPrint(x, y, ((semitone - 1) / 12) + 1);
500458
gfxPrint(x + 5, y, ".");

0 commit comments

Comments
 (0)