Old 03-08-2014, 09:04 PM   #1
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default Js effects - midi buses?

Maybe itīs a silly question, but...why donīt JS plugins have midi buses?
Soli Deo Gloria is offline   Reply With Quote
Old 03-08-2014, 09:11 PM   #2
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

they do, but they are defined within the JS code itself.

i don't really know how it works... sorry. I guess it involves some sort of sysex message.


Jeffos has a JS MIDI bus router that he wrote. So I guess you can just put this in the chain, (or maybe merge the code)

https://stash.reaper.fm/16520/MIDI_Bus_Router_v2.zip
James HE is offline   Reply With Quote
Old 03-09-2014, 01:59 AM   #3
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

This is an example of what you need:

in @init:
ext_midi_bus = 1; // causes midi_bus to be used for send/recv and midirecv() receives on all buses
when a MIDI message is received:
msg_bus = midi_bus +1; // stored as 01 ... 16
when a MIDI message is sent:
midi_bus = msg_bus -1; // sent as 00 ... 15
No need to mess with SysEx messages, which are used to transmit Bussed messages (that is done automatically).
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 03-09-2014, 06:25 PM   #4
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Thank you very much, guys! Itīs good to know it!

Darkstar, Iīll take a look inside the file of the plugin and see if I understood. I see from your indications that I have to search for "@init" and place below any of those sentences that you indicate, according to my need, isnīt it? I didnīt get that about midirecv(), though.

Thanks again both of you for the info, maybe this can lead to my humble initiation in JS coding...
Soli Deo Gloria is offline   Reply With Quote
Old 03-10-2014, 02:31 AM   #5
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

I think that the comment after the statement in @init means that the system variable is set when a MIDI message is received and is used when a MIDI message is sent. Also, that mid_recv() receives MIDI messages on any of the MIDI buses.

