Dynamic plane separation in Jit.gen
Hello,
I'm working on a kind of spectrum visualiser. I'm using a multichannel FFT to get a range of signals at each frequency bin and display them in a kind of wave table form. In the jit.gen patch I had to separate each plane of the input matrix using the swiz operator but I'd like to be able to do this dynamically so I can use FFT's with higher resolutions without needing to add a bunch more swiz operators.
I tried using javascript but it slows down the render rate too much. Can it be done at all?
Thanks in advance!
You cannot do script-patching in the gen/pix objects, but I don't think you need to.
See this post to learn how to flatten a multiplane matrix to less planes, and then you would be able to access the value from each plane using [cell] and [%] (modulo).
Also, friendly reminder to use copy compressed to share patchers here!
My bad, I forgot to copy compressed!
I've flattened the matrix and I can use the modulo operator to determine where each plane is represented in my input matrix but I'm stuck on how to access the value. How can I assign each column to the correct row so that each plane is represented on it's on row?
To be fair I don't really understand the first part of your patch (how/why using fft+ifft in this way, and why going from 16 channels to a 8 planes jit.catch~) but I doubt coercing to a 3-planes matrix helps here, because then you have your frequency bands spread across the X dimension and through planes (if I understand things correctly), which doesn't really help to reconstruct lines as you want.
I would instead entirely flatten the matrix to 1 plane and do some transformation so that every values of one plane from the original matrix is spread across one row on one plane on the final matrix.
I started with a 4 planes 3x3 matrix filled with single values from 0 to 35 (to help me keep track of things), and ended up with a 1 plane 9x4 matrix, that I can then easily extend to 3 planes for vertex positioning:
I applied the same thing to your patch, going from a 8 planes 128x8 matrix to a 3 planes 1024x8 and got this:
Not sure if it's the intended result but it seems to work!
And not sure if it the correct way to do this math, I feel like there would be much more straightforward way to achieve the same result, but my brain hurts when manipulating matrices across dimensions so that's the best I can do for now :)
The fft is so I can separate each frequency bin into independent channels and then transform the multichannel signal back to time domain with the mc.ifft. The minimum fft size allowed is 16 bins but the jit.gl.mesh object can't accept more than 12 planes (or maybe 13 I cant remember) so I only use jit.catch on 8 of the planes.
If I manage to flatten them correctly then I don't have to worry about plane count and can send a single plane matrix to the position input of the mesh object which has each signal represented on it's own row.
I coerced to a 3 plane matrix so that I could get the normalised x and y coordinates to make the grid.
Thank you the patches you shared have done the trick!