|
|
|
05-29-2017, 04:45 AM
|
#1
|
Human being with feelings
Join Date: Dec 2015
Location: Guangzhou, China
Posts: 176
|
How to use array of objects?
Hey all,
Since JSFX supports pseudo object programming.
And I tried to use the RMS function in "Gain Reduction Scope".
However I didn't figure out how to replace "rmsa,rmsb" to rms[i].
I've tried the following method but failed:
rmss=1024; // just like fftwindow, I consider it as the start address of an array
sp=0;
while (sp*2<num_ch)
(
rmsa=rmss[sp];
rmsa.rms.init(histsize, srate);
sp=sp+1;
);
The compiling is OK, but I can't get the actual results except 0 from rmsa.rms.getmax.
I also tried the following method, but it still retuns 0.
sp=0;
while (sp*2<num_ch)
(
rmsa=rmss+sp*4;
rmsa.rms.init(histsize, srate);
sp=sp+1;
);
---------3rd variation------
rms1.rms.init(histsize, srate);
rms2.rms.init(histsize, srate);
rmss[0]=rms1;
rmss[1]=rms2;
...
sp=0;
while (sp*2<num_ch)
(
rmsa=rmss+sp*4; // or rmss[sp]
rmsa.xxxxx
sp=sp+1;
);
Could anyone tell me how to use the array of object correctly?
Thanks!
|
|
|
05-29-2017, 02:38 PM
|
#2
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Sorry, you can't store objects in an array (would be great if you could but that will probably never happen.)
My usual approach if I don't know how many of a thing I might need is to treat blocks of memory as object definitions...
Code:
// Car object
MAKE = 0;
MODEL = 1;
COLOUR = 2;
CAR_SIZE = 3;
carList = 1024; // Base address
numCars = 16;
pCar = carList; // Car pointer to iterate over the list
loop
(
numCars,
pCar[MAKE] = "Ford";
pCar[MODEL] = "Mustang";
pCar[COLOUR] = "Orange";
pCar += CAR_SIZE;
);
|
|
|
05-29-2017, 08:09 PM
|
#3
|
Human being with feelings
Join Date: Dec 2015
Location: Guangzhou, China
Posts: 176
|
Quote:
Originally Posted by IXix
Sorry, you can't store objects in an array (would be great if you could but that will probably never happen.)
My usual approach if I don't know how many of a thing I might need is to treat blocks of memory as object definitions...
Code:
// Car object
MAKE = 0;
MODEL = 1;
COLOUR = 2;
CAR_SIZE = 3;
carList = 1024; // Base address
numCars = 16;
pCar = carList; // Car pointer to iterate over the list
loop
(
numCars,
pCar[MAKE] = "Ford";
pCar[MODEL] = "Mustang";
pCar[COLOUR] = "Orange";
pCar += CAR_SIZE;
);
|
Thanks for your reply.
Could this be the wish list for the jsfx in REAPER?
(Besides, I also tried the "return this" in function but still failed.
|
|
|
05-30-2017, 01:27 AM
|
#4
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by eviluess
Could this be the wish list for the jsfx in REAPER?
|
Not likely. It's either impossible or so vastly complicated that it's just not worth the effort involved. We just have to work with what we've got. What we've got is actually pretty amazing.
|
|
|
12-02-2017, 10:05 AM
|
#5
|
Human being with feelings
Join Date: Oct 2015
Posts: 35
|
What if another plugin is using that address?
|
|
|
12-02-2017, 10:19 AM
|
#6
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Not a problem, each JS FX has its own 8MB space
Quote:
A virtual local address space of about 8 million words, which can be accessed via brackets "[" and "]".
|
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
12-02-2017, 05:02 PM
|
#7
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
|
Plus 1 MB (AFAI remember) "gloabal" space shared by all of them, which you need to manage manually.
But you can use global namespaces that are managed automatically between multiple plugins.
-Michael
Last edited by mschnell; 05-23-2018 at 09:27 PM.
|
|
|
05-23-2018, 03:59 PM
|
#8
|
Human being with feelings
Join Date: Jul 2016
Posts: 33
|
me too
Hi guys. I know I'm committing a forum crime here by opening up an old wound - but I too second the need for this.
Its not so much that I want to put objects into an array, its that I need to have multiple instances of some function (with individual scope/closure/private variables) that I can index at a whim from 0 to n.
Specifically I have a butterworth filter + some extra code that I don't feel like repeating 2048 times.
I tried sweeping the one instance of the butterworth filter up & down the spectrum, but if you do that fast enough it creates harmonics ^_^
My current thought on this is to drill down the functionality as much as possible and get to individual variables & have them in an array.
Eg write my 'object's code to always need a pointer for every single one of its private variables. I haven't done this yet, but its where I'm going.
This methodology breaks down though when using any kind of library which utilizes pseudoobjects - because well, thats not your own code.
|
|
|
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 09:23 AM.
|