13
0

Revert failed experiment, scripted multiple MIDI outputs via dsp_run()

This reverts commit 8702ff2189,
and b10d9cf09b.

There was a misconception on the iterator (port vs message
in sequence), besides Ardour's mixer-strip is preferably used
with a single MIDI port. Most plugin-standards also only support
one port.

If need be LuaDSP run_map() can be used to handle multiple
MIDI I/O ports already.
This commit is contained in:
Robin Gareus 2020-03-09 22:07:41 +01:00
parent 810b2fb78d
commit 1d17993a29
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 6 additions and 57 deletions

View File

@ -725,15 +725,12 @@ LuaProc::connect_and_run (BufferSet& bufs,
// copy back midi events // copy back midi events
if (_has_midi_output && lua_midi_sink_tbl.isTable ()) { if (_has_midi_output && lua_midi_sink_tbl.isTable ()) {
uint32_t count = 0; bool valid;
uint32_t idx; const uint32_t idx = out.get(DataType::MIDI, 0, &valid);
for (luabridge::Iterator i (lua_midi_sink_tbl); !i.isNil (); ++i) { if (valid && bufs.count().n_midi() > idx) {
bool iter_is_valid; MidiBuffer& mbuf = bufs.get_midi(idx);
idx = out.get(DataType::MIDI, count, &iter_is_valid); mbuf.silence(0, 0);
count++; for (luabridge::Iterator i (lua_midi_sink_tbl); !i.isNil (); ++i) {
if (iter_is_valid && bufs.count().n_midi() > idx) {
MidiBuffer& mbuf = bufs.get_midi(idx);
mbuf.silence(0, 0);
if (!i.key ().isNumber ()) { continue; } if (!i.key ().isNumber ()) { continue; }
if (!i.value ()["time"].isNumber ()) { continue; } if (!i.value ()["time"].isNumber ()) { continue; }
if (!i.value ()["data"].isTable ()) { continue; } if (!i.value ()["data"].isTable ()) { continue; }

View File

@ -1,48 +0,0 @@
ardour {
["type"] = "dsp",
name = "MIDI generator with multiple ports",
category = "Example",
license = "MIT",
author = "R8000",
description = [[An Example Midi Generator for prototyping.]]
}
function dsp_ioconfig () return { { midi_out = 5} } end
local tme = 0 -- sample-counter
local seq = 0 -- sequence-step
local spb = 0 -- samples per beat
local midi_sequence_one = {
{ 0x90, 64, 127 },
{ 0x80, 64, 0 },
}
local midi_sequence_two = {
{ 0x90, 60, 70 },
{ 0x80, 60, 0 },
}
local midi_sequences = { midi_sequence_one, midi_sequence_two }
function dsp_init (rate)
local bpm = 120
spb = rate * 60 / bpm
if spb < 2 then spb = 2 end
end
function dsp_run (_, _, n_samples)
assert (type(midiout) == "table")
assert (spb > 1)
for time = 1,n_samples do -- not very efficient
-- TODO, timestamp the sequence in beats, calc/skip to next event
tme = tme + 1
if tme >= spb then
for m = 1, 5 do
midiout[m] = {time = time, data = midi_sequences[m % 2 + 1][seq + 1]}
end
tme = 0
seq = (seq + 1) % 2
end
end
end