Old 12-09-2007, 11:51 PM   #1
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 10,246
Default New updated REAPER/JS programming documentation

...is available here:

http://reaper.fm/sdk/js/

-Justin
Justin is offline   Reply With Quote
Old 12-11-2007, 07:51 AM   #2
LOSER
Human being with feelings
 
Join Date: May 2006
Posts: 2,373
Default

Nice, so a menu to instantly reach "Basic Code", "advanced functions", "Special Variables" on every page would be nice. Also "advanced functions" is all in small letters on the buttom of this page http://reaper.fm/sdk/js/basiccode.php while on all other pages it has capital (as all other page references (like Basic Code ...) have).
LOSER is offline   Reply With Quote
Old 02-15-2008, 07:00 AM   #3
Till
Human being with feelings
 
Till's Avatar
 
Join Date: Sep 2006
Location: Germany's California
Posts: 1,541
Default

Quote:
freembuf(top)
The freembuf() function provides a facility for you to notify the memory manager that you are no longer using a portion of the local memory buffer.

For example, if the user changed a parameter on your effect halving your memory requirements, you should use the lowest indices possible, and call this function with the highest index you are using plus 1, i.e. if you are using 128,000 items, you should call freembuf(128001); If you are no longer using any memory, you should call freembuf(0);
if you are using 128,000 items the highest index is 127,999, so you should call freembuf(128000).

am i going nuts or did somebody at cockos make a mistake here?

//EDIT: i'm gonna be nice and use this function but just in case i AM going nuts, i'll use highest index + 2
__________________
Intel Core 2 Quad Q6600 / 2 GB / WinXP Pro SP2 / EMU 0404 USB

"Recording is God's way of telling you that you suck." - Bob Brozman

My Jesusonic FX - Xenakios' Extension

REAPER FR Tracker - what is that?

The "How Stuff works in REAPER": video blog

Last edited by Till; 02-15-2008 at 07:02 AM.
Till is offline   Reply With Quote
Old 05-28-2008, 01:02 PM   #4
Aedus
Human being with feelings
 
Aedus's Avatar
 
Join Date: May 2008
Posts: 11
Default JS programming in windows help format

Hi,
I've compiled the js documentation in a chm / windows help format for my comfort. If someone find it useful I gladly share it.



Aedus

Updated 5 30 2008.
Attached Files
File Type: zip reaper_js_guide.zip (63.2 KB, 1167 views)

Last edited by Aedus; 07-23-2008 at 01:43 AM.
Aedus is offline   Reply With Quote
Old 08-18-2008, 08:39 PM   #5
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 419
Default

I cant stand letting a robot have the last say!
Guod3 is offline   Reply With Quote
Old 12-02-2008, 08:18 AM   #6
Joystick
Human being with feelings
 
Joystick's Avatar
 
Join Date: Jul 2008
Location: Athens / Greece
Posts: 425
Default

Thanks Aedus, that's very helpful!

Take care,

Panoz
Joystick is offline   Reply With Quote
Old 07-04-2009, 02:21 PM   #7
MisterToast
Human being with feelings
 
Join Date: Jul 2009
Posts: 10
Default

Quote:
Originally Posted by Justin View Post
...is available here:

http://reaper.fm/sdk/js/

-Justin
One thing I missed as a newbie (just started a thread about it)--there should probably be a section about the format of the sample data I'll be seeing. What is the range? Always stereo? Do I have a pointer to it? Is it an array to me in JS?

Maybe one little fully commented simple filter plug would suffice.

Edit: On second reading, I found a mention of the range in the Special Variables" section. I must have glossed over that section in my fist reading.

Maybe what I'm looking for is a tutorial. I suppose I could write one as I make my way. :-)

Last edited by MisterToast; 07-05-2009 at 09:16 AM.
MisterToast is offline   Reply With Quote
Old 10-25-2010, 02:56 AM   #8
Reflected
Human being with feelings
 
Reflected's Avatar
 
Join Date: Jul 2009
Posts: 1,922
Default

Can someone update it?

ps- middle button and mousewheel available in js already?
Reflected is offline   Reply With Quote
Old 11-11-2010, 10:58 AM   #9
Bernstraw
Human being with feelings
 
Join Date: Sep 2010
Posts: 388
Default

Here's what I found was missing or wasn't clear enough for me in the doc - for the sake of future JS users :

1) Sliders.

a. You can define up to 64 sliders from slider1 to slider64.
b. Slider values can also be accessed with a variable index : slider(1), slider(2), ... slider(variable).
Code:
i=1; loop(64, x+=slider(i) ; i+=1);
c. You can make sliders invisible in the default interface by adding "- " before their name :
Code:
@slider

slider1:0<0,127,1>control change
slider2:0<0,127,1>- X coordinate
slider3:0<0,127,1>- Y coordinate

// Only the first slider will be visible in the default interface.
// You can create your own graphical user interface to use slider2 and slider3.
***

2) Arrays.

