Guest User

Untitled

a guest
Mar 19th, 2017
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. ardour {
  2.     ["type"]    = "dsp",
  3.     name        = "MIDI fix channel",
  4.     category    = "MIDI", -- "Utility"
  5.     license     = "MIT",
  6.     author      = "Robert Schneider",
  7.     description = [[A MIDI filter that nails all data to one channel.]]
  8. }
  9.  
  10. function dsp_ioconfig ()
  11.     return { { midi_in = 1, midi_out = 1, audio_in = 0, audio_out = 0}, }
  12. end
  13.  
  14. function dsp_params ()
  15.     return
  16.     {
  17.         { ["type"] = "input",
  18.             name = "Channel",
  19.             doc = "Channel to be used for all data",
  20.             min = 1, max = 16, default = 1, integer = true }
  21.     }
  22. end
  23.  
  24. function dsp_run (_, _, n_samples)
  25.     assert (type(midiin) == "table")
  26.     assert (type(midiout) == "table")
  27.     local cnt = 1
  28.     local ctrl = CtrlPorts:array ()
  29.     local channel = ctrl[1];
  30.  
  31.     function tx_midi (time, data)
  32.         midiout[cnt] = {}
  33.         midiout[cnt]["time"] = time;
  34.         midiout[cnt]["data"] = data;
  35.         cnt = cnt + 1;
  36.     end
  37.  
  38.     -- for each incoming midi event
  39.     for _,b in pairs (midiin) do
  40.         local t = b["time"] -- t = [ 1 .. n_samples ]
  41.         local d = b["data"] -- get midi-event
  42.  
  43.         if (bit32.band (d[1], 240) ~= 240) then -- not a SYSEX
  44.             d[1] = bit32.band (d[1], 240) + channel - 1
  45.         end
  46.         tx_midi (t, d)
  47.     end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment