Canvas tp display audio waveform
- From: Ezra <zramix@g*oogle*mail.com>
- Date: Thu, 20 Oct 2005 00:37:05 GMT
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
.
- Follow-Ups:
- Re: Canvas tp display audio waveform
- From: Joe Strout
- Re: Canvas tp display audio waveform
- Prev by Date: Re: Newbiestuff
- Next by Date: Finder Style Listbox
- Previous by thread: Newbiestuff
- Next by thread: Re: Canvas tp display audio waveform
- Index(es):
Relevant Pages
|