2024-06-24 07:58:31 +00:00
|
|
|
#if defined(STFU_MAIN) && !defined(STFU_TIMER)
|
|
|
|
#define STFU_TIMER
|
|
|
|
|
2024-06-13 11:43:53 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
struct stfu_timer {
|
|
|
|
float v, a;
|
|
|
|
} stfu_init_timer() {
|
|
|
|
struct stfu_timer r;
|
|
|
|
r.v = 0;
|
|
|
|
r.a = (1.0f / STFU_AUDIO_FRAME_RATE);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
// todo: Pass period parameter?
|
|
|
|
struct stfu_timer stfu_pump_timer(struct stfu_timer wave) {
|
|
|
|
wave.v += wave.a;
|
|
|
|
if (wave.v > 1000)
|
|
|
|
wave.v -= 1000;
|
|
|
|
return wave;
|
|
|
|
}
|
2024-06-24 07:58:31 +00:00
|
|
|
|
|
|
|
#endif
|