MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
track.h
1#ifndef SYNC_TRACK_H
2#define SYNC_TRACK_H
3
4#ifdef __cplusplus
5 extern "C" {
6#endif
7
8#include <string.h>
9#include <stdlib.h>
10#include "base.h"
11
12enum key_type {
13 KEY_STEP, /* stay constant */
14 KEY_LINEAR, /* lerp to the next value */
15 KEY_SMOOTH, /* smooth curve to the next value */
16 KEY_RAMP,
17 KEY_TYPE_COUNT
18};
19
20struct track_key {
21 int row;
22 float value;
23 enum key_type type;
24};
25
26struct sync_track {
27 const char *name;
28 struct track_key *keys;
29 int num_keys;
30};
31
32// CPP write
33void start_save_sync ( const char* filename_h, const char* filename_cpp );
34void save_sync(const struct sync_track *t, const char *filename_h, const char* filename_cpp);
35void end_save_sync( const char* filename_h, const char* filename_cpp );
36
37// JSON write
38void start_save_sync_json ( const char* filename);
39void save_sync_json(const struct sync_track *t, const char *filename);
40void end_save_sync_json( const char* filename);
41
42int sync_find_key(const struct sync_track *, int);
43static inline int key_idx_floor(const struct sync_track *t, int row)
44{
45 int idx = sync_find_key(t, row);
46 if (idx < 0)
47 idx = -idx - 2;
48 return idx;
49}
50
51#ifndef SYNC_PLAYER
52int sync_set_key(struct sync_track *, const struct track_key *);
53int sync_del_key(struct sync_track *, int);
54static inline int is_key_frame(const struct sync_track *t, int row)
55{
56 return sync_find_key(t, row) >= 0;
57}
58
59#endif /* !defined(SYNC_PLAYER) */
60
61#ifdef __cplusplus
62 }
63#endif
64
65#endif /* SYNC_TRACK_H */
Definition track.h:26
Definition track.h:20