|
|
|
12-09-2007, 11:51 PM
|
#1
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
New updated REAPER/JS programming documentation
...is available here:
http://reaper.fm/sdk/js/
-Justin
|
|
|
12-11-2007, 07:51 AM
|
#2
|
Human being with feelings
Join Date: May 2006
Posts: 2,373
|
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).
|
|
|
02-15-2008, 07:00 AM
|
#3
|
Human being with feelings
Join Date: Sep 2006
Location: Germany's California
Posts: 1,543
|
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
Last edited by Till; 02-15-2008 at 07:02 AM.
|
|
|
05-28-2008, 01:02 PM
|
#4
|
Human being with feelings
Join Date: May 2008
Posts: 11
|
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.
Last edited by Aedus; 07-23-2008 at 01:43 AM.
|
|
|
08-18-2008, 08:39 PM
|
#5
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
I cant stand letting a robot have the last say!
|
|
|
12-02-2008, 08:18 AM
|
#6
|
Human being with feelings
Join Date: Jul 2008
Location: Athens / Greece
Posts: 625
|
Thanks Aedus, that's very helpful!
Take care,
Panoz
|
|
|
07-04-2009, 02:21 PM
|
#7
|
Human being with feelings
Join Date: Jul 2009
Posts: 10
|
Quote:
Originally Posted by 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.
|
|
|
10-25-2010, 02:56 AM
|
#8
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,295
|
Can someone update it?
ps- middle button and mousewheel available in js already?
|
|
|
11-11-2010, 10:58 AM
|
#9
|
Human being with feelings
Join Date: Sep 2010
Posts: 388
|
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 :
***
|
|
|
11-11-2010, 11:20 AM
|
#10
|
Moderator
Join Date: Aug 2007
Location: Italy
Posts: 4,327
|
WOW; thanks a lot, this is unvaluable info!!!!!
- Mario
|
|
|
02-07-2011, 07:10 PM
|
#11
|
Human being with feelings
Join Date: Feb 2011
Posts: 2
|
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
|
|
|
02-08-2011, 12:49 AM
|
#12
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
|
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
|
|
|
02-08-2011, 04:32 PM
|
#13
|
Human being with feelings
Join Date: Feb 2011
Posts: 2
|
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
|
|
|
05-15-2011, 12:18 PM
|
#14
|
Human being with feelings
Join Date: Oct 2006
Location: Southampton, England
Posts: 191
|
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.
|
|
|
08-25-2011, 07:06 AM
|
#15
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
|
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.
|
|
|
08-25-2011, 07:14 AM
|
#16
|
Moderator
Join Date: Aug 2007
Location: Italy
Posts: 4,327
|
Uh, I'm not sure JS cannot be made aware of the bypass status.
- Mario
|
|
|
02-17-2013, 12:44 AM
|
#17
|
Human being with feelings
Join Date: Apr 2010
Location: Portland OR
Posts: 217
|
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
|
|
|
08-10-2013, 06:29 AM
|
#18
|
Human being with feelings
Join Date: Jun 2010
Location: UK
Posts: 412
|
Quote:
Originally Posted by markheath
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);
...
);
|
|
|
08-16-2013, 01:48 PM
|
#19
|
Human being with feelings
Join Date: Jun 2010
Location: UK
Posts: 412
|
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.
Last edited by DeBased; 08-17-2013 at 03:19 AM.
Reason: was wrong
|
|
|
01-24-2014, 09:32 AM
|
#20
|
Mortal
Join Date: Dec 2008
Location: France
Posts: 1,969
|
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.
|
|
|
04-29-2014, 08:52 PM
|
#21
|
Human being with feelings
Join Date: Nov 2010
Posts: 2,436
|
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.
|
|
|
10-16-2014, 10:01 AM
|
#22
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
__________________
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.
|
|
|
08-27-2017, 10:13 AM
|
#23
|
Human being with feelings
Join Date: Jul 2009
Posts: 7,595
|
What is the purpose of "//Tags:" used in many JSFX
The FX browser doesn't seem to do anything with that.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:12 AM.
|