Have a look at midi_logger (that's where the comment came from) to see it in action. (You can Send MIDI from one track to another to put it on a Bus.)
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 03-11-2014 at 09:10 AM.
DarkStar is offline   Reply With Quote
Old 03-11-2014, 07:32 AM   #6
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Thanks so much, Darkstar! Iīll take a look at the JS programming tutorials, to have at least some minimal insights about the basic structure of JS coding. It can be useful if I want to customize any fx...
Soli Deo Gloria is offline   Reply With Quote
Old 02-23-2021, 05:02 PM   #7
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Quote:
Originally Posted by DarkStar View Post
This is an example of what you need:

in @init:
ext_midi_bus = 1; // causes midi_bus to be used for send/recv and midirecv() receives on all buses
when a MIDI message is received:
msg_bus = midi_bus +1; // stored as 01 ... 16
when a MIDI message is sent:
midi_bus = msg_bus -1; // sent as 00 ... 15
No need to mess with SysEx messages, which are used to transmit Bussed messages (that is done automatically).

After some years, I'm in the need again to set some specific JS FXs to certain MIDI buses (for example, a custom copy of the JS midi note filter set to MIDI Bus 2).



I read DarksStar's post and try it on a JS fx, but I can't get what I need. Would any charitative soul (DarkStar or anyone else) explain an easy way to set a JS FX to MIDI bus 2?
Soli Deo Gloria is offline   Reply With Quote
Old 02-23-2021, 06:22 PM   #8
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Try adding this to your code. You will need to create sliders for the midi channel and bus. This example includes note on/off but you can remove all that if it's not needed. Hope it helps.

Code:
@init
ext_midi_bus=1; 

@block
noteOn=$x90;
noteOff=$x80;
inChannel=slider1;  // channel slider
msg_bus=slider2+1; // bus slider

 while(midirecv(offset, msg1, msg2, msg3))(
      noteStatus=msg1&$xF0;
       channel=msg1&$x0F;
       noteStatus==noteOn&&channel==inChannel&&midi_bus==msg_bus-1 ? (

:your code here:

 );
noteStatus==noteOff&&channel==inChannel&&midi_bus==msg_bus-1 ? (

  :note off code here:

);
J Reverb is offline   Reply With Quote
Old 02-23-2021, 08:43 PM   #9
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Thanks so much for replying, J Reverb! I copied the code in the JS midi note filter and it looks like this :



Quote:
desc:MIDI Note Filter
//tags: MIDI processing filter
//author: Unknown

//slider1:0<-0,127,1{0: C-2,1: C#-2,2: D-2,3: D#-2,4: E-2,5: F-2,6: F#-2,7: G-2,8: G#-2,9: A-2,10: Bb-2,11: B-2,12: C-1,13: C#-1,14: D-1,15: D#-1,16: E-1,17: F-1,18: F#-1,19: G-1,20: G#-1,21: A-1,22: Bb-1,23: B-1,24: C0,25: C#0,26: D0,27: D#0,28: E0,29: F0,30: F#0,31: G0,32: G#0,33: A0,34: Bb0,35: B0,36: C1,37: C#1,38: D1,39: D#1,40: E1,41: F1,42: F#1,43: G1,44: G#1,45: A1,46: Bb1,47: B1,48: C2,49: C#2,50: D2,51: D#2,52: E2,53: F2,54: F#2,55: G2,56: G#2,57: A2,58: Bb2,59: B2,60: C3,61: C#3,62: D3,63: D#3,64: E3,65: F3,66: F#3,67: G3,68: G#3,69: A3,70: Bb3,71: B3,72: C4,73: C#4,74: D4,75: D#4,76: E4,77: F4,78: F#4,79: G4,80: G#4,81: A4,82: Bb4,83: B4,84: C5,85: C#5,86: D5,87: D#5,88: E5,89: F5,90: F#5,91: G5,92: G#5,93: A5,94: Bb5,95: B5,96: C6,97: C#6,98: D6,99: D#6,100: E6,101: F6,102: F#6,103: G6,104: G#6,105: A6,106: Bb6,107: B6,108: C7,109: C#7,110: D7,111: D#7,112: E7,113: F7,114: F#7,115: G7,116: G#7,117: A7,118: Bb7,119: B7,120: C8,121: C#8,122: D8,123: D#8,124: E8,125: F8,126: F#8,127: G8}>Lowest Key
//slider2:0<-0,127,1{0: C-2,1: C#-2,2: D-2,3: D#-2,4: E-2,5: F-2,6: F#-2,7: G-2,8: G#-2,9: A-2,10: Bb-2,11: B-2,12: C-1,13: C#-1,14: D-1,15: D#-1,16: E-1,17: F-1,18: F#-1,19: G-1,20: G#-1,21: A-1,22: Bb-1,23: B-1,24: C0,25: C#0,26: D0,27: D#0,28: E0,29: F0,30: F#0,31: G0,32: G#0,33: A0,34: Bb0,35: B0,36: C1,37: C#1,38: D1,39: D#1,40: E1,41: F1,42: F#1,43: G1,44: G#1,45: A1,46: Bb1,47: B1,48: C2,49: C#2,50: D2,51: D#2,52: E2,53: F2,54: F#2,55: G2,56: G#2,57: A2,58: Bb2,59: B2,60: C3,61: C#3,62: D3,63: D#3,64: E3,65: F3,66: F#3,67: G3,68: G#3,69: A3,70: Bb3,71: B3,72: C4,73: C#4,74: D4,75: D#4,76: E4,77: F4,78: F#4,79: G4,80: G#4,81: A4,82: Bb4,83: B4,84: C5,85: C#5,86: D5,87: D#5,88: E5,89: F5,90: F#5,91: G5,92: G#5,93: A5,94: Bb5,95: B5,96: C6,97: C#6,98: D6,99: D#6,100: E6,101: F6,102: F#6,103: G6,104: G#6,105: A6,106: Bb6,107: B6,108: C7,109: C#7,110: D7,111: D#7,112: E7,113: F7,114: F#7,115: G7,116: G#7,117: A7,118: Bb7,119: B7,120: C8,121: C#8,122: D8,123: D#8,124: E8,125: F8,126: F#8,127: G8}>Highest Key

slider1:21<0,127,1>Lowest Key (MIDI Note #)
slider2:108<0,127,1>Highest Key (MIDI Note #)
slider3:0<0,1,1{No,Yes}>Other events (CC, etc) pass through

in_pin:none
out_pin:none

@init

ext_midi_bus=1;

NOTE_OFF = 8;
NOTE_ON = 9;

was_filtered = 1024; // array for storing which notes are filtered

@block

noteOn=$x90;
noteOff=$x80;
inChannel=slider1; // channel slider
msg_bus=slider2+1; // bus slider

while(midirecv(offset, msg1, msg2, msg3))(
noteStatus=msg1&$xF0;
channel=msg1&$x0F;
noteStatus==noteOn&&channel==inChannel&&midi_bus== msg_bus-1 ? (

:your code here:

);
noteStatus==noteOff&&channel==inChannel&&midi_bus= =msg_bus-1 ? (

:note off code here:

);

while (
input = midirecv(mpos, msg1, msg23);
input ? (
statusHi = (msg1/16)|0;
statusLo = (msg1-(statusHi*16))|0;

data2 = (msg23/256)|0;
data1 = (msg23-(data2*256))|0;

// .... for Note Ons
statusHi == NOTE_ON && data2 > 0 ? (
filter = (data1 < slider1 || data1 > slider2);
(!filter) ? (
midisend(mpos, msg1, msg23);
)
was_filtered[data1] = 1;
);
):

// .... for Note Offs
statusHi == NOTE_OFF || (statusHi == NOTE_ON && data2 == 0 ) ? (
was_filtered[data1] ? (
was_filtered[data1] = 0;
)
midisend(mpos, msg1, msg23);
);
) : slider3 ? (
midisend(mpos, msg1, msg23);
);
);
input;
);

But instead of the effect title it appears a syntax error message, and it doesn't seem to accomplish the goal - that is, to be able to filter notes in the MIDI Bus 2 -. What am I doing wrong here?
Soli Deo Gloria is offline   Reply With Quote
Old 02-24-2021, 02:41 AM   #10
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Try this, there were a few errors in the code. I have highlighted in red where to put stuff so hopefully that should help if you need to modify other things.

Code:
desc:MIDI Note Filter
//tags: MIDI processing filter
//author: Unknown

//slider1:0<-0,127,1{0: C-2,1: C#-2,2: D-2,3: D#-2,4: E-2,5: F-2,6: F#-2,7: G-2,8: G#-2,9: A-2,10: Bb-2,11: B-2,12: C-1,13: C#-1,14: D-1,15: D#-1,16: E-1,17: F-1,18: F#-1,19: G-1,20: G#-1,21: A-1,22: Bb-1,23: B-1,24: C0,25: C#0,26: D0,27: D#0,28: E0,29: F0,30: F#0,31: G0,32: G#0,33: A0,34: Bb0,35: B0,36: C1,37: C#1,38: D1,39: D#1,40: E1,41: F1,42: F#1,43: G1,44: G#1,45: A1,46: Bb1,47: B1,48: C2,49: C#2,50: D2,51: D#2,52: E2,53: F2,54: F#2,55: G2,56: G#2,57: A2,58: Bb2,59: B2,60: C3,61: C#3,62: D3,63: D#3,64: E3,65: F3,66: F#3,67: G3,68: G#3,69: A3,70: Bb3,71: B3,72: C4,73: C#4,74: D4,75: D#4,76: E4,77: F4,78: F#4,79: G4,80: G#4,81: A4,82: Bb4,83: B4,84: C5,85: C#5,86: D5,87: D#5,88: E5,89: F5,90: F#5,91: G5,92: G#5,93: A5,94: Bb5,95: B5,96: C6,97: C#6,98: D6,99: D#6,100: E6,101: F6,102: F#6,103: G6,104: G#6,105: A6,106: Bb6,107: B6,108: C7,109: C#7,110: D7,111: D#7,112: E7,113: F7,114: F#7,115: G7,116: G#7,117: A7,118: Bb7,119: B7,120: C8,121: C#8,122: D8,123: D#8,124: E8,125: F8,126: F#8,127: G8}>Lowest Key
//slider2:0<-0,127,1{0: C-2,1: C#-2,2: D-2,3: D#-2,4: E-2,5: F-2,6: F#-2,7: G-2,8: G#-2,9: A-2,10: Bb-2,11: B-2,12: C-1,13: C#-1,14: D-1,15: D#-1,16: E-1,17: F-1,18: F#-1,19: G-1,20: G#-1,21: A-1,22: Bb-1,23: B-1,24: C0,25: C#0,26: D0,27: D#0,28: E0,29: F0,30: F#0,31: G0,32: G#0,33: A0,34: Bb0,35: B0,36: C1,37: C#1,38: D1,39: D#1,40: E1,41: F1,42: F#1,43: G1,44: G#1,45: A1,46: Bb1,47: B1,48: C2,49: C#2,50: D2,51: D#2,52: E2,53: F2,54: F#2,55: G2,56: G#2,57: A2,58: Bb2,59: B2,60: C3,61: C#3,62: D3,63: D#3,64: E3,65: F3,66: F#3,67: G3,68: G#3,69: A3,70: Bb3,71: B3,72: C4,73: C#4,74: D4,75: D#4,76: E4,77: F4,78: F#4,79: G4,80: G#4,81: A4,82: Bb4,83: B4,84: C5,85: C#5,86: D5,87: D#5,88: E5,89: F5,90: F#5,91: G5,92: G#5,93: A5,94: Bb5,95: B5,96: C6,97: C#6,98: D6,99: D#6,100: E6,101: F6,102: F#6,103: G6,104: G#6,105: A6,106: Bb6,107: B6,108: C7,109: C#7,110: D7,111: D#7,112: E7,113: F7,114: F#7,115: G7,116: G#7,117: A7,118: Bb7,119: B7,120: C8,121: C#8,122: D8,123: D#8,124: E8,125: F8,126: F#8,127: G8}>Highest Key


// The above code is an alternative to the sliders which will show notes istead of a slider value


slider1:21<0,127,1>Lowest Key (MIDI Note #)
slider2:108<0,127,1>Highest Key (MIDI Note #)
slider3:0<0,1,1{No,Yes}>Other events (CC, etc) pass through
slider4:0<0,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Midi Bus
slider5:0<0,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Midi Channel

in_pin:none
out_pin:none

@init

ext_midi_bus=1;

NOTE_OFF = 8;
NOTE_ON = 9;

was_filtered = 1024; // array for storing which notes are filtered

@block

inChannel=slider4;  // channel slider
msg_bus=slider5+1; // bus slider

  while (
    input = midirecv(mpos, msg1, msg23);
    input  ? (
      statusHi = (msg1/16)|0;
      statusLo = (msg1-(statusHi*16))|0;

      data2 = (msg23/256)|0;
      data1 = (msg23-(data2*256))|0;
      
      channel = msg1&$x0F; // Channel message
      
// .... for Note Ons
      statusHi == NOTE_ON && data2 > 0 && channel==inChannel && midi_bus == msg_bus-1 ? (
          filter = (data1 < slider1 || data1 > slider2); 
          (!filter) ? ( 
              midisend(mpos, msg1, msg23);
          ):(
              was_filtered[data1] = 1;
          );
      ):

// .... for Note Offs
      statusHi == NOTE_OFF || (statusHi == NOTE_ON && data2 == 0 ) && channel==inChannel && midi_bus == msg_bus-1 ? ( 
          was_filtered[data1] ? ( 
              was_filtered[data1] = 0;
          ):(
              midisend(mpos, msg1, msg23);
          );
      ) : slider3 ? (
          midisend(mpos, msg1, msg23);
      );
    );
    input;
   );
I can't test this right now but it should work I think
J Reverb is offline   Reply With Quote
Old 02-24-2021, 05:10 AM   #11
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
Default

In ReaPack there are some examples of JSFXes that use the midi bus feature.
-Michael
mschnell is offline   Reply With Quote
Old 02-24-2021, 08:50 PM   #12
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Quote:
Originally Posted by J Reverb View Post
Try this, there were a few errors in the code. I have highlighted in red where to put stuff so hopefully that should help if you need to modify other things.

I can't test this right now but it should work I think
Thanks so much, J Reverb! The bus thing seems to work just fine, but the funcionality of the note filter seems to be broken with this version... The block/pass-through of other events works for everything, including notes (something which is not supposed to happen), and the note sliders don't seem to do anything at all...

Quote:
Originally Posted by mschnell View Post
In ReaPack there are some examples of JSFXes that use the midi bus feature.
-Michael
Do you remember any specific JS fx name?

Last edited by Soli Deo Gloria; 02-25-2021 at 02:47 AM.
Soli Deo Gloria is offline   Reply With Quote
Old 02-25-2021, 05:10 AM   #13
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

Bus Station https://forum.cockos.com/showthread.php?t=241207
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 02-25-2021, 07:23 AM   #14
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
Default

The stock jsfx "Midi Delay" works with buses.
-Michael

Last edited by mschnell; 02-25-2021 at 12:09 PM.
mschnell is offline   Reply With Quote
Old 02-25-2021, 10:14 AM   #15
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

@Soli Deo Gloria
Go with DarkStar's Bus Station I would say. I can have a look into the code when able to test looks like I have got a few things wrong there on second glance.

@DarkStar
Mucho coolness I love the name Bus Station ! lol
J Reverb is offline   Reply With Quote
Old 02-26-2021, 05:28 AM   #16
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Quote:
Originally Posted by DarkStar View Post

Thanks so much, DarkStar! That JSFX is quite useful! I'll write a couple of observations in its own thread, to avoid derailing this one...


Quote:
Originally Posted by mschnell View Post
The stock jsfx "Midi Delay" works with buses.
-Michael

Thanks for the tip, Mschnell! As I look into the code (without any real coding knowledge on my part, I acknowledge), it seems to me that there's no "easy" way to include some lines of code on any JSFX and make it work with busses in a straightforward manner. It's a pitty that they don 't have that ability enabled by default; I suppose there's some important reason behind it.


Quote:
Originally Posted by J Reverb View Post
@Soli Deo Gloria
Go with DarkStar's Bus Station I would say. I can have a look into the code when able to test looks like I have got a few things wrong there on second glance.

Yes, I already did... Anyway, thank you very much for the replyies and the coding effort!
Soli Deo Gloria is offline   Reply With Quote
Old 02-26-2021, 06:02 AM   #17
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
Default

Quote:
Originally Posted by Soli Deo Gloria View Post
It's a pitty that they don 't have that ability enabled by default; I suppose there's some important reason behind it.
In fact it's even more of a pity that JSFXes can't work with Midi Buses like other plugins, as the Reaper GUI does not provide mapping Midi Buses for those JSFXes that internally ignore them.
-Michael

Last edited by mschnell; 02-26-2021 at 11:42 AM.
mschnell is offline   Reply With Quote
Old 02-26-2021, 07:34 AM   #18
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

I completely agree... Besides, many JS FXs provide MIDI functionality that makes total sense in a modular context, and MIDI buses are almost mandatory for such use cases...
Soli Deo Gloria is offline   Reply With Quote
Old 02-26-2021, 08:19 AM   #19
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Don't know if this is any closer ?


Code:
desc:MIDI Note Filter

slider1:21<0,127,1>Lowest Key (MIDI Note #)
slider2:108<0,127,1>Highest Key (MIDI Note #)
slider3:0<0,1,1{No,Yes}>Other events (CC, etc) pass through
slider4:2<0,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>CH
slider5:2<0,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Msg Bus

in_pin:none
out_pin:none

@init

ext_midi_bus=1;

NOTE_OFF = 8;
NOTE_ON = 9;

was_filtered = 1024; // array for storing which notes are filtered

@block

inChannel=slider4;  // channel slider
msg_bus=slider5+1; // bus slider
channel = msg1&$x0F; // Channel message
  while (
    input = midirecv(mpos, msg1, msg23);
    input && midi_bus == msg_bus-1 ? (
      statusHi = (msg1/16)|0;
      statusLo = (msg1-(statusHi*16))|0;
      data2 = (msg23/256)|0;
      data1 = (msg23-(data2*256))|0;
     
// .... for Note Ons
       statusHi == NOTE_ON && data2 > 0  ? (
          filter = (data1 < slider1 || data1 > slider2); 
          (!filter) ? ( 
              midisend(mpos, msg1, msg23);
          ):(
              was_filtered[data1] = 1;
          );
      ):
// .... for Note Offs
      statusHi == NOTE_OFF && input && midi_bus == msg_bus-1 || (statusHi == NOTE_ON && data2 == 0 )  ? ( 
          was_filtered[data1]  ? ( 
              was_filtered[data1] = 0;
          ):(
              midisend(mpos, msg1, msg23);
          );
      ) : slider3 ? (
          midisend(mpos, msg1, msg23);
      );
      
    );
    input;
   );
J Reverb is offline   Reply With Quote
Old 02-26-2021, 09:01 AM   #20
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,295
Default

Here’s a stupid idea that just might work. Install the ReaJS VST. Load midi JS in that. Reaper thinks it’s a VST and should treat it as such. No?
ashcat_lt is offline   Reply With Quote
Old 02-26-2021, 11:44 AM   #21
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
Default

Ouch
mschnell is offline   Reply With Quote
Old 03-01-2021, 04:09 PM   #22
Soli Deo Gloria
Human being with feelings
 
Soli Deo Gloria's Avatar
 
Join Date: Oct 2013
Location: Argentina
Posts: 1,303
Default

Quote:
Originally Posted by J Reverb View Post
Don't know if this is any closer ?


Code:
desc:MIDI Note Filter

slider1:21<0,127,1>Lowest Key (MIDI Note #)
slider2:108<0,127,1>Highest Key (MIDI Note #)
slider3:0<0,1,1{No,Yes}>Other events (CC, etc) pass through
slider4:2<0,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>CH
slider5:2<0,16,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Msg Bus

in_pin:none
out_pin:none

@init

ext_midi_bus=1;

NOTE_OFF = 8;
NOTE_ON = 9;

was_filtered = 1024; // array for storing which notes are filtered

@block

inChannel=slider4;  // channel slider
msg_bus=slider5+1; // bus slider
channel = msg1&$x0F; // Channel message
  while (
    input = midirecv(mpos, msg1, msg23);
    input && midi_bus == msg_bus-1 ? (
      statusHi = (msg1/16)|0;
      statusLo = (msg1-(statusHi*16))|0;
      data2 = (msg23/256)|0;
      data1 = (msg23-(data2*256))|0;
     
// .... for Note Ons
       statusHi == NOTE_ON && data2 > 0  ? (
          filter = (data1 < slider1 || data1 > slider2); 
          (!filter) ? ( 
              midisend(mpos, msg1, msg23);
          ):(
              was_filtered[data1] = 1;
          );
      ):
// .... for Note Offs
      statusHi == NOTE_OFF && input && midi_bus == msg_bus-1 || (statusHi == NOTE_ON && data2 == 0 )  ? ( 
          was_filtered[data1]  ? ( 
              was_filtered[data1] = 0;
          ):(
              midisend(mpos, msg1, msg23);
          );
      ) : slider3 ? (
          midisend(mpos, msg1, msg23);
      );
      
    );
    input;
    );

Thanks so much, J Reverb!! It doesn't seem to work, but I really appreciate the efforts! I'm considering other alternatives, so, don't worry about this anymore unless you take it as a personal challenge regarding this code and you're decided to make it work, no matter what... (!)


Quote:
Originally Posted by ashcat_lt View Post
Here’s a stupid idea that just might work. Install the ReaJS VST. Load midi JS in that. Reaper thinks it’s a VST and should treat it as such. No?

Not a bad idea, ashcat, but considering that I 'm on Linux, I'd have to use them bridged with Wine/Yabridge for now. Another possibility to take into account, for now...
Soli Deo Gloria is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.