aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2017-05-15 23:42:10 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2017-05-15 23:42:10 +0200
commita066876f32cd3eb16177a39a7e6f0449f5da840d (patch)
tree95721a8a8672b8daad05d0c8d38fd5b1a7404872
parent87ceeb7619ea9353f08edb0278c67d497e4f33e0 (diff)
downloadmoony.lv2-a066876f32cd3eb16177a39a7e6f0449f5da840d.zip
moony.lv2-a066876f32cd3eb16177a39a7e6f0449f5da840d.tar.gz
moony.lv2-a066876f32cd3eb16177a39a7e6f0449f5da840d.tar.bz2
moony.lv2-a066876f32cd3eb16177a39a7e6f0449f5da840d.tar.xz
api: fix timeresponder:stash.
* take account for multiplier when stashing. * leads to bug when multipliers before/after stash do not match
-rw-r--r--VERSION2
-rw-r--r--api/api_time.c13
2 files changed, 11 insertions, 4 deletions
diff --git a/VERSION b/VERSION
index f3e1870..df116b4 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.21.389
+0.21.391
diff --git a/api/api_time.c b/api/api_time.c
index e178a08..dcc70e2 100644
--- a/api/api_time.c
+++ b/api/api_time.c
@@ -135,21 +135,23 @@ _ltimeresponder_stash(lua_State *L)
timely_t *timely = lua_touserdata(L, 1);
lforge_t *lforge = luaL_checkudata(L, 2, "lforge");
+ const float multiplier_1 = 1.f / timely->multiplier;
+
// serialize full time state to stash
LV2_Atom_Forge_Frame frame;
if( !lv2_atom_forge_object(lforge->forge, &frame, 0, timely->urid.time_position)
|| !lv2_atom_forge_key(lforge->forge, timely->urid.time_barBeat)
- || !lv2_atom_forge_float(lforge->forge, TIMELY_BAR_BEAT(timely))
+ || !lv2_atom_forge_float(lforge->forge, TIMELY_BAR_BEAT(timely) * multiplier_1)
|| !lv2_atom_forge_key(lforge->forge, timely->urid.time_bar)
|| !lv2_atom_forge_long(lforge->forge, TIMELY_BAR(timely))
|| !lv2_atom_forge_key(lforge->forge, timely->urid.time_beatUnit)
- || !lv2_atom_forge_int(lforge->forge, TIMELY_BEAT_UNIT(timely))
+ || !lv2_atom_forge_int(lforge->forge, TIMELY_BEAT_UNIT(timely) * multiplier_1)
|| !lv2_atom_forge_key(lforge->forge, timely->urid.time_beatsPerBar)
- || !lv2_atom_forge_float(lforge->forge, TIMELY_BEATS_PER_BAR(timely))
+ || !lv2_atom_forge_float(lforge->forge, TIMELY_BEATS_PER_BAR(timely) * multiplier_1)
|| !lv2_atom_forge_key(lforge->forge, timely->urid.time_beatsPerMinute)
|| !lv2_atom_forge_float(lforge->forge, TIMELY_BEATS_PER_MINUTE(timely))
@@ -259,6 +261,8 @@ _ltimeresponder__newindex(lua_State *L)
if(!strcmp(lua_tostring(L, 2), "multiplier"))
{
const float multiplier = luaL_checknumber(L, 3);
+ if(multiplier <= 0.f)
+ luaL_error(L, "multiplier not > 0.0");
timely_set_multiplier(timely, multiplier);
}
}
@@ -295,6 +299,9 @@ _ltimeresponder(lua_State *L)
const float multiplier = luaL_optnumber(L, 2, 1.f);
lua_pop(L, 1); // multiplier
+ if(multiplier <= 0.f)
+ luaL_error(L, "multiplier not > 0.0");
+
// TODO do we want to cache/reuse this, too?
timely_t *timely = lua_newuserdata(L, sizeof(timely_t)); // userdata
timely_init(timely, moony->map, moony->sample_rate, mask,