[Portaudio] calculating average and max peak - beginner confused

Peter Shaw unthoughted at googlemail.com
Sun Mar 18 05:47:23 EDT 2012


ok Alan,
so: val = -val is the same as val = val *-1.
( i took a coffee and get my brain to work.)

but why i got negative values in my average output, too?

Peter

2012/3/18 Alan Wolfe <alan.wolfe at gmail.com>

> The abs looks right to me.  Just flips the sign if its negative.
>
> Your alternative seems to alter the number, not just the sign.
>
> It's good you figured out the issue though (:
>
> On Mar 18, 2012 2:36 AM, "Peter Shaw" <unthoughted at googlemail.com> wrote:
>
> Hi,
> i found it... it was my previous problem that's already told. Frames vs.
> Bytes,
> so i changed my code to:
> for (i = 0; i < rawPipeInfo->numBytesOfBuffer; i++) {
> instead of:
> rawPipeInfo->framesPerBuffer
>
> So i got a various range of numbers now.
>
> In the examples i found a ABS calculating:
> if (val < 0) {
>      val = -val; /* ABS */
>  }
> on (http://portaudio.com/docs/v19-doxydocs/paex__record_8c_source.html)
> but shouldn't it be:
> val *= -val
> to turn around the sign?
>
> Best regards,
> Peter.
>
>
>
>
> 2012/3/18 Peter Shaw <unthoughted at googlemail.com>
> >
> > Hi all,
> >
> > i am trying to get the average...
>
>
> _______________________________________________
> Portaudio mailing list
> Portaudio at music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/portaudio
>
>
> _______________________________________________
> Portaudio mailing list
> Portaudio at music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/portaudio
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://music.columbia.edu/pipermail/portaudio/attachments/20120318/6976116a/attachment.html>


More information about the Portaudio mailing list