# Graphing Audio Samples

Started by July 14, 2006
```Hi guys,

When I graph individual audio samples what's the best way to zoom out ? I
can think of several methods but I'm not sure which will work best.

Say I am zoomed out to level 8, meaning for every eight samples I plot one
of them, I can simply ignore seven of them, I can average them, I can use
the maximum value, and so on.

What do you think ?

Thanks,
Robert A.

```
```Robert A. wrote:
> Hi guys,
>
> When I graph individual audio samples what's the best way to zoom out ? I
> can think of several methods but I'm not sure which will work best.
>
> Say I am zoomed out to level 8, meaning for every eight samples I plot one
> of them, I can simply ignore seven of them, I can average them, I can use
> the maximum value, and so on.
>
> What do you think ?
>
> Thanks,
> Robert A.

Robert,

If you mean that at zoom level 8 you only have one
horizontal pixel coordinate to represent 8 samples, then what
I would do is plot all 8 samples at that same
horizontal coordinate but using (possibly) multiple
vertical coordinates.  Averaging them, max value,
etc., loses information that you probably don't want
to lose.

--Randy

```
```"Robert A." <invalid@invalid.org> wrote in message
news:YzQtg.851\$F_6.335@fe12.lga...
> Hi guys,
>
> When I graph individual audio samples what's the best way to zoom out ? I
> can think of several methods but I'm not sure which will work best.
>
> Say I am zoomed out to level 8, meaning for every eight samples I plot one
> of them, I can simply ignore seven of them, I can average them, I can use
> the maximum value, and so on.
>
> What do you think ?
>
> Thanks,
> Robert A.

draw a vertical line from the min to the max of the y values works.

Also, if the previous x pixel's values don't fall within the current min-max
range then you can extend the current range until they do connect. That way
you get a continuous looking waveform. This is all pretty common practice in
graphical instruments (scopes, FFT analyzers, etc).

Bob

```
```Randy Yates wrote:
> Robert A. wrote:
>> Hi guys,
>>
>> When I graph individual audio samples what's the best way to zoom out ? I
>> can think of several methods but I'm not sure which will work best.
>>
>> Say I am zoomed out to level 8, meaning for every eight samples I plot one
>> of them, I can simply ignore seven of them, I can average them, I can use
>> the maximum value, and so on.
>>
>> What do you think ?
>>
>> Thanks,
>> Robert A.
>
> Robert,
>
> If you mean that at zoom level 8 you only have one
> horizontal pixel coordinate to represent 8 samples, then what
> I would do is plot all 8 samples at that same
> horizontal coordinate but using (possibly) multiple
> vertical coordinates.  Averaging them, max value,
> etc., loses information that you probably don't want
> to lose.

Information is lost in any case: sequence, with the way you describe.
Plotting both max and min can be useful but noise prone. I guess it
depends both on the data and on what the user wants to see.

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;
```
```I have two thoughts:

1) Use a vertical bar for each point indicating the min and max sample
value.  This way you will let the user know that your decimating and he
will be able to see min/max values.

[Probably most accurate representation]
2) Apply a FIR filter to the signal that will remove potential aliasing
images when you decimate. Example: if your decimating by 8 then design
a lowpass filter that has a stopband at 0.5*fs/8 where 0.5fs = Nyquest
of original signal.

Michael Kreeger

```
```Jerry Avins wrote:
> Randy Yates wrote:
> > Robert A. wrote:
> >> Hi guys,
> >>
> >> When I graph individual audio samples what's the best way to zoom out ? I
> >> can think of several methods but I'm not sure which will work best.
> >>
> >> Say I am zoomed out to level 8, meaning for every eight samples I plot one
> >> of them, I can simply ignore seven of them, I can average them, I can use
> >> the maximum value, and so on.
> >>
> >> What do you think ?
> >>
> >> Thanks,
> >> Robert A.
> >
> > Robert,
> >
> > If you mean that at zoom level 8 you only have one
> > horizontal pixel coordinate to represent 8 samples, then what
> > I would do is plot all 8 samples at that same
> > horizontal coordinate but using (possibly) multiple
> > vertical coordinates.  Averaging them, max value,
> > etc., loses information that you probably don't want
> > to lose.
>
> Information is lost in any case: sequence, with the way you describe.

Hi Jerry,

What you say is true - there MUST be some loss of information.
What I meant was that averaging and min/max lose information
that doesn't HAVE to be lost.

--Randy

```
```You lose a lot with a digital CRO.  Undersampled waveforms are a featureless
block of pixels.  If there are sufficient samples to the horizontal pixel,
it might be worth considering the use of color or brightness as pseudo
z-axis info.

When a 1MHz (fast) sine wave is displayed on an analog CRO which has its
horizontal scan rate set to (slow) 1 milliSecond/division, the resulting
solid envelope displayed has increasing brightness towards the top and
bottom of the envelope due to the increased "dwell time" of the electron
beam.

From this you can make inferences about the waveform's slope at different
voltages, even though you cannot examine the waveform directly.  I often
find these secondary effects to be informative.  You can detect the onset
of distortion in a complex waveform without having to twiddle the sweep
rate up & back again to look at the expanded waveform.

If some suitable parameter could be derived from the waveform and mapped to
the z1 brightness axis (and maybe z2 == color axis??), some of the analog
CRO subtlety and "feel" could be recaptured.

A first-glance suggestion might be to make the v-line brightness inversely
proportional to the difference between adjacent sample Y values to fake the
analog effect above.

After that, one might add the brightness of several overlapping v-lines
(grossly under-sampled cycles) at the one h-pixel position to simulate
multiple overlapped trace passes.  The traces should be augmented only in
the overlap zone.

Normal precautions like limiting z value ranges & divide by zero avoidance
would apply.

Suggestions invited.  They might get included in next years Tektronix if we
are smart enough.  So in ten years time when I can afford a new one it will
be nice to use.  Meantime we can all still use the feature in our
screen-plot graphics stuff.

Jim A.
```
```Robert A. wrote:
> Hi guys,
>
> When I graph individual audio samples what's the best way to zoom out ? I
> can think of several methods but I'm not sure which will work best.
>
> Say I am zoomed out to level 8, meaning for every eight samples I plot one
> of them, I can simply ignore seven of them, I can average them, I can use
> the maximum value, and so on.
>
> What do you think ?

Can you display grayscale?  If so, then 2d anti-alias.  Plot
a vertical strip, where the grayscale density of that strip
represents the local density of points per vertical bin when
you zoom out horizontally.  The vertical strip itself will
represent a gray mini-histogram of the compressed signal.
If you are limited in the depth of the grayscale, you can
also add dither, sort-of-halftoning the signal density.

If you can't display grayscale, then you can filter or
display statistics.  Averaging the points is a poor low
pass filter. Min & max are probably poorer statistics
than +s and -s std.deviations from the mean, unless the
peak deviations from the mean (or low pass downsample
point) is particularly informative in some way.

If you can display color, then you can do some combination
of the above, grayscale for signal density, one color for
the low pass filtered signal, anothers color for +-1,2,3
std.deviation or min-max envelope.

Dropping samples without suitable low-pass filtering will
just produce a view of an aliased signal.

IMHO. YMMV.
--
Ron N.
http://www.nicholson.com/rhn

```