Xenakis' Sieves with JavaScript

thrly's icon

So I'm trying to learn about JavaScript and using it in Max, but I'm still at real early stages working with code. I've tried to write a little script that generates elementary Sieves (see Iannis Xenakis & Christopher Ariza). Like I say, its a real rudimentary (and yeah, its probably easier to combine the residual classes using Max [zl] processes, but this is a learning exercise for [js]) so don't expect the full complement of sieve handling methods that people like Ariza have done.

I'm encountering a bit of a weird problem getting the segment to work starting from a negative number. I'm thinking that its because the Sieves should start at 0 and run simultaneously in either direction 'infinitely' - the segment should just be a frame, but maybe i'm using it as a point of initialised?

I've only been learning JavaScript for about 2 weeks through codeAcademy.com - and then only just looked at using [js] to implement it through Max - so I'm assuming there will be some real basic errors?

Max Patch
Copy patch and select New From Clipboard in Max.

If anyone could take a look and give me some pointers on areas for improvement, it'd be really appreciated!

4280.sieves.js
js
Lume's icon

I doubt I can help, but you probably should use the "4280.sieves.js" file name in the js object.
The copy-compressed patch is fine, just don't know how to hook it all up!