Thanks for the info Erick, but i am still confused on how to display and .mp3 and .wav file. I utilized the following example provided b steeley an refined it a little bit and also so that it can work in my example.The code beneath I placed in a action event of the button control:
dim f as folderitem dim dlg as openDialog dim i,p, maxL,minL,divs,position,frameSize as integer dim L,R,sLen,H,leftY,rightY as integer dim t as double dim pic as picture dim readFile as BinaryStream dim mem as MemoryBlock dlg = new openDialog dlg.filter="audio" f = dlg.ShowModal if f<> nil then readFile=f.OpenAsBinaryFile mus = f.OpenAsFMExStream EditField1.Text = f.DisplayName durST2.Text = Format(mus.Duration/60/1000, "##.00") GetSampleInfor(mus) rateSlider1.Value = 1000 minL=255 sLen=f.length H=canvas1.Height divs=512/H leftY= (H/2)-16+leftY //reset 3d space pic=newpicture(canvas1.width,canvas1.height,16) pic.graphics.forecolor=RGB(240,240,240) pic.graphics.fillrect (0,0,pic.width,pic.height) pic.graphics.forecolor=RGB(100,100,250) pic.Transparent=1 frameSize=(slen)/(canvas1.width*4) //frameSize=8 for i = 0 to slen step 4 readFile.Position=i if p>frameSize then //left channel maxL=(H-(1+(maxL/divs)))-16 minL=(H-(1+(minL/divs)))-16 pic.graphics.drawline position,leftY,position,maxL pic.graphics.drawline position,leftY,position,minL position=position+1 //reset count p=0 maxL=0 minL=255 end if L=readFile.ReadByte if L <128 then L=L+255 end if if L>maxL then maxL=L end if if L< minL then minL=L end if readfile.position=readFile.position+1 p=p+1 next i canvas1.backdrop=pic readFile.Close end if ----- Original Message ----- From: "E. Tejkowski" <[EMAIL PROTECTED]> To: "REALbasic NUG" <[email protected]> Sent: Sunday, August 13, 2006 1:40 AM Subject: Re: How to dsiplay a waveform in a canvas control > On Aug 12, 2006, at 4:15 AM, Ayden wrote: > > > Eric Thanks for the reply and the crash course in wave dynamics. > > You have > > written some interresting information that has confused me a > > little...i.e > > the 16 bit WAV ... > > Look at these two sites to see how AIFF stores samples versus how > WAVE does it: > > http://www.borg.com/~jglatt/tech/aiff.htm > > http://www.borg.com/~jglatt/tech/wave.htm > > About the link someone posted earlier: > > http://realbasic.thezaz.com/Athenaeum/View.php?entry=36 > > That example uses QuickTime to extract data from a sound track and > packs it up into an 8 bit memoryblock. Then you can iterate through > that memblock to draw the wave. 8 bit is often sufficient for many > waveform drawing tasks. Mind you, the audio won't play back at 8 bit > necessarily. It's just a useflul trick to extract the data you need > and present it to you in a nice neat package for drawing. It also has > the benefit of working with a variety of sound formats (AIFF, WAV, > MOV, MP3, MP4, AU, etc) without you having to parse anything. The > downside for Linux (and possibly for Window's users) is that it > requires a QuickTime installation. The AIFF and WAVE links are for > doing the parsing of files yourself. The benefit is it that will work > on all platforms, but it requires more work. > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > > Search the archives of this list here: > <http://support.realsoftware.com/listarchives/lists.html> > > _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
