Old 04-09-2014, 10:35 AM   #1
Vincent Vespa
Human being with feelings
 
Join Date: Apr 2014
Posts: 4
Default Anyone got some time to school me in this JS stuff?

Howdy, I've been using Reaper for a while and I'm starting to think it's about time I learned to program in some stuff to make my life a bit easier. I had an idea to use a script to teach my NanoKontrol to switch MIDI channels when I toggle the Solo key on each strip. I've tried going about it many different ways, but after about ten hours of trying with no success I'm pretty sure I should leave this to people who actually know what they're doing.

I'm intending to use some form of script to allow me to alter the FX parameters that are adjusted using the NanoKontrol 2 that I have. For my test, I've been using iZotope Ozone's equalizer.

In prep for testing, I programmed the NanoKontrol so that the sliders are assigned to CC#0-7 and the knobs at the top are assigned to CC#8-15. My solo buttons (for no real reason) assigned to CC#32-39, and they are assigned in Toggle mode with Off set to 0 and on set to 127. After I did all of this, I programmed the FX parameters in Ozone to be controlled in the following way:

EQ Main Gain = Channel 1 CC 0-7
EQ Main Frequency = Channel 1 CC 8-15
EQ Main Q = Channel 2 CC 0-7
EQ Main Shape = Channel 2 CC 8-15

I then set my NanoKontrol's global MIDI channel to 3.

I assumed it would be fairly straightforward to script a midisend in JS so that the channel would send the output to the next FX in the chain with a ? to set the output to channel 1 if the Solo button's slider was set < 64 and channel 2 if the slider is > than 64. I set the FX sliders to be controlled in Absolute mode with all of my sliders, knobs, and solo buttons set to different FX sliders, but it doesn't seem like it will output it to the next FX.

To be honest I just kind of glanced through everything I found on the JS Language page, so I've probably made a terrible mess of everything, but I've never really programmed anything MIDI related... Or even music related for that matter.

Anyway, here's the script that I tried using... Maybe it will give someone an idea as to what exactly I was going for and one of you nice, super smart people can teach me a bit as you pick it apart.

My @init and @block sections are pretty much random attempts I made to make anything work. They made sense with other things I tried... Now they're just kind of random artifacts.

Feel free to laugh at me.

Code:
desc:iZotope Control

slider1:64<0,127,1>Slider 1
slider2:64<0,127,1>Slider 2
slider3:64<0,127,1>Slider 3
slider4:64<0,127,1>Slider 4
slider5:64<0,127,1>Slider 5
slider6:64<0,127,1>Slider 6
slider7:64<0,127,1>Slider 7
slider8:64<0,127,1>Slider 8
slider9:64<0,127,1>Knob 1
slider10:64<0,127,1>Knob 2
slider11:64<0,127,1>Knob 3
slider12:64<0,127,1>Knob 4
slider13:64<0,127,1>Knob 5
slider14:64<0,127,1>Knob 6
slider15:64<0,127,1>Knob 7
slider16:64<0,127,1>Knob 8
slider17:64<0,127,1>Solo 1
slider18:64<0,127,1>Solo 2
slider19:64<0,127,1>Solo 3
slider20:64<0,127,1>Solo 4
slider21:64<0,127,1>Solo 5
slider22:64<0,127,1>Solo 6
slider23:64<0,127,1>Solo 7
slider24:64<0,127,1>Solo 8

@init
  stateCC = 0xB0;

@slider
  slider1 = slider1;
  slider2 = slider2;
  slider3 = slider3;
  slider4 = slider4;
  slider5 = slider5;
  slider6 = slider6;
  slider7 = slider7;
  slider8 = slider8;
  slider9 = slider9;
  slider10 = slider10;
  slider11 = slider11;
  slider12 = slider12;
  slider13 = slider13;
  slider14 = slider14;
  slider15 = slider15;
  slider16 = slider16;
  slider17 = slider17;
  slider18 = slider18;
  slider19 = slider19;
  slider20 = slider20;
  slider21 = slider21;
  slider22 = slider22;
  slider23 = slider23;
  slider24 = slider24;

@block
  midisend(0,0xB0, 0, slider1)

