Skip to content

Commit f5b6116

Browse files
committed
Only detect pre-armed loops; it's more predictable
1 parent 94fcb2b commit f5b6116

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

source/alo.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,9 @@ update_position(Alo* self, const LV2_Atom_Object* obj)
291291
self->button_state[i] = (*self->ports.loops[i]) > 0.0f ? true : false;
292292
self->state[i] = STATE_RECORDING;
293293
self->phrase_start[i] = 0;
294-
log("STATE: RECORDING (speed change) [%d]", i);
295294
}
296295
log("Speed change: %G", self->speed);
297-
log("Loop beats: %d", self->loop_beats);
296+
log("Loop: [%d][%d]", self->loop_beats, self->loop_samples);
298297
};
299298
}
300299
if (beat && beat->type == uris->atom_Float) {
@@ -372,35 +371,34 @@ run(LV2_Handle instance, uint32_t n_samples)
372371
// log("Sample: %.9f", sample);
373372
recording[self->loop_index] = sample;
374373
for (int i = 0; i < NUM_LOOPS; i++) {
374+
375375
if (self->phrase_start[i] && self->phrase_start[i] == self->loop_index) {
376376
if (self->button_state[i]) {
377377
self->state[i] = STATE_LOOP_ON;
378-
log("DECISION: LOOP ON [%d][%d]", i, self->loop_index);
378+
log("[%d]DECISION: LOOP ON [%d]", i, self->loop_index);
379379
} else {
380380
if (self->state[i] == STATE_RECORDING) {
381381
self->phrase_start[i] = 0;
382-
log("DECISION: Abandon phrase [%d][%d]", i, self->loop_index);
382+
log("[%d]DECISION: Abandon phrase [%d]", i, self->loop_index);
383383
} else {
384384
self->state[i] = STATE_LOOP_OFF;
385-
log("DECISION: LOOP OFF [%d][%d]", i, self->loop_index);
385+
log("[%d]DECISION: LOOP OFF [%d]", i, self->loop_index);
386386
}
387387
}
388388
}
389389

390390
float* const loop = self->loops[i];
391-
if (self->state[i] == STATE_RECORDING) {
391+
if (self->state[i] == STATE_RECORDING && self->button_state[i]) {
392392
loop[self->loop_index] = sample;
393393
if (self->phrase_start[i] == 0 && self->speed != 0) {
394394
if (fabs(sample) > self->threshold) {
395395
self->phrase_start[i] = self->loop_index;
396-
if (self->button_state[i]) {
397-
log(">>> DETECTED PHRASE START [%d][%d] <<<", i, self->loop_index);
398-
}
396+
log("[%d]>>> DETECTED PHRASE START [%d]<<<", i, self->loop_index);
399397
}
400398
}
401399
}
402400

403-
if (self-> state[i] == STATE_LOOP_ON && self->speed != 0) {
401+
if (self->state[i] == STATE_LOOP_ON && self->speed != 0) {
404402
output[pos] += loop[self->loop_index];
405403
}
406404
}

0 commit comments

Comments
 (0)