player: return interpolated value as double
The heavy lifting was already done in double precision, so just return the full value to the user without truncating to float.
This commit is contained in:
parent
7c43db7385
commit
739fc21cfd
@ -35,7 +35,7 @@ void sync_set_io_cb(struct sync_device *d, struct sync_io_cb *cb);
|
||||
#endif /* defined(SYNC_PLAYER) */
|
||||
|
||||
const struct sync_track *sync_get_track(struct sync_device *, const char *);
|
||||
float sync_get_val(const struct sync_track *, double);
|
||||
double sync_get_val(const struct sync_track *, double);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
14
sync/track.c
14
sync/track.c
@ -13,27 +13,27 @@
|
||||
#include "track.h"
|
||||
#include "base.h"
|
||||
|
||||
static float key_linear(const struct track_key k[2], double row)
|
||||
static double key_linear(const struct track_key k[2], double row)
|
||||
{
|
||||
double t = (row - k[0].row) / (k[1].row - k[0].row);
|
||||
return (float)(k[0].value + (k[1].value - k[0].value) * t);
|
||||
return k[0].value + (k[1].value - k[0].value) * t;
|
||||
}
|
||||
|
||||
static float key_smooth(const struct track_key k[2], double row)
|
||||
static double key_smooth(const struct track_key k[2], double row)
|
||||
{
|
||||
double t = (row - k[0].row) / (k[1].row - k[0].row);
|
||||
t = t * t * (3 - 2 * t);
|
||||
return (float)(k[0].value + (k[1].value - k[0].value) * t);
|
||||
return k[0].value + (k[1].value - k[0].value) * t;
|
||||
}
|
||||
|
||||
static float key_ramp(const struct track_key k[2], double row)
|
||||
static double key_ramp(const struct track_key k[2], double row)
|
||||
{
|
||||
double t = (row - k[0].row) / (k[1].row - k[0].row);
|
||||
t = pow(t, 2.0);
|
||||
return (float)(k[0].value + (k[1].value - k[0].value) * t);
|
||||
return k[0].value + (k[1].value - k[0].value) * t;
|
||||
}
|
||||
|
||||
float sync_get_val(const struct sync_track *t, double row)
|
||||
double sync_get_val(const struct sync_track *t, double row)
|
||||
{
|
||||
int idx, irow;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user