PDA

View Full Version : JS Programming - set_slider in @slider


ajay100
08-26-2007, 02:43 AM
Hi everyone, it's great to see what people get up to when inspired! Special thanks to the contributors that make it so much easier to get started with JS programming and also for the great plug-ins I'm experimenting with in Reaper!

The JS documentation doesn't make it clear if get_slider and set_slider can be used in the @slider block. The reason I would like to use these functions is so that I can iterate a loop instead of initiating and updating all of the sliders (I believe total 16 now) separately.

@slider
aryBuffer = 1024;
intNoteSliders = 14;
intCount = 0;
loop(intNoteSliders,
intCount += 1;
varSlider = floor(get_slider(1.intCount));
set_slider(1.intCount,
(varSlider < 0) ? 0 : (varSlider > 127) ? 127
);
aryBuffer(intCount) = varSlider;
);

Is this possible? There are possibly other syntax errors also, as I haven't got past the first debug error.

Many thanks.

LOSER
08-28-2007, 02:19 AM
get_slider and set_slider only work with the JS standalone version AFAIK, furthermore would your FX always have to be on the first postion in the chain for the code to work and also I don't think that 1.intCount works in any case, so you'd have to go 1+intCount/10 or something.

ajay100
08-29-2007, 06:45 AM
Thanks Loser, that helped me to experiment a bit more, and I was able to get the following code to *partially* work (in Reaper):

buffer = 1024;
intNoteOffset = 35; // first note number
intNoteSliders = 7; // controlling 7 notes, even sliders 2-14
intCount = 0; // counter
loop(intNoteSliders,
intCount += 2;
varNoteSlider = get_slider(1 + intCount / 10) + intNoteOffset; // offset is added to slider value to get note number
varVelocitySlider = get_slider(1 + (intCount + 1) / 10);
buffer[intCount] = varNoteSlider;
buffer[intCount + 1] = varVelocitySlider;
);

This works up to slider9, but when we get to slider10, there seems to be a problem. I have tested the code using the traditional x = slider10 (11,12,13,14) and it works. Any ideas?

Also, the first parameter (1 - the effect number) of get_slider doesn't seem to be enforced in Reaper, as I moved the effect around in the chain and it worked in all positions. Can anyone confirm this? Not that it is a problem ATM, but I was a bit worried about how the effect would know what number it was (?!)

LOSER
08-29-2007, 02:37 PM
[...]
Also, the first parameter (1 - the effect number) of get_slider doesn't seem to be enforced in Reaper, as I moved the effect around in the chain and it worked in all positions. Can anyone confirm this? Not that it is a problem ATM, but I was a bit worried about how the effect would know what number it was (?!)

Well, I don't know, because I don't think that get/set_slider is really intented to be used in REAPER, because from my understanding was this code intented to control on FX's parameter via another FX (to get sliders automated etc) in the JS standalone version. So I don't really know how compatible it is with REAPER, since there are several differences between JS standalone and REAPER ...

Jonas_Eriksson_Swe
09-19-2007, 08:59 AM
I've use get_ and set_slider (in @slider) in a few plugs and it seems to work fine in Reaper (while I don't know if it's *officially* supported).

Also 'effect number' seems to be 1 no matter where in the chain you put it (in Reaper).

Hope that helps! Regards,
- Jonas Eriksson