From 739fc21cfd9f762bd2de6aaa080c09d50bc8b594 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 10 Aug 2012 15:04:59 +0200 Subject: [PATCH] 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. --- sync/sync.h | 2 +- sync/track.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sync/sync.h b/sync/sync.h index 790e967..70987ef 100644 --- a/sync/sync.h +++ b/sync/sync.h @@ -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 } diff --git a/sync/track.c b/sync/track.c index fccc3e7..05f4793 100644 --- a/sync/track.c +++ b/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;