Hi there!
At first, I'd like to introduce myself here a bit:
I'm from Germany (please excuse propably bad English sometimes), and I'm about fininishing my studying in electronics engineering.
I use PureData for a while when working in the lower-frequency area because it's very handy when 'just trying xyz' without writing three hours the routines for accessing the soundcard et cetera.
Well, currently I want to meassure the energy of noise over a given time, e.g. 2 minutes.
What I thought was, using the formula
E = sum of v^2[k] to N values + 1/N * sum of v[k] = Sigma^2 + µ^2.
The left part should be fairly easy, using the expr~ and pow-expression (my thoughts, theoretically, nothing tried yet!).
But I started to think about the second part.
To be honest, to answer my question by myself, I thought it may be a good idea to take a look at the source code of tavg~, but I'm pretty sure I missunderstand something here:
Do I understand things right, that tavg~ takes the average of 'just' the last 4 values, doesn't it?
Or do you know any other way for getting the average of a signal for a longer time?
Thanks in advance
 // Cut out of tavg~.c
static void tavg_bang(t_tavgtilde *x)
{
  if (x->blocks) {
    t_float result=x->buf*x->n_inv/x->blocks;
    outlet_float(x->x_obj.ob_outlet, result);
    x->blocks = 0;
    x->buf = 0.;
  }
}
static t_int *tavg_perform(t_int *w)
{
  t_sample *in = (t_sample *)(w[1]);
  t_tavgtilde *x = (t_tavgtilde *)w[2];
  int n = (int)(w[3]);
  t_sample buf = x->buf;
  while (n--) buf += *in++;
  x->buf = buf;
  x->blocks++;
  return (w+4);
}