Implementing a 1D difference equation in Jitter

Jun 1, 2007 at 7:48pm

Implementing a 1D difference equation in Jitter

Is there a simple way to implement difference equations with feedback in Jitter such as:

y[n] = (1/2)*(y[n-1]+x[n])

where y[n] is the output, and x[n] is the input.

I’ve been able to implement such using jit.iter and a math patch, but I can’t find a way to put the data back into a jitter matrix without a large CPU hit. Right now I’m using setcell commands to fill a matrix and it takes 10x more CPU than the filter itself!

Here’s my processing chain broken down:

input->jit.iter->difference equation patch->jit.matrix setcell commands->jit.graph

What can I do to get rid of the CPU hit from all the setcell commands?

#32232
Jun 1, 2007 at 7:55pm

>Is there a simple way to implement difference equations with
>feedback in Jitter such as:
>
>y[n] = (1/2)*(y[n-1]+x[n])
>
>where y[n] is the output, and x[n] is the input.
>
>I’ve been able to implement such using jit.iter and a math patch,
>but I can’t find a way to put the data back into a jitter matrix
>without a large CPU hit. Right now I’m using setcell commands to
>fill a matrix and it takes 10x more CPU than the filter itself!
>
>Here’s my processing chain broken down:
>
>input->jit.iter->difference equation patch->jit.matrix setcell
>commands->jit.graph
>
What can I do to get rid of the CPU hit from all the setcell commands?

Java inside one of those mxj objects would be a good choice there, perhaps.


on the floor there’s a long wooden table/on the table there’s an open book/
on the page there’s a detailed drawing/and on the drawing is the name I took
Gregory Taylor http://www.rtqe.net

#105644
Jun 1, 2007 at 8:01pm

Hi Aaron,

You should have a look at the jit.convolve object. This kind of stuff
should be fairly straightforward to do.

#P outlet 14 193 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 179 57 48 196617 loadbang;
#P message 179 79 52 196617 0.5 0.5 0;
#P newex 179 98 68 196617 jit.fill kernel;
#P newex 179 120 140 196617 jit.matrix kernel 1 float32 3;
#P inlet 14 108 15 0;
#P newex 14 146 175 196617 jit.convolve @origin 1 0 @in2_dim 3;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 0 1;
#P connect 0 0 6 0;
#P connect 1 0 0 0;
#P connect 5 0 4 0;
#P window clipboard copycount 7;

#105645
Jun 1, 2007 at 8:12pm

On Jun 1, 2007, at 12:48 PM, Aaron Faulstich wrote:

> Is there a simple way to implement difference equations with feedback
> in Jitter such as:
>
> y[n] = (1/2)*(y[n-1]+x[n])
>
> where y[n] is the output, and x[n] is the input.

Sounds similar to jit.slide or jit.scanslide depending on whether
you’re filtering in time or in space, respectively. Use a slide factor
of 2 to get the above formula from: y(n) = y(n-1) + ((x(n) –
y(n-1))/slide)

But otherwise, if these or other objects aren’t suitable for your
purposes, as Gregory mentioned, Java would work well (but don’t use
setcell/getcell. grab and set as an entire array, as the Jitter java
examples illustrate).

-Joshua

#105646
Jun 1, 2007 at 8:15pm

On Jun 1, 2007, at 1:01 PM, andrew benson wrote:

> You should have a look at the jit.convolve object.

Convolution is an FIR. Aaron wants an IIR, spatially I presume. Yet
another way to do this, might be to use jit.peek~/jit.poke~ passed
through biquad~ (to apply Andrew’s other setcell/getcell suggestion to
this problem).

-Joshua

#105647
Jun 1, 2007 at 8:28pm

Ah yes, I see.
Then yes, jit.scanslide would probably work best.

AB

> Convolution is an FIR. Aaron wants an IIR, spatially I presume. Yet
> another way to do this, might be to use jit.peek~/jit.poke~ passed
> through biquad~ (to apply Andrew’s other setcell/getcell suggestion to
> this problem).
>
> -Joshua
>

#105648
Jun 2, 2007 at 1:50am

Wow, thanks for all the input everyone, it’s a lot more than I expected!

I didn’t realize the scanslide object used an IIR equation, so that’s good to know. I tried it out and the CPU use actually went a little higher, but it might come in handy later.

I *really* need to sit down and get a grasp on Java and mxj, but I haven’t had time yet. I’ll keep that in mind.

I originally thought not to use jit.convolve because of the IIR nature of using feedback vs. FIR convolution, but I’m going to try making some truncated impulse responses from the difference equation and see how well that works.

Again, thanks for all the responses.

#105649

You must be logged in to reply to this topic.