summaryrefslogtreecommitdiffstats
path: root/src/track.h
diff options
context:
space:
mode:
authorOlivia Mackintosh <livvy@base.nu>2020-04-21 18:33:32 +0100
committerOlivia Mackintosh <livvy@base.nu>2020-04-21 18:33:32 +0100
commitddd234ea1ff2924e587372aa12c4d5cda99a0ce0 (patch)
treef5c6f28a18b726d04fcbb351341df4fb05714385 /src/track.h
downloadtiny-ddd234ea1ff2924e587372aa12c4d5cda99a0ce0.tar.gz
Initial commit
Diffstat (limited to 'src/track.h')
-rw-r--r--src/track.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/track.h b/src/track.h
new file mode 100644
index 0000000..fd59ded
--- /dev/null
+++ b/src/track.h
@@ -0,0 +1,47 @@
+#ifndef SYNC_TRACK_H
+#define SYNC_TRACK_H
+
+#include <string.h>
+#include <stdlib.h>
+#include "base.h"
+
+enum key_type {
+ KEY_STEP, /* stay constant */
+ KEY_LINEAR, /* lerp to the next value */
+ KEY_SMOOTH, /* smooth curve to the next value */
+ KEY_RAMP,
+ KEY_TYPE_COUNT
+};
+
+struct track_key {
+ int row;
+ float value;
+ enum key_type type;
+};
+
+struct sync_track {
+ char *name;
+ struct track_key *keys;
+ int num_keys;
+};
+
+int sync_find_key(const struct sync_track *, int);
+static inline int key_idx_floor(const struct sync_track *t, int row)
+{
+ int idx = sync_find_key(t, row);
+ if (idx < 0)
+ idx = -idx - 2;
+ return idx;
+}
+
+#ifndef SYNC_PLAYER
+int sync_set_key(struct sync_track *, const struct track_key *);
+int sync_del_key(struct sync_track *, int);
+static inline int is_key_frame(const struct sync_track *t, int row)
+{
+ return sync_find_key(t, row) >= 0;
+}
+
+#endif /* !defined(SYNC_PLAYER) */
+
+#endif /* SYNC_TRACK_H */