There is only one array available, its index goes from 0 to 8388607.
You have to define in @init where your sub-arrays will be located (their offset) in this big array.

Code:
0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 ... 8388607
\____ Xcoord ____/\____ Ycoord ____/\_____ next_array _____/
* Xcoord[...] starts at index 0 and has 6 slots.
* Ycoord[...] will have to start at index 6 and is also 6 slots long.
* next_array[...] (8 slots) starts at 12.

Here's how to do it :
Code:
@init

Xcoord = 0 ;
Ycoord = 6 ;
next_array = 12 ; // offset is given by the size of previous arrays.


@ block

// You can now use them like normal arrays.

i = 0 ;
loop(6,
     Xcoord[i] = 16*i ;
     Ycoord[i] = rand(128) ;
     i+=1 ;
);
next_array[0] = rand(16);
More in these threads :
js arrays
Can anyone explain this code to me?
a memory allocation question

***

3) @gfx glitches.

For loops (and other situations) never use the same index/variable in @gfx and @sample (or @block).

Example : this code will result in graphical glitches :
Code:
@block // audio processing

i=0;
loop(32, x[i]=spl(i); i+=1);

@gfx // graphic processing

i=0;
loop(16, gfx_drawnumber(my_data[i],0); i+=1);
It is stated in the doc that the @gfx section runs in a separate thread from @block and @sample so the variable i can be modified in @block and in @gfx concurrently.
You have to use 2 different variables, i and ii for example :

Code:
@block // audio processing

i=0;
loop(32, x[i]=spl(i); i+=1);

@gfx // graphic processing

ii=0;
loop(16, gfx_drawnumber( my_data[ii] , 0); ii+=1);
Read this thread :
Help : graphical glitches in my JS

***

4) Mouse clicks.

List of all possible values for mouse_cap :



***

5) JS font.

List of all available characters :



***
Bernstraw is offline   Reply With Quote
Old 11-11-2010, 11:20 AM   #10
mabian
Human being with feelings
 
mabian's Avatar
 
Join Date: Aug 2007
Location: Italy
Posts: 3,458
Default

WOW; thanks a lot, this is unvaluable info!!!!!

- Mario
__________________
My DAW: Intel Q9550 @2.8GHz + 4GB RAM + RME Fireface UC + 1TB HD + Win10x64
My Music: http://www.reverbnation.com/errepici - http://www.errepici.it/web/contents.asp?sec=4
mabian is offline   Reply With Quote
Old 02-07-2011, 07:10 PM   #11
danielz
Human being with feelings
 
Join Date: Feb 2011
Posts: 2
Default Does js file structure still work as described in the doc??

Hi

I used the built in script editor of Reaper ("edit" button clicked in FX window) to change an existing js Midi effect. My changed version of "midi_note_filter" now filters away the unwanted "All Notes Off" messages generated by my Roland D50 keyboard.

Instead of changing an existing effect I'd prefer to create a copy and edit the copy. However this does not work. If I add a new effect file into the Reaper sub-directory C:\Programs\REAPER\InstallData\Effects\MIDI and restart reaper the new effect does not appear in the "add fx to" screen. What did I miss? I am clueless.. any hints would be very much appreciated!

best regards
daniel
danielz is offline   Reply With Quote
Old 02-08-2011, 12:49 AM   #12
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,798
Default

You should copy your JS effect to one of the following locations:

Windows XP: C:\Documents and Settings\<username>\Application Data\REAPER\Effects
Windos Vista/7: C:\Users\<username>\AppData\Roaming\REAPER\Effects
Mac OS X: /Users/<username>/Library/Application Support/REAPER/Effects
Tale is offline   Reply With Quote
Old 02-08-2011, 04:32 PM   #13
danielz
Human being with feelings
 
Join Date: Feb 2011
Posts: 2
Default

Thanks Tale!

I first did not find the folder "Application Data" you mentioned for XP. Then I figured out it is by default invisible so I had to enable display of hidden files and folders in the folder options. Also in the german version of XP it is called "Anwendungsdaten" instead of "Application Data".

But finally all works fine.. :-)

cheers
Daniel
danielz is offline   Reply With Quote
Old 05-15-2011, 12:18 PM   #14
markheath
Human being with feelings
 
Join Date: Oct 2006
Location: Southampton, England
Posts: 160
Default

A small documentation issue I noticed:
Quote:
rand(x)
Example: s = rand(x);
Returns a psuedorandom whole number between 0 and the parameter.
rand() actually seems to return a floating point number.
__________________
Mark
Soundcloud | Bandcamp | My dev blog
markheath is offline   Reply With Quote
Old 08-25-2011, 07:06 AM   #15
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 967
Default

I checked the js documentation, http://www.reaper.fm/sdk/js/js.php , unfortunately could not find out what is the name of the "slider" BYPASS which is available on each effect?

I would like to send/trigger certain codes/events based on "bypass parameter change" of that js effect. For example in midi_transpose js effect, after each bypass toggling I would like to send "all notes off" for that track. But how can I tell in js language:


