Skip to content

Commit

Permalink
fixing lua event function "play head" (#420)
Browse files Browse the repository at this point in the history
Co-authored-by: samba <samba@manjaro>
  • Loading branch information
SambaGodschynski and samba authored Apr 6, 2024
1 parent 7216f13 commit 67cc8ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rendertests/tests/293_lua_event_function.sheet
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
using "./293luaEventFunction.lua";
using "./293_lua_event_function.conductions";

device: MyDevice midi _useDevice="DIN 3";
device: MyDevice midi _useDevice="FLUID";
instrumentDef: piano _ch=0 _onDevice=MyDevice _pc=0;
instrumentDef: piano2 _ch=1 _onDevice=MyDevice _pc=0;
instrumentDef: piano3 _ch=2 _onDevice=MyDevice _pc=0;

[
instrument: piano;
{
/call: 293luaEventFunction/ | g a b c' |
/call: 293luaEventFunction _octave=1/ | g' a' b' c'' |
-- lua event functions does not consume any time, so we need to add an rest after the call to
-- set the "Play Head" on to the correct position
/call: 293luaEventFunction/ r1 | g4 a b c' |
/call: 293luaEventFunction _octave=1/ r1 | g'4 a' b' c'' |
}
]
3 changes: 3 additions & 0 deletions src/compiler/commands/ExecuteEventFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ namespace compiler
AModification::Events events;
theEventFunction->execute(context, events);
const auto &originEvent = event();
com::Ticks passedTicks = 0;
for(auto &event : events)
{
event.sourceId = originEvent.sourceId;
event.sourcePositionBegin = originEvent.sourcePositionBegin;
event.sourcePositionEnd = originEvent.sourcePositionEnd;
sheetEventRenderer_->addEvent(event);
passedTicks += event.duration;
}
context->seek(-passedTicks);
}

LuaEventFunctionPtr ExecuteEventFunction::loadEventFunction(IContextPtr ctx, const com::String& modName)
Expand Down

0 comments on commit 67cc8ee

Please sign in to comment.