tone-generator/scheduler.hpp

30 lines
400 B
C++
Raw Permalink Normal View History

2024-08-19 22:43:24 +10:00
#pragma once
2024-09-27 22:46:51 +10:00
#include "timing.hpp"
2024-08-19 22:43:24 +10:00
namespace scheduler {
2024-09-27 22:46:51 +10:00
enum State {
play,
skip,
pause,
end,
};
2024-08-19 22:43:24 +10:00
inline uint32_t timestamp = 0;
2024-09-27 22:46:51 +10:00
inline State state = State::pause;
2024-08-19 22:43:24 +10:00
void reset();
2024-08-25 16:53:23 +10:00
void do_all();
2024-09-27 22:46:51 +10:00
inline bool is_running() {
return state <= State::skip;
}
inline bool should_update() {
return (state == State::play && timing::at >= timestamp) || state == State::skip;
}
2024-08-19 22:43:24 +10:00
};