Implementing a 1D difference equation in Jitter


    Jun 01 2007 | 7:48 pm
    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?

    • Jun 01 2007 | 7:55 pm
      >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
    • Jun 01 2007 | 8:01 pm
      Hi Aaron,
      You should have a look at the jit.convolve object. This kind of stuff should be fairly straightforward to do.
    • Jun 01 2007 | 8:12 pm
      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
    • Jun 01 2007 | 8:15 pm
      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
    • Jun 01 2007 | 8:28 pm
      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 >
    • Jun 02 2007 | 1:50 am
      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.