Canvas tp display audio waveform



I've had limited success displaying the audio waveform of a 16 bit
48kHz mono .wav file in a Canvas using vertical lines, because it's
simple and I don't know how to draw points and connect them with lines.
Neither do I know how to draw sine waves.

In a window with a pushbutton, a listbox and a canvas on it I use this
code in the pushbutton.

Sub Action()
dim I, value, average As integer
dim f As FolderItem
dim b As BinaryStream
dim m As EditableMovie
ListBox1.DeleteAllRows
Canvas1.Graphics.ClearRect 0,0, Canvas1.Width, Canvas1.Height
f= GetOpenFolderItem("special/any")
if f<>nil then

b = f.OpenAsBinaryFile(false)
if b <> nil then
average = b.Length/Canvas1.width
for I = 0 to Canvas1.width
b.LittleEndian =true
value =b.Readlong + b.Readlong // Read 16 bits?

////get it down to some values between -128 & + 128
value= value/65536.0
value = value/255

ListBox1.AddRow Str(value)
Canvas1.Graphics.DrawLine i,0,i ,value
b.Position = b.Position + average // jump forward
next
end if
end if
b.close
End Sub

It sort of works but mostly it's not too good. My questions are, how
can I draw it so that it looks like a real waveform with positive and
negative peaks radiating out vertically from a center line? the
negative valies that I encounter just subtract from the the y1 starting
point.

The other thing is I get a bunch of random spikes, am I just
interpreting the data wrong? Plus the resolution isn't very good.

I welcome any advice or comments.
Thanks
.



Relevant Pages

  • RE: TreeView multiple selections
    ... But with this behavior I can't draw a node to normal after selecting twice ... .Net2.0 has added the build-in support for custom-draw. ... rectangle based on your requirement. ... Dim focusPen As New Pen ...
    (microsoft.public.dotnet.general)
  • Re: Horizontal lines
    ... horizontal line at the bottom of the bottom control in a detail section of a ... subreport, add code to the On Print event of the section. ... Dim intBottom As Integer ... > draw a horizontal line for my subreport, no vertical lines involved, ...
    (microsoft.public.access.reports)
  • Re: Horizontal lines
    ... Now I'm trying to draw a horizontal line in code. ... rectangle "separating" the opportunities, ... Dim intPageHeadHeight As Integer ... >> Dim intPageHeadHeight As Integer ...
    (microsoft.public.access.reports)
  • Re: Horizontal lines
    ... to draw vertical lines at the intLeft position. ... > Dim intPageHeadHeight As Integer ... >>> Dim intPageHeadHeight As Integer ...
    (microsoft.public.access.reports)
  • Re: Owner Draw
    ... Like all other objects I'd say create it once, in OnPaint clear and draw to ... Dim itemsPerPage As Integer ... scroll As Integer, ByVal index As Integer) ... ' Rectangle for bird name ...
    (microsoft.public.dotnet.framework.compactframework)