On Jan 18, 2008 11:48 AM, Matteo Sisti Sette <[EMAIL PROTECTED]> wrote: > Also, I may be missing something, but I think your attached patch only > calculates the product and sum of the LAST TWO bins. Note you use > [fexpr~ $x[0]+$x[-1]] and [fexpr~ $x[0]*$x[-1]] > where I would use: > [fexpr~ $x[0]+$y[-1]] and [fexpr~ $x[0]*$y[-1]]
I don't really know what you two are talking about, but I know what this means. > [fexpr~ $x[0]+$x[-1]] and [fexpr~ $x[0]*$x[-1]] evaluates on every pair of samples. You get an output vector that looks like: (x[0]+x[-1], x[1]+x[0], x[2]+x[1], ... , x[N-1] + x[N-2] ) or (x[0]*x[-1], x[1]*x[0], x[2]*x[1], ... , x[N-1] * x[N-2] ) Whereas, > [fexpr~ $x[0]+$y[-1]] and [fexpr~ $x[0]*$y[-1]] is an accumulator!!! It will just keep growing and growing. Consider the equations in the following way: [fexpr~ $x[0]+$y[-1]] means y[n] = y[n-1] + x[n] for all n you can expand this by substitution: y[n] = y[n-2] + x[n-1] + x[n] y[n] = y[n-3] + x[n-2] + x[n-1] + x[n] and so on.... suppose we add up terms between arbitrary indexes a and b (could be more than one block) y[b]=sum( i = a to b, x[i]) + y[a] likewise [fexpr~ $x[0]*$x[-1]] means y[n] = y[n-1]*x[n] y[b]=product( i = a to b, x[i]) * y[a] if y is ever zero, it will always be zero after that...so, to use this, you would have to seed the values of y using the set y1 command. I always check this bookmark for reference because I need it all the time! http://crca.ucsd.edu/~syadegar/expr.html Chuck _______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
