Waveform drawing

Hi,

I want to make a waveform drawing panel. If i use a zoomed out look of the wave it doesn't seems to be the correct output like audio editors use. If the wave is zoomed out , for example, i paint every eighth point from the samples a line to the next eighth point.

How do audio editor paint the waveform, is there an algorithm?

Thank you,

Thomas

[388 byte] By [tazze] at [2007-9-30 11:45:54]
# 1
I suspect they simply scale the points before drawing. Note that Graphics2D operates in doubles.
YATArchivist at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...
# 2
Ok, then I have to make a Graphics2D object, draw all points in the object and then use the scale funktion from g2d. Right?I think it will be a bit slow but i will try.
tazze at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...
# 3

The problem with drawing only 1 in 8 points is that you are

crudely downsampling your data. It is quite possible that you will

miss the high and low points in each 8 point region.

One solution is to alternatley display the highest of the 8 points,

then the lowest. Repeat. More comlpex techniques are possible

but unless you do something like this the overall effect would

appear to reduce the amplitude of the waveform. (not strictly the

case but it would probably look like this was happening.

(depends on the actual data of course)).

matfud

matfud at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...
# 4

>The problem with drawing only 1 in 8 points is that you are

>crudely downsampling your data. It is quite possible that you will

>miss the high and low points in each 8 point region.

That must be the reason why the wave looks wrong. I read that bevor downsampling you have to filter the

signal with a low pass filter. May be that is a good solution.

>One solution is to alternatley display the highest of the 8 points,

>then the lowest. Repeat. More comlpex techniques are possible

>but unless you do something like this the overall effect would

>appear to reduce the amplitude of the waveform. (not strictly the

>case but it would probably look like this was happening.

>(depends on the actual data of course)).

The data i want to display are audio waveforms. It seems to be an easy solution. May be I can prevent the

problem with the amplitude when I collect the highest and the lowest points representing one point on the

x-axis and draw a line between them.

Thank you for your hints

tazze at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...
# 5

The problem with using a downsampling filter (a low-pass filter)

is that it remove the high frequencies. This has a similar effect

to just grabbing 1 point in 8. (in fact the attenuation may be far

more pronounced then simply taking 1 in 8 points).

The concept of grabbing the highest then the lowest is also crude

but does give a better visual indication of the amplitude of the

waveform.

Remeber that most wave viwers are not trying to accurately

represent the data, instead they are trying to give the user an

idea of the amplitude. They are also trying to give an idea of the

shape of the wave (but to a lesser extent)

Although as I said in an earlier post the must be better ways

of achieving this then the solution I proposed (which is crude

in the extreme).

matfud

matfud at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...
# 6
>Although as I said in an earlier post the must be better ways>of achieving this then the solution I proposed (which is crude>in the extreme).Correct me if i understood it wrong. You think there are better solutions I should search for.Thanks.
tazze at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...
# 7
I'm not sure but it is likely that there are better solutions out there. matfud
matfud at 2007-7-4 13:19:20 > top of Java-index,Other Topics,Algorithms...