Go Back   Cockos Confederated Forums > REAPER Forums > JS and ReaScript Discussion

Reply
 
Thread Tools Display Modes
Old 03-24-2011, 05:58 PM   #41
Mich
Mortal
 
Join Date: May 2009
Posts: 1,265
Default

Quote:
Originally Posted by caseyjames View Post
Not that I'd be able to write a handler for them, but is it not possible to write something within JS to read a midi file? Is it not able to load arbitrary files, even if it can't cope with them?
Unless Cockos changed something and they forgot to update the JS documentation, yes.

Here are all available file functions in JS:
http://www.reaper.fm/sdk/js/js.php#cat_file

MIDI is not among then and neither is arbitrary file access. Only wav, ogg and specially formated txt files.
Mich is offline   Reply With Quote
Old 03-24-2011, 06:53 PM   #42
groundhum
Mortal
 
groundhum's Avatar
 
Join Date: Jan 2011
Location: Finger Lakes, NY
Posts: 43
Default

Doesn't file_mem() read from any open file? I'm just asking; the spec implies it.
__________________
Michael Rees, composer &c.
extraneous data
groundhum is offline   Reply With Quote
Old 03-24-2011, 08:23 PM   #43
Mich
Mortal
 
Join Date: May 2009
Posts: 1,265
Default

Quote:
Originally Posted by groundhum View Post
Doesn't file_mem() read from any open file? I'm just asking; the spec implies it.
Maybe, but I don't think JS allowa you to open any other files than wav, ogg and txt. I could be wrong though, best thing would be you go and try to open a MIDI file and see whether file_mem() returns something usable, however I doubt it will work because similar requests were already made multiple times, e.g.: http://forum.cockos.com/showthread.php?t=75323 but the answer todate has (sadly) always been no you can't read arbitrary files with JS.
Mich is offline   Reply With Quote
Old 03-24-2011, 08:43 PM   #44
caseyjames
Mortal
 
caseyjames's Avatar
 
Join Date: Jul 2009
Posts: 606
Default

Has there been any mention of a JS 2 anywhere on the horizon?
caseyjames is offline   Reply With Quote
Old 05-12-2011, 03:24 AM   #45
vocalid
Mortal
 
vocalid's Avatar
 
Join Date: Sep 2009
Location: Middle of nowhere (where the cheese comes from)
Posts: 476
Default Displaying sliders without text

I don't know if anyone has ever had this problem:

You want to insert a slider but not have a desription left of it? ...space doesn't work, it won't display the slider.

Solution: insert ASCII code 129 -> hold alt down while pressing 0129 on the keyboard number pad

(took me ages of trying out stuff to find it)

Last edited by vocalid; 05-12-2011 at 03:36 AM.
vocalid is offline   Reply With Quote
Old 09-23-2011, 03:21 AM   #46
DarkStar
Mortal
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 9,045
Default Defininig arrays

I used to run into problems defining arrays in JS FX, losing track of how the memory was being used and inadvertently reusing or overwriting memory slots.

I've come up with a fairly fool-proof syntax for defining arrays:
-- define the start address, number of items and end address together
-- for the next array, its start address = the end address of the previous array
-- each array item can consist of multiple elements
-- include any initialisation or constants (indented, for clarity)

Here is an example:

Code:
// -----------------------------------------------------------
    in_buffs = 1024;					// start of array
    noofbuffs = 256;					// number of items in array
    end_in_buffs = in_buffs + noofbuffs;		// end of array

        in_buffs[0] =  21; in_buffs[1] =  25; etc 	// initialisation of array

// -----------------------------------------------------------
    label_X = end_in_buffs;				// start of next array, = end of previous array	
    nooflabs = 32;						// number of items in array
    label_Y = label_X + nooflabs;
    label_Z = label_Y + nooflabs;
    end_labels = label_Z + nooflabs;			// end of array

        label_X[0] = 20; label_X[1] = 50; etc	// initialisation of array
        label_Y[0] = 110; label_Y[1] = 57; etc
        label_Z[0] = 40; label_Z[1] = 60; etc
 
// -----------------------------------------------------------
    chan_state = end_labels;				// start of next array, = end of previous array
        OFF = 0;						// constants for buff_state
        ON = 1;
   noofchans = 16;
   end_chan_states = chan_state + noofchans;	// end of array
 
        memset(chan_state, OFF, noofchans);	// initialisation of array (dest, value, length)
        chan_state[2] = ON;

// -----------------------------------------------------------
__________________
DarkStar
... interesting, if true.
DarkStar is online now   Reply With Quote
Old 01-14-2013, 06:16 AM   #47
IXix
Mortal
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 1,907
Default List import library

I made a suite of functions for managing lists of items in memory. Hopefully some people might find it useful .

Details and discussion at http://forum.cockos.com/showthread.p...23#post1104623
IXix is offline   Reply With Quote
Old 04-25-2013, 11:40 PM   #48
bang
Mortal
 
bang's Avatar
 
Join Date: Jul 2006
Posts: 453
Default newJs pseudo-object parameters

hello all!

seems that the main limitation of newJs pseudo-objects is that inside a function "this.foo" is all there is. there's no inbuilt way to refer to "that.foo". here's my current workaround technique:
Code:
function rgbapush()
  instance( r, g, b, a )
(
  stack_push( a );
  stack_push( b );
  stack_push( g );
  stack_push( r );
);

function rgbapop()
  instance( r, g, b, a )
(
  stack_pop( r );
  stack_pop( g );
  stack_pop( b );
  stack_pop( a );
);

// a.rgbapush(); b.rgbapush();
function rgbamix( mix ) // thread safe
  instance( r, g, b, a ) local( mix1 )
(
  mix1= 1-mix;
  this.rgbapop(); // this= b.rgbapush();
  // keep in sync w/ rgbapop()
  r= stack_pop() * mix1 + r * mix; //stack_pop( a.r );
  g= stack_pop() * mix1 + g * mix; //stack_pop( a.g );
  b= stack_pop() * mix1 + b * mix; //stack_pop( a.b );
  a= stack_pop() * mix1 + a * mix; //stack_pop( a.a );
);

/*** alas, doesn't work:
// a.rgbapush(); b.rgbapush();
function rgbamix2( mix )
  instance( r, g, b, a )
  local(a1, b1)
(
  mix1= 1-mix;
  b1.rgbapop(); a1.rgbapop();
  r= a1.r * mix1 + b1.r * mix;
  g= a1.g * mix1 + b1.g * mix;
  b= a1.b * mix1 + b1.b * mix;
  a= a1.a * mix1 + b1.a * mix;
); ***/
anyone have anything better than this?

enjoy! /dan
bang 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:01 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.