```BobG wrote:
> Mark:
> You could take the absolute value of each sample first and then sum
> them or you could square each sample then sum them.  Or you could use a
>
> Hilbert transformer.
> ===================
> What I want is db of |vout|/|vin|, so abs val makes sense, but not
> squaring. Lets say I have 4 volts out and 2 volts in. Thats 6db gain.
> If I square em, thats 16V out and 4V in... 12db.... makes no sense to
> me. Is the db of the square the same as the square of the db?

The way you plan to do it gives the ratio of instantaneous values,
That's not a frequency response. Say v_in = V_in*A*cos(wt) and
v_out = V_out*B*cos(wt+phi). the v's are instantaneous values and the Vs
are amplitudes. The frequency response is V_in/V_out, = B/A;angle -phi.
the amplitude response is B/A and the phase response is - phi.

What do you plan to do with the ratio of instantaneous values? Internal
filter delay plays no role in frequency response.

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```
```
BobG wrote:
> Mark:
> You could take the absolute value of each sample first and then sum
> them or you could square each sample then sum them.  Or you could use a
>
> Hilbert transformer.
> ===================
> What I want is db of |vout|/|vin|, so abs val makes sense, but not
> squaring. Lets say I have 4 volts out and 2 volts in. Thats 6db gain.
> If I square em, thats 16V out and 4V in... 12db.... makes no sense to
> me. Is the db of the square the same as the square of the db?

dB = 20 * log (V1/V2)
where V1 and V2 are voltages

or

dB = 10 * log (P1/P2)
where P1 and P2 are powers

you could do it either way.

If you use absolute value you are working with voltages and need to use
20*log (V1/V2).

If you use squareing, you are working with powers and need to use
10*log (P1/P2).

Hope this helps.

Mark

```
```Mark:
You could take the absolute value of each sample first and then sum
them or you could square each sample then sum them.  Or you could use a

Hilbert transformer.
===================
What I want is db of |vout|/|vin|, so abs val makes sense, but not
squaring. Lets say I have 4 volts out and 2 volts in. Thats 6db gain.
If I square em, thats 16V out and 4V in... 12db.... makes no sense to
me. Is the db of the square the same as the square of the db?

```
```
BobG wrote:
> My filter is a 'simulation' of an opamp filter. I guess the DSP types
> call this an IIR filter?  So I guess all my input samples are 'real'
> since they came from an a/d converter. I can only imagine where the
> imaginary samples are supposed to come from. Never understood negative
> frequency either. And why square em? I'm not interested in the power am
> I? Just the voltage I thought. Very confusing.

For an ordinary AC sine wave the voltage oscillates above and below
zero so if you sum all the voltage samples they will average out close
to zero becasue this represents the DC value of the sine wave.

You could take the absolute value of each sample first and then sum
them or you could square each sample then sum them.  Or you could use a
Hilbert transformer.

Mark

```
```My filter is a 'simulation' of an opamp filter. I guess the DSP types
call this an IIR filter?  So I guess all my input samples are 'real'
since they came from an a/d converter. I can only imagine where the
imaginary samples are supposed to come from. Never understood negative
frequency either. And why square em? I'm not interested in the power am
I? Just the voltage I thought. Very confusing.

```
```
Mike Yarwood wrote:
> "BobG" <bobgardner@aol.com> wrote in message
> > Trying to make an octave band analyzer by computing a BP filter,
> > running all the input samples thru it, and summing all the output
> > samples, recompute filter and repeat for N frequencies. I suspect there
> > is something wrong with getting output ampl by summing all the samples.
> > How do smart people solve this problem??
> >
> I don't know how the smart people do it but a band pass filter ought to have
> no DC component and has to put out several samples per cycle of the center
> frequency so I suspect you are getting values fairly close to zero.
>
> You could maybe try squaring your samples before summing them?
>
> Best of luck - Mike

Depending on the application, you might want to run the signals through

an envelope detector befor squaring and summing. It's basically a
quadrature sampling step followed by a sqrt(I^2 + Q^2) step, where
'I' is the in-phase component and 'Q' is the quadrature component.

Rune

```
```"BobG" <bobgardner@aol.com> wrote in message
> Trying to make an octave band analyzer by computing a BP filter,
> running all the input samples thru it, and summing all the output
> samples, recompute filter and repeat for N frequencies. I suspect there
> is something wrong with getting output ampl by summing all the samples.
> How do smart people solve this problem??
>
I don't know how the smart people do it but a band pass filter ought to have
no DC component and has to put out several samples per cycle of the center
frequency so I suspect you are getting values fairly close to zero.

You could maybe try squaring your samples before summing them?

Best of luck - Mike

```
```Trying to make an octave band analyzer by computing a BP filter,