"if bypass parameter toggles" ?



Thanks in advance.
TonE is offline   Reply With Quote
Old 08-25-2011, 07:14 AM   #16
mabian
Human being with feelings
 
mabian's Avatar
 
Join Date: Aug 2007
Location: Italy
Posts: 3,458
Default

Uh, I'm not sure JS cannot be made aware of the bypass status.

- Mario
__________________
My DAW: Intel Q9550 @2.8GHz + 4GB RAM + RME Fireface UC + 1TB HD + Win10x64
My Music: http://www.reverbnation.com/errepici - http://www.errepici.it/web/contents.asp?sec=4
mabian is offline   Reply With Quote
Old 02-17-2013, 12:44 AM   #17
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 142
Default

For lack of an "Avoiding common Jesusonic mistakes" sticky thread, I'm posting here.

Wrong:
Code:
x = -5;
while (x < 5 ? (
  x += 1;
));
gfx_drawnumber (x, 0);     // Jesusonic returns "0"
Right:
Code:
x = -5;
while (x < 5 ? (
  x += 1;
  1;
));
gfx_drawnumber (x, 0);     // Jesusonic returns "5"
When Jesusonic increments x up to 0, that statement returns 0, which means false, and false statements at the end of while loops break the loop, so the while loop ends early.
Adding the "1;" statement ensures the last line of the while loop is true. Now the loop won't break until the if-condition is false.
Another way to write the while loop is to not use an if-statement and instead put the while-condition all by itself on the last line. If you do this, DON'T put in a "1;" or you'll get an infinite loop:

Right:
Code:
x = -5;
while (
  x += 1;
  x < 5;
);
gfx_drawnumber (x, 0);     // Jesusonic returns "5"
Wrong:
Code:
x = -5;
while (
  x += 1;
  x < 5;
  1;
);
gfx_drawnumber (x, 0);     // Jesusonic loops forever and returns nothing
Kite is offline   Reply With Quote
Old 08-10-2013, 06:29 AM   #18
DeBased
Human being with feelings
 
DeBased's Avatar
 
Join Date: Jun 2010
Location: UK
Posts: 170
Default

Quote:
Originally Posted by markheath View Post
A small documentation issue I noticed:
rand() actually seems to return a floating point number.
Right. But is it exclusive? Does it ever return exactly 1.0?

Also the (optional) input param <x> is treated as an integer (fractions are discarded) and clamped to 1, ie.:

Code:
function rand(x) (
  x = max((int)x, 1);
  ...
  );
DeBased is offline   Reply With Quote
Old 08-16-2013, 01:48 PM   #19
DeBased
Human being with feelings
 
DeBased's Avatar
 
Join Date: Jun 2010
Location: UK
Posts: 170
Default

edit: No I was wrong (but it would make more sense to me like that):

pdc.. examples sammples are wrong:

Code:
pdc_bot_ch=0; pdc_top_ch=2; // delays the first two channels (spl0/spl1).
pdc_bot_ch=2; pdc_top_ch=5; // delays channels spl2,spl3, and spl4.
pdc_top_ch is inclusive, so should be one less:

Code:
pdc_bot_ch=0; pdc_top_ch=1; // delays the first two channels (spl0/spl1).
pdc_bot_ch=2; pdc_top_ch=4; // delays channels spl2,spl3, and spl4.
__________________
setup: Reaper 5.x/4.x (x64), Win10 Pro (x64) / Win8.1 Pro (x64), Emu 1616m PCIe, Intel i5-3750k @ 4.6Ghz, 16GB Ram.

Last edited by DeBased; 08-17-2013 at 03:19 AM. Reason: was wrong
DeBased is offline   Reply With Quote
Old 01-24-2014, 09:32 AM   #20
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Thanks for the big JSFX documentation update (and new midirecv/while examples, much better IMHO)!

I have one stupid remark though: I was prefering the previous presentation (i.e. everything in a single page) because it was much more handy for *find*, print, etc.
Jeffos is offline   Reply With Quote
Old 04-29-2014, 08:52 PM   #21
Breeder
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,809
Default

Just a heads up on missing stuff in documentation:

special variables is missing ext_midi_bus, midi_bus, ts_num and ts_denom
user fuctions is missing globals()
functions are missing atomic_() functions
operator reference (arrays and gmem) is missing options:gmem option

Last edited by Breeder; 06-12-2014 at 11:08 AM.
Breeder is offline   Reply With Quote
Old 10-16-2014, 10:01 AM   #22
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,037
Default

js supports links in code such as:

// http://www.google.com

also acceptable

// http://google.com

but a closing parenthesis ruins the link

// http://mathopenref.com/graphfunction...40425531914894

is shortened to

// http://mathopenref.com/graphfunctions.html?fx=(a*x-x
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 02-18-2015 at 02:57 PM.
Argitoth 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 03:07 AM.


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