Old 04-28-2011, 05:57 AM   #1
jpshea
Human being with feelings
 
Join Date: Sep 2006
Posts: 23
Default JS to convert MIDI Note Off to MIDI Note On?

Hi folks,

Interested in using ReaGate to provide mute automation on a Soundcraft Ghost. On the Soundcraft, each channel has its own note number, and unmute is a note on message with velocity 127, and mute is a note on message with velocity 1.

So, when ReaGate closes the gate (i.e. the track falls below the gate threshold) and sends the note off message, is it possible to use JS to convert this message into a note on message with velocity 1? (preserve channel and note number)

Not sure what velocity ReaGate uses for gate open, is it also possible to force the note on velocity to 127 for any incoming note on message?

Not concerned about marrying up any corresponding note off messages btw, the Soundcraft only implements note on message (it's not a synth!).

Regards,
JPS
jpshea is offline   Reply With Quote
Old 04-28-2011, 06:35 AM   #2
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Something like this:

Code:
desc:Note off to note on vel 1 filter

// these lines tell Reaper the effect has no audio input/output,
// which enables processing optimizations.
// MIDI-only FX should always have these lines.
in_pin:none
out_pin:none

@init

NOTE_OFF = $x80;
NOTE_ON = $x90;
VEL_ONE = $x100;

@block

  while 
  (
    (midirecv(mpos, msg1, msg23)) ? 
    (
      ((msg1 & $xF0) == NOTE_OFF) ? 
      ( 
      	chan = msg1 & $x0F;
      	note = msg23 & $xFF;
      	
      	msg1 = NOTE_ON | chan;
      	msg23 = VEL_ONE | note;
      	
       );
       
      midisend(mpos, msg1, msg23);
        
    );
  );
Note: I'm at work right now, so I have not been able to test it. But just cut&paste the text into a text-file, save it somewhere in <reaper resource path>\Effects, and try it.

I hope I didn't mess up...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 05-04-2011, 04:30 AM   #3
jpshea
Human being with feelings
 
Join Date: Sep 2006
Posts: 23
Default

Thanks Fabian,

Works perfectly!! Very much appreciated.

The note on velocity for ReaGate opening is (fixed at) 127 btw, and the (original) note off message has velocity 0.

Hope to be able to try it out with the desk soon!

Still trying to get the ReaGate MIDI out recorded - per http://forums.cockos.com/showpost.ph...21&postcount=4

Regards,
JPS
jpshea is offline   Reply With Quote
Old 11-19-2017, 06:58 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@Fabian
Thanks for this script ! Could definitly be in Reapack :P
X-Raym is offline   Reply With Quote
Old 11-19-2017, 02:21 PM   #5
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Quote:
Originally Posted by X-Raym View Post
@Fabian
Thanks for this script ! Could definitly be in Reapack :P
Oops... I have no memory of this script. I wrote it? And while at work?

But, sure, if it is useful for anyone, then of course it can be included. I do not know how to do that though, so if someone feels like it, please go ahead
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 04-06-2020, 11:53 AM   #6
AntonioEc
Human being with feelings
 
Join Date: Apr 2020
Posts: 11
Default Note off to note on

I needed a plugin to work in release part of a sound, becouse most of vst synths can't play a sound after key release. So I looked for js plugin, that could filter all note on and convert notes off to notes on. The idea was to put this plugin after the synth with main part of sound, before the synth with final part of sound. So, note on triggers first synth and note off triggers second synth.

I didn't find nothing like this, but X-Raym's plugin "notes on to notes off". It is wrote very understandable with comments, and I managed to modificate it for my goal

I'm here to share result and say thanks to X-Raym

Code:
/**
 * JSFX Name: Note Off to Note On
 * Description: Filtr all note On and converts Notes Off to Note On. 
 It's usefull to elaborate release fase in a sound.
 * Author: X-Raym. Modificated by Antonio from rmmedia.ru
 * Author URI: http://www.extremraym.com
 * Links:
     Forum Thread http://forum.cockos.com/showthread.php?t=181105
     Screenshot https://monosnap.com/file/jSODyOpFNH9W4VxgBW6dByhlGfnAKS.png
 * Donation: http://www.extremraym.com/en/donation
 * Licence: GPL v3
 * REAPER: 5.0
 * Extensions: None
 * Version: 1.0
 */

/**
 * Changelog:
 * Note Off to On v.1.0 by Antonio
 * v1.0 (2017-11-19)
  + Initial Release
 */

desc:Note On under 127 velocity to Note Off And all Note Off to Note On
in_pin:none
out_pin:none
slider1:0<0,16,1{Any,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Input Channel


////////////////////////////////////////////////////////////////////////////////
@init
statNoteOn = $x90;
statNoteOff = $x80;


////////////////////////////////////////////////////////////////////////////////
@slider
inChannel = slider1 - 1;

////////////////////////////////////////////////////////////////////////////////
@block

while
(

  midirecv(offset,msg1,note,vel) ?
  (

    // Extract message type and channel
    status = msg1 & $xF0;
    channel = msg1 & $x0F;

    // Is it on our channel?
    channel == inChannel || inChannel == -1 ?
    (
      
      // Is it a note event?
      status == statNoteOn ?
      (

          // If note is good
          vel <=127 ? (
              
              vel = 0;
              msg1 = statNoteOff;
        
          );

      );
      // Is it a note off event?
            status == statNoteOff ?
            (
                    msg1 = statNoteOn;
              
                );
      

    );
    
    midisend(offset,msg1,note,vel);
    
    1; // Force loop to continue until all messages have been processed

  );

);
AntonioEc is offline   Reply With Quote
Old 09-14-2022, 04:18 AM   #7
jimbobbley
Human being with feelings
 
Join Date: Nov 2011
Posts: 95
Default

Quote:
Originally Posted by Fabian View Post
Something like this:

Code:
desc:Note off to note on vel 1 filter

// these lines tell Reaper the effect has no audio input/output,
// which enables processing optimizations.
// MIDI-only FX should always have these lines.
in_pin:none
out_pin:none

@init

NOTE_OFF = $x80;
NOTE_ON = $x90;
VEL_ONE = $x100;

@block

  while 
  (
    (midirecv(mpos, msg1, msg23)) ? 
    (
      ((msg1 & $xF0) == NOTE_OFF) ? 
      ( 
      	chan = msg1 & $x0F;
      	note = msg23 & $xFF;
      	
      	msg1 = NOTE_ON | chan;
      	msg23 = VEL_ONE | note;
      	
       );
       
      midisend(mpos, msg1, msg23);
        
    );
  );
Note: I'm at work right now, so I have not been able to test it. But just cut&paste the text into a text-file, save it somewhere in <reaper resource path>\Effects, and try it.

I hope I didn't mess up...
Just to say a big thanks for this - I'm here many years later to try a similar thing to the OP and this has worked a treat. I love this place!
jimbobbley is offline   Reply With Quote
Old 09-14-2022, 10:40 AM   #8
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Quote:
Originally Posted by jimbobbley View Post
Just to say a big thanks for this - I'm here many years later to try a similar thing to the OP and this has worked a treat. I love this place!
Something I hacked together while at work in 2011... and it is still useful? I'm amazed. And I'm glad it works for you. Have fun
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian 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:14 AM.


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