Remove dsp_has_midi_*() in favor of dsp_ioconfig()
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Thu, 4 Aug 2016 15:47:38 +0000 (17:47 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Sat, 6 Aug 2016 17:38:09 +0000 (19:38 +0200)
_has_midi_*put members of LuaProc will be set according to the actual
configuration chosen, for configure_io() and run() to use.

libs/ardour/luaproc.cc
scripts/midifilter.lua
scripts/midigenerator.lua
scripts/midimon.lua
scripts/rawmidi.lua
scripts/synth1.lua

index c8e088af55e0445c3bee82729ed81df00c637bcb..e157467094179d0da3a75728a7a73441e5e033f7 100644 (file)
@@ -228,25 +228,6 @@ LuaProc::load_script ()
                }
        }
 
-       // query midi i/o
-       luabridge::LuaRef lua_dsp_has_midi_in = luabridge::getGlobal (L, "dsp_has_midi_input");
-       if (lua_dsp_has_midi_in.type () == LUA_TFUNCTION) {
-               try {
-                       _has_midi_input = lua_dsp_has_midi_in ();
-               } catch (luabridge::LuaException const& e) {
-                       ;
-               }
-       }
-
-       luabridge::LuaRef lua_dsp_has_midi_out = luabridge::getGlobal (L, "dsp_has_midi_output");
-       if (lua_dsp_has_midi_out.type () == LUA_TFUNCTION) {
-               try {
-                       _has_midi_output = lua_dsp_has_midi_out ();
-               } catch (luabridge::LuaException const& e) {
-                       ;
-               }
-       }
-
        _ctrl_params.clear ();
 
        luabridge::LuaRef lua_render = luabridge::getGlobal (L, "render_inline");
@@ -395,6 +376,8 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
       imprecise->set (DataType::AUDIO, (in));                       \
       imprecise->set (DataType::MIDI, possible_midiin);             \
     }                                                               \
+    _has_midi_input = (possible_midiin > 0);                        \
+    _has_midi_output = (possible_midiout > 0);                      \
     penalty = p;                                                    \
     found = true;                                                   \
   }                                                                 \
@@ -436,8 +419,8 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
 
                int possible_in = io["audio_in"].isNumber() ? io["audio_in"] : -1;
                int possible_out = io["audio_out"].isNumber() ? io["audio_out"] : -1;
-               int possible_midiin = _has_midi_input ? 1 : 0;
-               int possible_midiout = _has_midi_output ? 1 : 0;
+               int possible_midiin = io["midi_in"].isNumber() ? io["midi_in"] : 0;
+               int possible_midiout = io["midi_out"].isNumber() ? io["midi_out"] : 0;
 
                if (midi_in != possible_midiin && !imprecise) {
                        continue;
index e7a2aae4f985970ee06c042984c9de20189e4ea9..3ff61d388851127a2d44748ee0bcb95198cee3fb 100644 (file)
@@ -8,12 +8,9 @@ ardour {
 }
 
 function dsp_ioconfig ()
-       return { { audio_in = 0, audio_out = 0}, }
+       return { { midi_in = 1, midi_out = 1, audio_in = 0, audio_out = 0}, }
 end
 
-function dsp_has_midi_input () return true end
-function dsp_has_midi_output () return true end
-
 function dsp_run (_, _, n_samples)
        assert (type(midiin) == "table")
        assert (type(midiout) == "table")
index 165c7d11533e3cc2d116b6c5fe0234fc30886058..4ef4bf4c714752c6b08f1ceb1695bc508a6c253c 100644 (file)
@@ -8,11 +8,9 @@ ardour {
 }
 
 function dsp_ioconfig ()
-       return { { audio_in = 0, audio_out = 0}, }
+       return { { midi_out = 1, audio_in = 0, audio_out = 0}, }
 end
 
-function dsp_has_midi_output () return true end
-
 local tme = 0 -- sample-counter
 local seq = 1 -- sequence-step
 local spb = 0 -- samples per beat
index ac92507a829d0eca63879fe3964eca09181fd70e..0dc25bf338983d1c368c3655b7dd5fb32b8b034e 100644 (file)
@@ -13,12 +13,9 @@ local evlen = 3
 local hpadding, vpadding = 4, 2
 
 function dsp_ioconfig ()
-       return { { audio_in = -1, audio_out = -1}, }
+       return { { midi_in = 1, midi_out = 1, audio_in = -1, audio_out = -1}, }
 end
 
-function dsp_has_midi_input () return true end
-function dsp_has_midi_output () return true end
-
 function dsp_params ()
        return
        {
index 72aa89673637a2601483370db272d263f67ea42b..672a37da81a1bb0985ee50f682c1b5ef72fef3d6 100644 (file)
@@ -10,14 +10,10 @@ ardour {
 -- return possible audio i/o configurations
 function dsp_ioconfig ()
        -- -1, -1 = any number of channels as long as input and output count matches
-       return { { audio_in = -1, audio_out = -1}, }
+       -- require 1 MIDI in, 1 MIDI out.
+       return { { midi_in = 1, midi_out = 1, audio_in = -1, audio_out = -1}, }
 end
 
--- require 1 MIDI in, 1 MIDI out.
-function dsp_has_midi_input () return true end
-function dsp_has_midi_output () return true end
-
-
 -- "dsp_runmap" uses Ardour's internal processor API, eqivalent to
 -- 'connect_and_run()". There is no overhead (mapping, translating buffers).
 -- The lua implementation is responsible to map all the buffers directly.
@@ -91,7 +87,8 @@ function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
        local midi_ins = in_map:count (): n_midi () -- number of midi input buffers
        local midi_outs = out_map:count (): n_midi () -- number of midi input buffers
 
-       -- with dsp_has_midi_in/out() the following will always be true
+       -- with midi_in=1, midi_out=1 in dsp_ioconfig
+       -- the following will always be true
        assert (midi_ins == 1)
        assert (midi_outs == 1)
 
index 90da05d41e8b1604bdf687cc39d87f3edc247942..2a8288ba52282ff7e8149440117522dab73a5aaa 100644 (file)
@@ -10,20 +10,15 @@ ardour {
 function dsp_ioconfig ()
        return
        {
-       --      { audio_in = 0, audio_out = -1}, -- any number of channels
-       --      { audio_in = 0, audio_out =  1}, -- values >  0, precisely N channels
-               { audio_in = 0, audio_out =  2}, -- values >  0, precisely N channels
-               { audio_in = 0, audio_out =  4}, -- values >  0, precisely N channels
-               { audio_in = 0, audio_out =  8}, -- values >  0, precisely N channels
-       --      { audio_in = 0, audio_out = -6}, -- values < -2, up to -N channels, here 1,..,6
+       --      { midi_in = 1, audio_in = 0, audio_out = -1}, -- any number of channels
+       --      { midi_in = 1, audio_in = 0, audio_out =  1}, -- values >  0, precisely N channels
+               { midi_in = 1, audio_in = 0, audio_out =  2}, -- values >  0, precisely N channels
+               { midi_in = 1, audio_in = 0, audio_out =  4}, -- values >  0, precisely N channels
+               { midi_in = 1, audio_in = 0, audio_out =  8}, -- values >  0, precisely N channels
+       --      { midi_in = 1, audio_in = 0, audio_out = -6}, -- values < -2, up to -N channels, here 1,..,6
        }
 end
 
-function dsp_has_midi_input ()
-       return true
-end
-
-
 local note_table = {}
 local active_notes = {}
 local phases = {}