Add jump function to loop
This commit is contained in:
parent
2686fb98d1
commit
ed6f3e1de2
2 changed files with 542 additions and 519 deletions
|
@ -56,6 +56,7 @@ unsigned i;
|
|||
void sequencer_main_loop(void)
|
||||
{
|
||||
unsigned i;
|
||||
line_time_t new_cursor;
|
||||
|
||||
// Restart main loop timer
|
||||
timer0_write(ESP.getCycleCount() + TIMESTEPS);
|
||||
|
@ -66,14 +67,24 @@ unsigned i;
|
|||
switch(lines[i].next_event->type) {
|
||||
case EVENT_NOTEON:
|
||||
digitalWrite(LINE_PIN_MAP[i], 1);
|
||||
++lines[i].next_event;
|
||||
break;
|
||||
case EVENT_NOTEOFF:
|
||||
digitalWrite(LINE_PIN_MAP[i], 0);
|
||||
++lines[i].next_event;
|
||||
break;
|
||||
case EVENT_JUMP:
|
||||
new_cursor = lines[i].cursor = lines[i].next_event->new_cursor;
|
||||
for(list<event_t>::iterator it = lines[i].events.begin(); it != lines[i].events.end(); ++it) {
|
||||
if(it->time >= new_cursor) {
|
||||
lines[i].next_event = it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Todo: tone, jump, barrier, envelope
|
||||
}
|
||||
|
||||
++lines[i].next_event;
|
||||
// Todo: tone, barrier, envelope
|
||||
}
|
||||
}
|
||||
|
||||
if(lines[i].next_event != lines[i].events.end())
|
||||
|
@ -101,7 +112,9 @@ const char *p;
|
|||
JsonArray &model_lines = model["lines"];
|
||||
unsigned millis_per_slot = model["millis_per_slot"];
|
||||
|
||||
//
|
||||
// Critical section
|
||||
noInterrupts();
|
||||
|
||||
for(lineno = 0; lineno < LINES_NUM; ++lineno) {
|
||||
lines[lineno].cursor = 0;
|
||||
lines[lineno].events.clear();
|
||||
|
@ -119,10 +132,17 @@ const char *p;
|
|||
lines[lineno].events.push_back(event);
|
||||
}
|
||||
}
|
||||
event.type = EVENT_JUMP;
|
||||
event.time = t * millis_per_slot;
|
||||
event.new_cursor = 0;
|
||||
lines[lineno].events.push_back(event);
|
||||
|
||||
}
|
||||
|
||||
for(lineno = 0; lineno < LINES_NUM; ++lineno)
|
||||
lines[lineno].next_event = lines[lineno].events.begin();
|
||||
|
||||
interrupts();
|
||||
}
|
||||
|
||||
void setup()
|
||||
|
|
1033
gadgety_static.cpp
1033
gadgety_static.cpp
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue