Commit 7ba93119 authored by Hanspeter Portner's avatar Hanspeter Portner

properly handle atom:beatTime in sequence iterator.

parent ff868db9
......@@ -799,6 +799,9 @@ moony_init(moony_t *moony, const char *subject, double sample_rate,
moony->uris.units_unit = moony->map->map(moony->map->handle, LV2_UNITS__unit);
moony->uris.atom_frame_time = moony->map->map(moony->map->handle, LV2_ATOM__frameTime);
moony->uris.atom_beat_time = moony->map->map(moony->map->handle, LV2_ATOM__beatTime);
osc_forge_init(&moony->oforge, moony->map);
lv2_atom_forge_init(&moony->forge, moony->map);
lv2_atom_forge_init(&moony->state_forge, moony->map);
......@@ -988,6 +991,8 @@ moony_open(moony_t *moony, lua_State *L, bool use_assert)
SET_MAP(L, LV2_ATOM__, URI);
SET_MAP(L, LV2_ATOM__, URID);
SET_MAP(L, LV2_ATOM__, Vector);
SET_MAP(L, LV2_ATOM__, beatTime);
SET_MAP(L, LV2_ATOM__, frameTime);
}
lua_setglobal(L, "Atom");
......
......@@ -624,12 +624,16 @@ _latom_seq__tostring(lua_State *L, latom_t *latom)
int
_latom_seq_foreach_itr(lua_State *L)
{
moony_t *moony = lua_touserdata(L, lua_upvalueindex(1));
latom_t *latom = lua_touserdata(L, 1);
if(!lv2_atom_sequence_is_end(latom->body.seq, latom->atom->size, latom->iter.seq.ev))
{
// push frame time
lua_pushinteger(L, latom->iter.seq.ev->time.frames);
if(latom->body.seq->unit == moony->uris.atom_beat_time)
lua_pushnumber(L, latom->iter.seq.ev->time.beats);
else
lua_pushinteger(L, latom->iter.seq.ev->time.frames);
// push atom
lua_pushvalue(L, lua_upvalueindex(2));
latom_t *litem = lua_touserdata(L, lua_upvalueindex(2));
......
......@@ -792,7 +792,7 @@ _lforge_sequence(lua_State *L)
{
moony_t *moony = lua_touserdata(L, lua_upvalueindex(1));
lforge_t *lforge = luaL_checkudata(L, 1, "lforge");
LV2_URID unit = luaL_optinteger(L, 2, 0); //TODO use proper unit
LV2_URID unit = luaL_optinteger(L, 2, 0);
lforge_t *lframe = moony_newuserdata(L, moony, MOONY_UDATA_FORGE, lforge->lheader.cache);
lframe->depth = 1;
lframe->last.frames = 0;
......
......@@ -231,6 +231,9 @@ struct _moony_t {
LV2_URID core_scale_point;
LV2_URID units_unit;
LV2_URID atom_beat_time;
LV2_URID atom_frame_time;
} uris;
struct {
......
......@@ -991,11 +991,11 @@ do
local function producer(forge)
forge:frame_time(0)
local subseq = forge:sequence()
local subseq = forge:sequence(Atom.beatTime)
assert(subseq ~= forge)
subseq:frame_time(1):int(1)
subseq:frame_time(2):int(2)
subseq:time(1.1):int(1)
subseq:beat_time(2.2):int(1)
assert(subseq:pop() == nil)
......@@ -1009,8 +1009,9 @@ do
assert(#subseq == 2)
for frames, atom in subseq:foreach() do
assert(not math.tointeger(frames)) -- beatTime is double
assert(atom.type == Atom.Int)
assert(atom.value == frames)
assert(atom.value == 1)
end
subseq = seq[2]
......
......@@ -191,6 +191,8 @@ checkKw(char*s)
CHECK(Atom.URI, NUMBER);
CHECK(Atom.URID, NUMBER);
CHECK(Atom.Vector, NUMBER);
CHECK(Atom.frameTime, NUMBER);
CHECK(Atom.beatTime, NUMBER);
break;
case 'b':
CHECK(break, BREAK);
......
......@@ -51,7 +51,7 @@ var LuaHighlightRules = function() {
// Lua math
"huge|maxinteger|mininteger|pi|"+
// moony Atom
"Bool|Chunk|Double|Float|Int|Long|Literal|Object|Path|Property|Sequence|String|Tuple|URI|URID|Vector|"+
"Bool|Chunk|Double|Float|Int|Long|Literal|Object|Path|Property|Sequence|String|Tuple|URI|URID|Vector|frameTime|beatTime|"+
// moony MIDI
"MidiEvent|"+
"NoteOff|NoteOn|NotePressure|Controller|ProgramChange|ChannelPressure|Bender|SystemExclusive|QuarterFrame|SongPosition|SongSelect|TuneRequest|Clock|Start|Continue|Stop|ActiveSense|Reset|"+
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment