Forums > MaxMSP

using jit.matrix to delete samples from a buffer

April 3, 2009 | 7:00 pm

Hi all

I’ve read the thread about cropping a buffer which led me to the jit.matrix object. for the purpose of my patch i would rather not use any external objects.

is it possible to input data from a buffer (sample index and sample value) in to a jit.matrix, then perform a function on this (delete samples where there is silence) and then write this to another buffer?

I’ve had a look at the tutorials and help but I am confused by data types and how to write to the matrix


April 3, 2009 | 9:49 pm
Mike S wrote on Fri, 03 April 2009 14:00

is it possible to input data from a buffer (sample index and sample value) in to a jit.matrix, then perform a function on this (delete samples where there is silence) and then write this to another buffer?

Look to jit.buffer~. You can then do a comparison on the output (!=~ 0.) to see if the sample isn’t 0., and if not, write it to the next buffer~. Need to manage your index values though, since the second buffer indices will gradually drift smaller than the first (one less for each 0. sample you discard).

There’s a ton of interesting other manipulations you can do to it (jit.op, jit.xfade, mixing video with your sound??) by using matrices for your audio.


April 12, 2009 | 4:48 pm

I’m just concentrating on audio at the moment

Now I want to use the pitch of the incoming audio (via analyzer~) to separate the first buffer in to several smaller buffers (dynamic scripting, which fortunately i get) the idea would be to have a bit of data smoothing and a +/- 5Hz deviation that would define the next buffer, I also plan to remove the silence from the original buffer.

My problem now lies in how to store/retrieve the values. I have been using coll so far but I believe this has a limit of 256 entries which isn’t enough. At the moment I am looking at jit.matrix as a way of storing the time and corresponding pitch of the audio and also jit.fill to fill it.

I am a little unsure of how jit.matrix works. Essentially I want something that looks like this

time f0

0.1 60

0.2 63

and so on.

how many planes does this have? and what are the dimensions?


April 13, 2009 | 1:29 am
Mike S wrote on Sun, 12 April 2009 11:48
Now I want to use the pitch of the incoming audio (via analyzer~) to separate the first buffer in to several smaller buffers (dynamic scripting, which fortunately i get) the idea would be to have a bit of data smoothing and a +/- 5Hz deviation that would define the next buffer, I also plan to remove the silence from the original buffer.

My problem now lies in how to store/retrieve the values. I have been using coll so far but I believe this has a limit of 256 entries which isn’t enough. At the moment I am looking at jit.matrix as a way of storing the time and corresponding pitch of the audio and also jit.fill to fill it.

I am a little unsure of how jit.matrix works. Essentially I want something that looks like this

time f0

0.1 60

0.2 63

and so on.

how many planes does this have? and what are the dimensions?

Lots of possibilities, for this you could even use a table or multislider. I think [coll] has a lot more than 256, not sure… on max 5 it definitely does. jit.cellblock will also let you see the numbers right there, but is more unwieldy than using a multislider or matrix–>pwindow.

In one sense, you could just use the buffer~ itself (or another one) to store, using peek~ to access/write. But to use the matrix operations you’d need jit.matrix. The dimensions would depend on the overall number of buffer samples—I’d just use one plane (where the index is time) and store the pitch data as the values in it. You’d want to scale the time and pitch information, probably, to make it match the jit.matrix type (use float32 unless you can get away with 0-255 char type).


April 13, 2009 | 1:57 am

if you’re on 5, try this simple patch for using the matrix (filling with random values or reading from a buffer~)…

The key element is the jit.matrix, which I made as:

jit.matrix [name] 1 float32 1024

This would give a one-plane, floating-point matrix with 1024 data points, called "name". Read out your buffer~ values with peek~ and store them with "setcell $1 val $2". Also jit.buffer~ could save some effort too.

Note I had to use setcell $2 val $1, since the values in the [pack] come in flipped (index into inlet 2, then value into inlet 1 to output).

– Pasted Max Patch, click to expand. –

April 13, 2009 | 2:02 pm

thanks seejay, i’ll let you know how i get on Smile

seems coll now accepts a much larger amount


Viewing 6 posts - 1 through 6 (of 6 total)