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 :
***