Go Back   Cockos Incorporated Forums > Other Software Discussion > OSCII-bot forum

Reply
 
Thread Tools Display Modes
Old 10-24-2020, 04:38 AM   #1
simplecarnival
Human being with feelings
 
simplecarnival's Avatar
 
Join Date: Feb 2007
Posts: 375
Default Script to change incoming MIDI velocities and send it to Reaper?

I'm trying to use OSCII-bot to take a MIDI keyboard controller's output and increase the velocity level before sending the key information to Reaper. I don't like the velocity curve on my MIDI controller, so I want to make my own curve in software (before it hits Reaper).

I've been able to get OSCII-bot to work with the included "show-io.txt" script so that I can see the output values of my MIDI controller. However, I'm not sure where to go after this.

Can someone provide an example script that would increase the key velocity levels by 25 and then feed that result into Reaper? (Obviously, if the new velocity level adds up to be over 127, the value of 127 should be used.)

Thank you!
__________________
Jeff Boller
Sundrift Productions
simplecarnival is offline   Reply With Quote
Old 10-24-2020, 01:07 PM   #2
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
Default

Did you try Midi CC Mapper X? It can do this and million other things.
TonE is offline   Reply With Quote
Old 10-25-2020, 07:54 AM   #3
simplecarnival
Human being with feelings
 
simplecarnival's Avatar
 
Join Date: Feb 2007
Posts: 375
Default

TonE -- I looked that up, and it appears it's just a VST plug-in. I don't want to use a VST plug-in for this purpose, because -- unless there's some other way of doing this that I'm not aware of -- that means I'd have to insert this on every track where I want to use this particular keyboard controller.

Reaper has a built-in JS plug-in called "MIDI Velocity Scaler/Compressor" that does exactly what I'm looking to do...except, again, it's a plug-in. That would mean that I'd need to insert it on every track where I want to use this keyboard controller.

I have three keyboard controllers, so when I switch between them, I don't want to have to remember to enable/disable a plug-in on every track where this might be used. That's why I'm trying to change the velocity before it hits Reaper. It would be much easier to just start up OSCII-bot and have it run its script than enabling/disabling plug-ins on multiple tracks.

