JS

Creating a structure from a number and index possibly using JS

miccat's picture

Hi,

I have searched the internet for hours on this problem and the closest thing I have come across is a structure merger built in javascript in this post: "Just modifing one (or many) members in a structure before using this structure..." I have tried to modify this so that the input is a number rather than a structure but as I have never studied JS I am finding it extremely difficult.

Basically, what I am trying to achieve is an object with a similar output to the 'audio input' object which comes with QC4. The difference being that the structure can have more than 16 bands.

Say I had 50 bands with index 0, 1, 2, 3, ...49 Each with a value between 0-1.

How can I form this into a structure (in a similar way to what 'audio input' does)?

Thanks so much for your help and I hope this makes sense.

Javascript problem. Probably newb error but I just don't get it!

usefuldesign.au's picture

I'm writing a simple JS routine to filter a structure of points into those points that are within a prescribed distance of a particular point, which is described by it's index value in the point structure.

So it's not the first time JS has refused to pull nested values even when I'm using code I've used successfully elsewhere ie. [i] ["X"]. And it's not for the first time it refuses to parse a line like:

 total_points = all_points.length;

even though the exact same line works in another patch parsing the same structure data. (so I've used the structure count patch and pull it in ;) )

But this really gets me, as a way of debugging I'm logging some point co-ords (X,Y,Z) as __numbers out of the patch.

If I literally assign them as in result.X = 0.123 no worries but if I use the incredibly complicated code of

var x1 = new Number();
x1 = 2 + 3;
result.X = x1;

I get told Argument X: Incorrect type, should be a number ( :\ x100 )

If anybody can explain this to me I'd be enormously grateful. Shutting down in frustration.

Cheers Alastair