On Mon, Jun 06, 2005 at 09:17:54AM +0000, vanDongen/Gilcher wrote:
  As I recently found out, this can be very messy :)
Indeed :-)
  The basic algorithm is this:
 Each horizontal pixel represents n samples. Usually n is pretty big.
 Of those n samples you take the min and the max, and then you draw a vertical
 line between them.
 Obviously this has to be scaled to your vertical resolution and vertically
 translated to the right position  on your canvas.
 If n<=1 you can choose to draw lines between the points, or just show the
 points. 
The most difficult situation is for n nearly equal to one.
But even this is not really correct if you want precision.
Consider an Fs/4 sine with samples -0.9 -0.9 +0.9 +0.9 -0.9 -0.9 +0.9 etc.
Now what is the (peak) amplitude of this sine ? Not 0.9, but something like
1.27. If you send this signal through a unity gain filter that produces 45
degrees of phase shift, you will get samples at +/- 1.27, and your DAC will
clip.
So even a simle digital peak meter requires interpolation of peaks to
be accurate. I don't know any in the linux world that do this.
--
FA