I believe MIDI-OX plus MIDI Yoke can theoretically do what I'm looking to do, but neither of those applications look like they've been updated to work with anything newer than Windows 2000. (I'm running Windows 10.)
__________________
Jeff Boller
Sundrift Productions
simplecarnival is offline   Reply With Quote
Old 10-25-2020, 11:24 AM   #4
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

MidiYoke and Midi-OX both work quite happily on Windows 10 so that way is possible.

To bump up the velocity with OSCII-bot then something like this script fragment should work

Code:
@midimsg
status = msg1 & $xF0;  // mask out channel to derive status 
channel = msg1 & $x0F; // mask out status to derive channel (just in case it is relevant or needed)
status == $x90 ?       // Note on - so there must be a key press
(
  msg3 = msg3 + 25;         // Bump up the velocity 
  msg3 > 127 ? msg3 = 127;  // Keep the velocity in byte range
  midisend(out);            // Where "out" is to be the same as the name of the     midi output that was opened
):                          // Just in case: msg2 contains the note : but that isn't changing
( midisend(out);            // Pass through any other midi unmodified 
);
This is only the core of the script - the opening of the midi inputs and outputs etc is omitted.

Last edited by goldenarpharazon; 10-25-2020 at 11:40 AM. Reason: Added pass through
goldenarpharazon is offline   Reply With Quote
Old 10-25-2020, 01:56 PM   #5
simplecarnival
Human being with feelings
 
simplecarnival's Avatar
 
Join Date: Feb 2007
Posts: 375
Default

Quote:
Originally Posted by goldenarpharazon View Post
MidiYoke and Midi-OX both work quite happily on Windows 10 so that way is possible.

To bump up the velocity with OSCII-bot then something like this script fragment should work

Code:
@midimsg
status = msg1 & $xF0;  // mask out channel to derive status 
channel = msg1 & $x0F; // mask out status to derive channel (just in case it is relevant or needed)
status == $x90 ?       // Note on - so there must be a key press
(
  msg3 = msg3 + 25;         // Bump up the velocity 
  msg3 > 127 ? msg3 = 127;  // Keep the velocity in byte range
  midisend(out);            // Where "out" is to be the same as the name of the     midi output that was opened
):                          // Just in case: msg2 contains the note : but that isn't changing
( midisend(out);            // Pass through any other midi unmodified 
);
This is only the core of the script - the opening of the midi inputs and outputs etc is omitted.
Thank you, goldenarpharazon...that is helpful.

I'm trying to bolt the code you provided into the show-io script, and apparently I'm doing something wrong with the output (the variable originally called "out" in your code). Every time I press a key I get this error message the OSCII-bot output window (probably because my output is wrong somehow):

Code:
midisend(): device 0.000000 invalid


Here's my code:

Code:
@input omni_midi_out OMNI-MIDI-OUTPUT
@input omni_osc_out OMNI-OSC-OUTPUT
@input omni_midi OMNI-MIDI
@input omni_osc OMNI-OSC
@init


@input midi_in MIDI "SAMSON Graphite 49"

@output devicehandle MIDI "SAMSON Graphite 49"


gfx_init("show input and output", 320,200);


function showmsg(type, desc, wp) local(colpos,w,h,str) 
(
  gfx_setfont(1,"Verdana",max(gfx_h/16,10));
  gfx_a=1;
  gfx_mode=0;
  sprintf(str=#,"%s message: %s\n",type,desc);
  gfx_measurestr(str,w,h);
  gfx_x=gfx_w/2-w/2+2;
  gfx_y=wp - h/2;
  gfx_r=gfx_g=gfx_b=0;
  gfx_drawstr(str);

  gfx_r=0.5+0.5*cos(colpos);
  gfx_g=0.7+0.3*cos(colpos+$pi/4);
  gfx_b=0.6+0.4*cos(colpos+$pi/8);
  colpos+=0.03;

  gfx_x=gfx_w/2-w/2;
  gfx_y-=2;
  gfx_drawstr(str);

);

@oscmsg

showmsg(msgdev==omni_osc ? "OSC-IN" : "OSC-OUT", oscstr,gfx_h*.4);

@midimsg

status = msg1 & $xF0;  // mask out channel to derive status 
channel = msg1 & $x0F; // mask out status to derive channel (just in case it is relevant or needed)
status == $x90 ?       // Note on - so there must be a key press
(
  msg3 = msg3 + 25;         // Bump up the velocity 
  msg3 > 127 ? msg3 = 127;  // Keep the velocity in byte range
  midisend(output);            // Where "output" is to be the same as the name of the midi output that was opened
):                          // Just in case: msg2 contains the note : but that isn't changing
( midisend(output);            // Pass through any other midi unmodified 
);

showmsg(msgdev==omni_midi ? "MIDI-IN" : "MIDI-OUT", sprintf(#,"%02x %02x %02x",msg1,msg2,msg3),gfx_h*.6);

@timer

gfx_clear=-1;
gfx_x=gfx_y=0;

dx=gfx_w*0.01;
dy=gfx_h*0.01;
gfx_a=1.0;
gfx_blit(-1,0,0.003,dx,dy,gfx_w-2*dx,gfx_h-2*dy,0,0,gfx_w,gfx_h);
gfx_a=0.01;
gfx_r=gfx_g=gfx_b=0;
gfx_rect(0,0,gfx_w,gfx_h);

I've tried setting the output to this...

Code:
@output midi_out MIDI "SAMSON Graphite 49"
...but no luck.

Any suggestions?
__________________
Jeff Boller
Sundrift Productions
simplecarnival is offline   Reply With Quote
Old 10-25-2020, 02:22 PM   #6
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Given the names used for the keyboard where it uses @output devicehandle MIDI "SAMSON Graphite 49" then

Code:
midisend(out);
should be instead

Code:
midisend(devicehandle);
This should stop the error. But the script is sending the Midi output back to the keyboard which is probably not what you intend and that might create some kind of Midi loop (usually a bad thing). You need to be sending the midi via MIDI-Yoke to route this into Reaper. i.e.

Keyboard -> MIDI -> OSCII-bot -> MIDI -> MIDI-Yoke-> MIDI -> Reaper

Alternatively, to avoid passing on Midi you could open an OSC output to Reaper and instead use the Reaper OSC feature called VKB_MIDI_NOTE to send the note. This feature can be found in the Default.ReaperOSC OSC pattern config file. This post should help too https://forum.cockos.com/showthread.php?t=155109

Last edited by goldenarpharazon; 10-26-2020 at 02:05 AM. Reason: Made using the same device variable name clearer + added VKB_MIDI_NOTE idea
goldenarpharazon is offline   Reply With Quote
Old 10-25-2020, 03:31 PM   #7
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
Default

replacing output
with devicehandle ?
TonE is offline   Reply With Quote
Old 10-25-2020, 12:04 PM   #8
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
Default

Yes, it is a jsfx. Good luck with the oscii-bot idea. You might look into Midi CC Mapper X to take whatever you like into oscii-bot. Their codes should be similar if not same.
TonE is offline   Reply With Quote
Old 10-27-2020, 04:44 AM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
Default

Quote:
Originally Posted by simplecarnival View Post
unless there's some other way of doing this that I'm not aware of -- that means I'd have to insert this on every track where I want to use this particular keyboard controller.
No problem at all. I do this all the time with my live setups.
The controller uses a single track with appropriate midi preprocessing plugins. The midi output of that track is routed by Reaper's very versatile midi routing features to as many tracks as necessary that e.g. hold the VST instrument plugins.

-Michael
mschnell is online now   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 11:45 PM.


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