mschnell
10-19-2018, 11:37 PM
I added the options all" and "all unchanged" to the input channel selection
Please test the code posted here. If it works, I'll upload it to ReaPack.
Thanks,
-Michael
desc: MIDI convert to CC
author: Michael Schnell (mschnell@bschnell.de)
version: 3.0
changelog: added "all" and "all unchanged" input channel setting, bugfixes
donation: United Nations Foundation http://www.unfoundation.org/
about:
## Description
Midi CC, PC, Note On or Note Off messages are converted to Midi CC messages with a predefined Channel and CC #. The CC value is calculated from the incoming value.
All midi messages that don't fit the "In" specifications are passed through.
The slider "In Channel" defines the channel the messages to be converted are expected in. "all" accepts any channel, "all unchanged" accepts all channels and forwards the channel unchanged.
The slider "Midi Message" selects if CC, PC, Note on or Note Off messages are converted.
The slider "In CC" is only used when "CC" is selected and defines the CC# of the eligible input messages.
The sliders "Min Input Value" and "Max Input Value" d3efine the range of the eligible input values.
The slider "Out Channel" defines the Channel the converted messages are sent in.
The slider "Out CC" defines the Midi CC message # to be sent
The slider "Min CC Value" defines the value to be sent when the Min Input Value is received. Hence there will be an offset of Min_Input_Value - Min_Outout_Value.
The slider "Max CC Value" defines the value to be sent when the Max Input Value is received. Hence there will be an appropriate stretching of the input range.
// License: LGPL - http://www.gnu.org/licenses/lgpl.html
slider1:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,all, all unchanged}>In Channel
slider2:0<0,4,1{CC,PC,Note On,Note Off}>MIDI Message
slider3:1<0,128,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61, 62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 S.Release,73 S.Attack,74 S.Brightness,75 S.Ctrl 6,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113, 114,115,116,117,118,119,120,121,122,123,124,125,12 6,127,N/A}>In CC#
slider4:0<0,127,1)>Min Input Value
slider5:127<0,127,1)>Max Input Value
slider6:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Out Channel
slider7:1<0,127,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61, 62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 S.Release,73 S.Attack,74 S.Brightness,75 S.Ctrl 6,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113, 114,115,116,117,118,119,120,121,122,123,124,125,12 6,127}>Out CC#
slider8:0<0,127,1)>Min CC Value
slider9:127<0,127,1)>Max CC Value
@slider
inchannel = slider1;
inchannel > 15 ? (
inmask = 0xf0;
inchannel = 0;
) : (
inmask = 0xff;
);
m11 = -1;
type = slider2;
type == 0 ? ( // CC
m1 = 0xb0 + inchannel;
m2 = slider3;
m2 >= 128 ? (
slider3 = 1;
m2 = 1;
);
) : type == 1 ? ( // PC
m1 = 0xc0 + inchannel;
slider3 = 128;
) : type == 2 ? ( // Note On
m1 = 0x90 + inchannel;
slider3 = 128;
) : type == 3 ? ( // Note Off
m1 = 0x80 + inchannel;
m11= 0x90 + inchannel;
slider3 = 128;
);
inmin = slider4;
inmax = slider5;
inmin >= inmax ? (
inmax = inmin+1;
slider5 = inmax;
);
inmax = slider5;
mm1 = 0xb0 + slider6;
outCC = slider7;
outmin = slider8;
outmax = slider9;
factor = (outmax-outmin) / (inmax - inmin);
@block
function convert (mm) (
mm >= inmin ? (
mm <= inmax ? (
m3 = ((((mm-inmin) * factor) + 0.5) | 0) + outmin;
m3 > 127 ? m3 = 127;
m = mm1;
msg11 = -1;
);
);
);
while (midirecv(offset, msg1, msg2, msg3)) (
msg11 = msg1 & inmask;
m = 0;
type = slider2;
type == 0 ? ( // CC
msg11 == m1 ? (
msg2 == m2 ? (
convert(msg3);
);
);
) : (type == 1) || (type == 3) ? ( // PC or Note off
msg11 == m1 ? (
convert(msg2);
) : (msg11 == m11) && (msg3 == 0) ? ( // Note On, Velocity 0 -> Note off
convert(msg2);
);
) : type == 2 ? ( // Note On
msg11 == m1 ? (
msg3 != 0 ? ( // Velocity 0 -> Note off
convert(msg2);
);
);
);
m ? (
slider1 == 17 ? (
m = (m & 0xf0) | (msg1 & 0x0f); // replace predefined channel by received channel
);
midisend(offset, m, outCC, m3);
);
msg11 >= 0 ? midisend(offset, msg1, msg2, msg3); // pass through
);
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.