Commit a4823084 authored by Hanspeter Portner's avatar Hanspeter Portner

move <control> and <notify> arguments to after <n>.

parent 34cac999
Pipeline #4405658 passed with stages
in 16 minutes and 56 seconds
......@@ -980,7 +980,7 @@ moony_init(moony_t *moony, const char *subject, double sample_rate,
{
strcpy(moony->chunk,
"-- host does not support state:loadDefaultState feature\n\n"
"function run(n, ...)\n"
"function run(n, control, notify, ...)\n"
"end");
}
if(!moony->voice_map)
......
......@@ -103,29 +103,29 @@ _run_period(lua_State *L, const char *cmd, Handle *handle, uint32_t nsamples,
{
lua_pushinteger(L, nsamples);
// push sequence / forge pair(s)
for(unsigned i=0; i<handle->max_val; i++)
// push control / notify pair
{
latom_t *latom = moony_newuserdata(L, &handle->moony, MOONY_UDATA_ATOM, true);
latom->atom = (const LV2_Atom *)event_in[i];
latom->atom = (const LV2_Atom *)control;
latom->body.raw = LV2_ATOM_BODY_CONST(latom->atom);
lforge_t *lforge = moony_newuserdata(L, &handle->moony, MOONY_UDATA_FORGE, true);
lforge->depth = 0;
lforge->last.frames = 0;
lforge->forge = &handle->forge[i];
lforge->forge = &handle->moony.notify_forge;
}
// push control / notify pair
// push sequence / forge pair(s)
for(unsigned i=0; i<handle->max_val; i++)
{
latom_t *latom = moony_newuserdata(L, &handle->moony, MOONY_UDATA_ATOM, true);
latom->atom = (const LV2_Atom *)control;
latom->atom = (const LV2_Atom *)event_in[i];
latom->body.raw = LV2_ATOM_BODY_CONST(latom->atom);
lforge_t *lforge = moony_newuserdata(L, &handle->moony, MOONY_UDATA_FORGE, true);
lforge->depth = 0;
lforge->last.frames = 0;
lforge->forge = &handle->moony.notify_forge;
lforge->forge = &handle->forge[i];
}
lua_call(L, 1 + 2*handle->max_val + 2, 0);
......
......@@ -109,34 +109,34 @@ _run_period(lua_State *L, const char *cmd, Handle *handle, uint32_t nsamples,
{
lua_pushinteger(L, nsamples);
// push sequence / forge pair
// push control / notify pair
{
latom_t *latom = moony_newuserdata(L, &handle->moony, MOONY_UDATA_ATOM, true);
latom->atom = (const LV2_Atom *)event_in;
latom->atom = (const LV2_Atom *)control;
latom->body.raw = LV2_ATOM_BODY_CONST(latom->atom);
lforge_t *lforge = moony_newuserdata(L, &handle->moony, MOONY_UDATA_FORGE, true);
lforge->depth = 0;
lforge->last.frames = 0;
lforge->forge = &handle->forge;
lforge->forge = &handle->moony.notify_forge;
}
// push values
for(unsigned i=0; i<handle->max_val; i++)
lua_pushnumber(L, *handle->val_in[i]);
// push control / notify pair
// push sequence / forge pair
{
latom_t *latom = moony_newuserdata(L, &handle->moony, MOONY_UDATA_ATOM, true);
latom->atom = (const LV2_Atom *)control;
latom->atom = (const LV2_Atom *)event_in;
latom->body.raw = LV2_ATOM_BODY_CONST(latom->atom);
lforge_t *lforge = moony_newuserdata(L, &handle->moony, MOONY_UDATA_FORGE, true);
lforge->depth = 0;
lforge->last.frames = 0;
lforge->forge = &handle->moony.notify_forge;
lforge->forge = &handle->forge;
}
// push values
for(unsigned i=0; i<handle->max_val; i++)
lua_pushnumber(L, *handle->val_in[i]);
lua_call(L, 3 + handle->max_val + 2, LUA_MULTRET);
unsigned ret = lua_gettop(L) - top;
......
......@@ -96,9 +96,6 @@ _run_period(lua_State *L, const char *cmd, Handle *handle, uint32_t nsamples,
{
lua_pushinteger(L, nsamples);
for(unsigned i=0; i<handle->max_val; i++)
lua_pushnumber(L, *handle->val_in[i]);
// push control / notify pair
{
latom_t *latom = moony_newuserdata(L, &handle->moony, MOONY_UDATA_ATOM, true);
......@@ -111,6 +108,10 @@ _run_period(lua_State *L, const char *cmd, Handle *handle, uint32_t nsamples,
lforge->forge = &handle->moony.notify_forge;
}
// push values
for(unsigned i=0; i<handle->max_val; i++)
lua_pushnumber(L, *handle->val_in[i]);
lua_call(L, 1 + handle->max_val + 2, LUA_MULTRET);
unsigned ret = lua_gettop(L) - top;
......
......@@ -114,7 +114,7 @@ moony:c1xc1
] ;
state:state [
moony:code """function run(n, c1, control, notify)
moony:code """function run(n, control, notify, c1)
return c1
end"""
] .
......@@ -188,7 +188,7 @@ moony:c2xc2
] ;
state:state [
moony:code """function run(n, c1, c2, control, notify)
moony:code """function run(n, control, notify, c1, c2)
return c1, c2
end"""
] .
......@@ -292,7 +292,7 @@ moony:c4xc4
] ;
state:state [
moony:code """function run(n, c1, c2, c3, c4, control, notify)
moony:code """function run(n, control, notify, c1, c2, c3, c4)
return c1, c2, c3, c4
end"""
] .
......@@ -358,7 +358,7 @@ moony:a1xa1
] ;
state:state [
moony:code """function run(n, seq, forge, control, notify)
moony:code """function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do
forge:time(frames):atom(atom)
end
......@@ -446,7 +446,7 @@ moony:a2xa2
] ;
state:state [
moony:code """function run(n, seq1, forge1, seq2, forge2, control, notify)
moony:code """function run(n, control, notify, seq1, forge1, seq2, forge2)
for frames, atom in seq1:foreach() do
forge1:time(frames):atom(atom)
end
......@@ -578,7 +578,7 @@ moony:a4xa4
] ;
state:state [
moony:code """function run(n, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4, control, notify)
moony:code """function run(n, control, notify, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4)
for frames, atom in seq1:foreach() do
forge1:time(frames):atom(atom)
end
......@@ -675,7 +675,7 @@ moony:c1a1xc1a1
] ;
state:state [
moony:code """function run(n, seq, forge, c1, control, notify)
moony:code """function run(n, control, notify, seq, forge, c1)
for frames, atom in seq:foreach() do
forge:time(frames):atom(atom)
end
......@@ -777,7 +777,7 @@ moony:c2a1xc2a1
] ;
state:state [
moony:code """function run(n, seq, forge, c1, c2, control, notify)
moony:code """function run(n, control, notify, seq, forge, c1, c2)
for frames, atom in seq:foreach() do
forge:time(frames):atom(atom)
end
......@@ -909,7 +909,7 @@ moony:c4a1xc4a1
] ;
state:state [
moony:code """function run(n, seq, forge, c1, c2, c3, c4, control, notify)
moony:code """function run(n, control, notify, seq, forge, c1, c2, c3, c4)
for frames, atom in seq:foreach() do
forge:time(frames):atom(atom)
end
......
......@@ -72,7 +72,7 @@ moony:bank-through_control-through
a pset:Preset ;
doap:license lic:Artistic-2.0 ;
state:state [
moony:code """function run(n, ...)
moony:code """function run(n, control, notify, ...)
return ...
end"""
] .
......@@ -81,7 +81,7 @@ moony:bank-through_atom-through
a pset:Preset ;
doap:license lic:Artistic-2.0 ;
state:state [
moony:code """function run(n, seq, forge, ...)
moony:code """function run(n, control, notify, seq, forge, ...)
for frames, atom in seq:foreach() do
forge:time(frames):atom(atom)
end
......@@ -94,7 +94,7 @@ moony:bank-through_atom-through2
a pset:Preset ;
doap:license lic:Artistic-2.0 ;
state:state [
moony:code """function run(n, seq1, forge1, seq2, forge2)
moony:code """function run(n, control, notify, seq1, forge1, seq2, forge2)
for frames, atom in seq1:foreach() do
forge1:time(frames):atom(atom)
end
......@@ -109,7 +109,7 @@ moony:bank-through_atom-through4
a pset:Preset ;
doap:license lic:Artistic-2.0 ;
state:state [
moony:code """function run(n, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4)
moony:code """function run(n, control, notify, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4)
for frames, atom in seq1:foreach() do
forge1:time(frames):atom(atom)
end
......@@ -132,7 +132,7 @@ moony:bank-multiplex_atom-multiplex2
a pset:Preset ;
doap:license lic:Artistic-2.0 ;
state:state [
moony:code """function run(n, seq1, forge1, seq2, forge2)
moony:code """function run(n, control, notify, seq1, forge1, seq2, forge2)
for frames, atom in seq1:foreach(seq2) do
forge1:time(frames):atom(atom)
forge2:time(frames):atom(atom)
......@@ -144,7 +144,7 @@ moony:bank-multiplex_atom-multiplex4
a pset:Preset ;
doap:license lic:Artistic-2.0 ;
state:state [
moony:code """function run(n, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4)
moony:code """function run(n, control, notify, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4)
for frames, atom in seq1:foreach(seq2, seq3, seq4) do
forge1:time(frames):atom(atom)
forge2:time(frames):atom(atom)
......@@ -167,7 +167,7 @@ moony:bank-midi_midi-responder
end
})
function run(n, seq, forge)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do
local handled = midiR(frames, forge, atom)
end
......@@ -208,7 +208,7 @@ function apply(atom)
timeR:apply(atom)
end
function run(n, seq, forge)
function run(n, control, notify, seq, forge)
local from = 0
for frames, atom in seq:foreach() do
timeR(from, frames, forge, atom)
......@@ -231,7 +231,7 @@ moony:bank-osc_osc-responder
end
})
function run(n, seq, forge)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do
local handled = oscR(frames, forge, atom)
end
......@@ -399,11 +399,11 @@ function restore(atom)
pURI[RDF.value] = Unmap[pURID[RDF.value]]
end
function once(n, seq, forge, control, notify)
function once(n, control, notify, seq, forge)
stateR:register(0, notify)
end
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in control:foreach() do
stateR(frames, notify, atom)
end
......@@ -435,7 +435,7 @@ for i, v in ipairs(channels) do
mask = mask | (1 << v) -- toggle bit of active channel
end
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local block = false -- assume a not-to-be-blocked event by default
......@@ -485,7 +485,7 @@ local midiR = MIDIResponder({
[MIDI.NotePressure] = noteResponder(MIDI.NotePressure) -- and NotePressure
}, true)
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local handled = midiR(frames, forge, atom) -- call responder for event
end
......@@ -572,7 +572,7 @@ function apply(atom)
end
end
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local handled = midiR(frames, forge, atom) -- call responder for event
end
......@@ -652,7 +652,7 @@ local function dispatch(n, forge)
end
end
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local handled = midiR(frames, forge, atom) -- call responder for event
end
......@@ -707,7 +707,7 @@ local midiR = MIDIResponder({
[MIDI.NoteOff] = note_responder(MIDI.NoteOff) -- and NoteOff
}, true)
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local handled = midiR(frames, forge, atom) -- call responder for event
end
......@@ -783,7 +783,7 @@ local midiR = MIDIResponder({
end
}, not block)
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local handled = midiR(frames, forge, atom) -- call responder for event
end
......@@ -834,7 +834,7 @@ function apply(atom)
timeR:apply(atom)
end
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
local from = 0 -- initial frame offset
for to, atom in seq:foreach() do -- iterate over incoming events
......@@ -863,7 +863,7 @@ local oscR = OSCResponder({
end
})
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach() do -- iterate over incoming events
local handled = oscR(frames, forge, atom) -- call responder for event
end
......@@ -911,11 +911,11 @@ function restore(atom)
end
-- register parameters to UI
function once(n, seq, forge, control, notify)
function once(n, control, notify, seq, forge)
stateR:register(0, notify)
end
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
for frames, atom in seq:foreach(control) do -- iterate over incoming events
local handled = stateR(frames, notify, atom)
end
......
......@@ -66,14 +66,18 @@ main(int argc, char **argv)
" restore(_state)\n"
" end\n"
" local n = 128\n"
" local _seq0 = Stash()\n"
" local _seq1 = Stash()\n"
" local _seq2 = Stash()\n"
" local _seq3 = Stash()\n"
" local _seq4 = Stash()\n"
" local _forge0 = Stash()\n"
" local _forge1 = Stash()\n"
" local _forge2 = Stash()\n"
" local _forge3 = Stash()\n"
" local _forge4 = Stash()\n"
" _seq0:sequence():pop()\n"
" _seq0:read()\n"
" _seq1:sequence():pop()\n"
" _seq1:read()\n"
" _seq2:sequence():pop()\n"
......@@ -83,10 +87,10 @@ main(int argc, char **argv)
" _seq4:sequence():pop()\n"
" _seq4:read()\n"
" if once then\n"
" once(n, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)\n"
" once(n, _seq0, _forge0, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)\n"
" end\n"
" if run then\n"
" run(n, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)\n"
" run(n, _seq0, _forge0, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)\n"
" end\n"
"end\n"
"\n");
......
......@@ -214,7 +214,7 @@
<a class="api-snippet" href="#snippet-run-c1xc1" data-snippet="snippet-run-c1xc1">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-c1xc1">-- C1 x C1 prototype 'run' function
function run(n, c, control, notify)
function run(n, control, notify, c)
return c
end</code></pre>
</div></div>
......@@ -226,7 +226,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-c2xc2" data-snippet="snippet-run-c2xc2">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-c2xc2">-- C2 x C2 prototype 'run' function
function run(n, c1, c2, control, notify)
function run(n, control, notify, c1, c2)
return c1, c2
end</code></pre>
</div></div>
......@@ -238,7 +238,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-c4xc4" data-snippet="snippet-run-c4xc4">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-c4xc4">-- C4 x C4 prototype 'run' function
function run(n, c1, c2, c3, c4, control, notify)
function run(n, control, notify, c1, c2, c3, c4)
return c1, c2, c3, c4
end</code></pre>
</div></div>
......@@ -250,7 +250,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-a1xa1" data-snippet="snippet-run-a1xa1">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-a1xa1">-- A1 x A1 prototype 'run' function
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
end</code></pre>
</div></div>
......@@ -261,7 +261,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-a2xa2" data-snippet="snippet-run-a2xa2">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-a2xa2">-- A2 x A2 prototype 'run' function
function run(n, seq1, forge1, seq2, forge2, control, notify)
function run(n, control, notify, seq1, forge1, seq2, forge2)
end</code></pre>
</div></div>
......@@ -272,7 +272,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-a4xa4" data-snippet="snippet-run-a4xa4">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-a4xa4">-- A4 x A4 prototype 'run' function
function run(n, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4, control, notify)
function run(n, control, notify, seq1, forge1, seq2, forge2, seq3, forge3, seq4, forge4)
end</code></pre>
</div></div>
......@@ -284,7 +284,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-c1a1xc1a1" data-snippet="snippet-run-c1a1xc1a1">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-c1a1xc1a1">-- C1+A1 x C1+A1 prototype 'run' function
function run(n, seq, forge, c, control, notify)
function run(n, control, notify, seq, forge, c)
return c
end</code></pre>
</div></div>
......@@ -297,7 +297,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-c2a1xc2a1" data-snippet="snippet-run-c2a1xc2a1">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-c2a1xc2a1">-- C2+A1 x C2+A1 prototype 'run' function
function run(n, seq, forge, c1, c2, control, notify)
function run(n, control, notify, seq, forge, c1, c2)
return c1, c2
end</code></pre>
</div></div>
......@@ -310,7 +310,7 @@ end</code></pre>
<a class="api-snippet" href="#snippet-run-c4a1xc4a1" data-snippet="snippet-run-c4a1xc4a1">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-run-c4a1xc4a1">-- C4+A1 x C4+A1 prototype 'run' function
function run(n, seq, forge, c1, c2, c3, c4, control, notify)
function run(n, control, notify, seq, forge, c1, c2, c3, c4)
return c1, c2, c3, c4
end</code></pre>
</div></div>
......@@ -358,15 +358,15 @@ print('hello world')</code></pre>
return native Lua numbers, missing return values will be set to 0.0.</p>
<dl>
<dt class="func">function run(n, seq1, forge1, ..., c1, ..., control, notify)</dt>
<dt class="func">function run(n, control, notify, seq1, forge1, ..., c1, ...)</dt>
<dt>n (integer)</dt>
<dd>number of audio samples of current period</dd>
<dt>{control, notify} (userdata, userdata)</dt>
<dd>pair of atom sequence and atom forge object for communication with UI</dd>
<dt>{seq, forge} [x] (userdata, userdata)</dt>
<dd>pairs of atom sequence and atom forge objects, with x=[0, 1, 2, 4]</dd>
<dt>c [x] (number)</dt>
<dd>control port inputs, with x=[0, 1, 2, 4]</dd>
<dt>{control, notify} (userdata, userdata)</dt>
<dd>pair of atom sequence and atom forge object for communication with UI</dd>
<dt class="ret">(number)</dt>
<dd>control port outputs, with x=[0, 1, 2, 4]</dd>
</dl>
......@@ -374,7 +374,7 @@ print('hello world')</code></pre>
<a class="api-snippet" href="#snippet-callback-run" data-snippet="snippet-callback-run">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-callback-run">-- 'run' callback prototype for moony#a1xa1
function run(n, seq, forge, control, notify)
function run(n, control, notify, seq, forge)
-- here we will process events
end</code></pre>
</div></div>
......@@ -393,21 +393,21 @@ end</code></pre>
a new <a href="#state-responder">StateResponder</a>.</p>
<dl>
<dt class="func">function once(n, seq1, forge1, ..., c1, ..., control, notify)</dt>
<dt class="func">function once(n, control, notify, seq1, forge1, ..., c1, ...)</dt>
<dt>n (integer)</dt>
<dd>number of audio samples of current period</dd>
<dt>{control, notify} (userdata, userdata)</dt>
<dd>pair of atom sequence and atom forge object for communication with UI</dd>
<dt>{seq, forge} [x] (userdata, userdata)</dt>
<dd>pairs of atom sequence and atom forge objects, with x=[0, 1, 2, 4]</dd>
<dt>c [x] (number)</dt>
<dd>control port inputs, with x=[0, 1, 2, 4]</dd>
<dt>{control, notify} (userdata, userdata)</dt>
<dd>pair of atom sequence and atom forge object for communication with UI</dd>
</dl>
<a class="api-snippet" href="#snippet-callback-once" data-snippet="snippet-callback-once">&rArr; show snippet</a>
<pre class="api-hidden"><code id="snippet-callback-once">-- 'once' callback prototype for moony#a1xa1
function once(n, seq, forge, control, notify)
function once(n, control, notify, seq, forge)
-- here we will run logic once right after a code update
-- send all-notes-off MIDI message on all channels
......@@ -3221,7 +3221,7 @@ function restore(atom)
end
-- register state upon code reload
function once(n, seq, forge)
function once(n, control, notify, seq, forge)
assert(stateR:register(0, forge) == forge)
end
......
......@@ -56,14 +56,18 @@ local function _test(produce, consume, check)
if once then
local n = 128
local _seq0 = Stash()
local _seq1 = Stash()
local _seq2 = Stash()
local _seq3 = Stash()
local _seq4 = Stash()
local _forge0 = Stash()
local _forge1 = Stash()
local _forge2 = Stash()
local _forge3 = Stash()
local _forge4 = Stash()
_seq0:sequence():pop()
_seq0:read()
_seq1:sequence():pop()
_seq1:read()
_seq2:sequence():pop()
......@@ -73,19 +77,23 @@ local function _test(produce, consume, check)
_seq4:sequence():pop()
_seq4:read()
once(n, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)
once(n, _seq0, _forge0, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)
end
if run then
local n = 128
local _seq0 = Stash()
local _seq1 = Stash()
local _seq2 = Stash()
local _seq3 = Stash()
local _seq4 = Stash()
local _forge0 = Stash()
local _forge1 = Stash()
local _forge2 = Stash()
local _forge3 = Stash()
local _forge4 = Stash()
_seq0:sequence():pop()
_seq0:read()
_seq1:sequence():pop()
_seq1:read()
_seq2:sequence():pop()
......@@ -95,7 +103,7 @@ local function _test(produce, consume, check)
_seq4:sequence():pop()
_seq4:read()
run(n, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)
run(n, _seq0, _forge0, _seq1, _forge1, _seq2, _forge2, _seq3, _forge3, _seq4, _forge4)
end
end
......
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