@sample
  slider17 < 64 ? midisend(0,0xB0, 0, slider1) : midisend(0,0xB1, 0, slider1);
  slider18 < 64 ? midisend(0,0xB0, 1, slider2) : midisend(0,0xB1, 1, slider2);
  slider19 < 64 ? midisend(0,0xB0, 2, slider3) : midisend(0,0xB1, 2, slider3);
  slider20 < 64 ? midisend(0,0xB0, 3, slider4) : midisend(0,0xB1, 3, slider4);
  slider21 < 64 ? midisend(0,0xB0, 4, slider5) : midisend(0,0xB1, 4, slider5);
  slider22 < 64 ? midisend(0,0xB0, 5, slider6) : midisend(0,0xB1, 5, slider6);
  slider23 < 64 ? midisend(0,0xB0, 6, slider7) : midisend(0,0xB1, 6, slider7);
  slider24 < 64 ? midisend(0,0xB0, 7, slider8) : midisend(0,0xB1, 7, slider8);
  slider17 < 64 ? midisend(0,0xB0, 8, slider9) : midisend(0,0xB1, 8, slider9);
  slider18 < 64 ? midisend(0,0xB0, 9, slider10) : midisend(0,0xB1, 9, slider10);
  slider19 < 64 ? midisend(0,0xB0, 10, slider11) : midisend(0,0xB1, 10, slider11);
  slider20 < 64 ? midisend(0,0xB0, 11, slider12) : midisend(0,0xB1, 11, slider12);
  slider21 < 64 ? midisend(0,0xB0, 12, slider13) : midisend(0,0xB1, 12, slider13);
  slider22 < 64 ? midisend(0,0xB0, 13, slider14) : midisend(0,0xB1, 13, slider14);
  slider23 < 64 ? midisend(0,0xB0, 14, slider15) : midisend(0,0xB1, 14, slider15);
  slider24 < 64 ? midisend(0,0xB0, 15, slider16) : midisend(0,0xB1, 15, slider16);
Thanks in advance,
Vincent
Vincent Vespa is offline   Reply With Quote
Old 04-09-2014, 01:09 PM   #2
Vincent Vespa
Human being with feelings
 
Join Date: Apr 2014
Posts: 4
Default

Hmm...

Can anyone also tell me how to make it only send the MIDI data when the Slider Parameters change?
Vincent Vespa is offline   Reply With Quote
Old 04-09-2014, 02:07 PM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Vincent Vespa View Post
Hmm...

Can anyone also tell me how to make it only send the MIDI data when the Slider Parameters change?
Keep track of the previous value, and only send it when the previous and new value differ, i.e.:

Code:
@init
old_value = -1;

@slider
new_value = slider1;

@block
new_value != old_value ? (
  midisend(0, 0xB0, 1, new_value);
  old_value = new_value;
);
Tale is offline   Reply With Quote
Old 04-09-2014, 02:12 PM   #4
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
Default

I didn't really understand what you want to do, but I glanced at your code...

What are you trying to achieve with all the
Code:
slider1 = slider1;
slider2 = slider2;
...
Whatever it is that you try there, I do not think it will do what you expect.

Quote:
Originally Posted by Vincent Vespa View Post
Hmm...

Can anyone also tell me how to make it only send the MIDI data when the Slider Parameters change?
Your @slider block is called whenever a slider is changed. You have to keep track of the slider value before the change and compare with after the change. If it changed, you need to set a variable to note this. This variable should then be read in the @block code. Something like:

Code:
@slider
    old_s1 == slider1 ? 
    (
        old_s1 = slider1;
        s1_changed = 1;
    );

@block
    s1_changed ?
    (
        midisend(...);
        s1_changed = 0;
    );
This is of course untested, but conceptually something like that. And I'm sure others can chime in with more efficient ways to achieve the same thing.

EDIT: Darn! Tale beat me to it, but at least it showed that I was on theright track...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 04-09-2014, 07:36 PM   #5
Vincent Vespa
Human being with feelings
 
Join Date: Apr 2014
Posts: 4
Default

The slider = slider variables were kind of an allusion to an old language I used in high school where you had to name the variables with an =.

Thanks for the input guys, I'll rework it after I get some rest. I really do appreciate the input, it's a great help in motivating me to learn the scripting.
Vincent Vespa is offline   Reply With Quote
Old 04-10-2014, 01:11 AM   #6
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

No need for X = X; (unless you're are Laurie Anderson
https://www.youtube.com/watch?v=DR30nKnE80g )

Just defining a slider is enough. And using a variable is enough to declare it. "Variables do not need to be declared, are by default global to the effect, and are all double-precision floating point. "
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar 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:53 AM.


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