View Single Post
Old 10-25-2018, 01:48 PM   #28
kilna
Human being with feelings
 
kilna's Avatar
 
Join Date: Oct 2009
Location: San Diego, CA, USA, Earth, Sol System, Milky Way Galaxy
Posts: 30
Default

OK, so I've used your code as a starting point and added the features related to routing that I described above:

Code:
desc:MIDI Channel to Bus
//tags: MIDI processing routing

in_pin:none
out_pin:none

slider1:1<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Start MIDI Channel / Bus
slider2:14<1,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Qty of Channels / Busses (MPE Polyphony)
slider3:1<0,1,1{Disabled,Enabled}>Map High Channels Wrapped Busses
slider4:0<0,16,1{Disabled,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Broadcast Channel (sent to every output bus)
slider5:0<0,16,1{Passthrough (mapping disabled),1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Map to MIDI Channel

@init

ext_midi_bus = 1;

@slider

start_channel = slider1;
end_channel = start_channel + slider2;
(end_channel > 15) ? (end_channel = 15;);
num_channels = (end_channel - start_channel + 1);
wrap = slider3;
broadcast = (slider4 > 0);
broadcast_channel = (slider4 - 1);
map = (slider5 > 0);
map_channel = (slider5 - 1);

@block
while (midirecv(offset, msg1, msg2, msg3)) (
    
  input_bus = midi_bus;
  input_channel = (msg1 & 0x0f);
  message = (msg1 & 0xf0);
  (broadcast && (input_channel == broadcast_channel)) ? (
    bus = start_channel;
    loop( num_channels,
      output_channel = ( map ? map_channel : input_channel );
      midi_bus = bus;
      midisend(offset, (message + output_channel), msg2, msg3);
      bus += 1;
    );
  ) : (
    ((input_channel >= start_channel) && ((input_channel <= end_channel) || wrap)) ? (
      output_bus = input_channel;
      (input_channel > end_channel) ? (
        output_bus = (((input_channel - start_channel) % num_channels) + start_channel);
      );
      midi_bus = output_bus;
      output_channel = ( map ? map_channel : input_channel );
      midisend(offset, (message + output_channel), msg2, msg3);
    ) : (
      midisend(offset, msg1, msg2, msg3);
    );
  );
);
This does all of the things I want:
  • Configurable polyphony
  • Configurable start channel/bus
  • Ability to rewrite to a target channel (since many FX only respond on one channel)
  • Ability to map a larger number of incoming MIDI channels to a smaller number of busses (higher MIDI channels wrap back around to use lower bus numbers)... this allows me to run, say, only 4 VTSs while retaining as much polyphony as I want during recording the MPE MIDI stream.
  • Ability to optionally send one MIDI channel to all of the target busses (for MPE common-info on MIDI channel 1)

If you want full MPE compatibility, set:
  • Start Midi Channel -> 2
  • Qty of Channels / Busses -> 15
  • Map High Channel Wrapped Busses -> Either option
  • Broadcast Channel -> 1
  • Map to MIDI Channel -> Whatever your FX are configured to

...and you'll of course need 15 instances of whatever FX you want, configured each for busses 2 through 16

I've also updated my proof-of-concept Reaper file to use the new methodolgy:

https://drive.google.com/file/d/1VDR...ew?usp=sharing

In this example I have 4 ReaSynth instances, each responding to busses 2-5... the MIDI Channel to Bus plugin configured for start channel 2, channel quantity 4, wrap enabled, broadcast to channel 1, and mapped to channel 1.
Attached Files
File Type: rpp MPE Test.rpp (8.4 KB, 274 views)
File Type: txt MIDI Channel to Bus.txt (1.8 KB, 284 views)
kilna is offline   Reply With Quote