Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 26-07-2011
Member
 
Join Date: Jun 2011
Posts: 84
Code for drawing Audio wav on Canvas

Since few days I have been trying to draw wave using code in Canvas. I want the wave look similar to the wave that we see in an audio editor. For it I have done researches over the internet also tried two different plug-in. The plug- in that I have used are MBS audio and MBS QTime. If you just have a look at the plug-in area, I also tried the code for WEB look including dissecting the audio recording one MBS audio.
Reply With Quote
  #2  
Old 26-07-2011
Member
 
Join Date: May 2009
Posts: 503
Re: Code for drawing Audio wav on Canvas

I have found the below example in on the internet. I hope it will help you with some reference.

First ADD a canvas, a pushbutton and a listbox to your window.
put this in the pushbutton

Code:
dim I, value, average as integer
dim f as folderItem
dim b as binaryStream

listBox1.deleteAllRows
canvas1.graphics.clearRect 0, 0, canvas1.width, canvas1.height

f=GetOPenFolderItem("special/any")


if f <> nil then
b=f.OpenAsBinaryFile(false)
Reply With Quote
  #3  
Old 26-07-2011
Member
 
Join Date: May 2009
Posts: 523
Re: Code for drawing Audio wav on Canvas

The below code will read 16 bit files. However, the image is drawn does not really look anything like the waveform that we've all come to expect. See the below:

Code:
if b <> nil then
average = b.length/canvas1.width
for I = 0 to (canvas1.width)
b.littleEndian=true
value=b.readlong+b.readlong
value=value/65536.0
value=value/256*canvas1.height/2
value=value/canvas1.height
listBox1.addrow str(value)
canvas1.graphics.drawline i, canvas1.height/2, i, value+canvas1.height/2
b.position = b.position + average

next
end if
end if

b.close
Reply With Quote
  #4  
Old 26-07-2011
Member
 
Join Date: Apr 2009
Posts: 484
Re: Code for drawing Audio wav on Canvas

Considering the math to get the
Assuming the math to get "value" is correct, you can follow the previous value to get a distinctive waveform:
Code:
Code:
lastValue = canvas1.width/2
average = b.length/canvas1.width
for I = 0 to (canvas1.width)
  b.littleEndian=true
  value=b.readlong+b.readlong
  value=value/65536.0
  value=value/256*canvas1.height/2
  value=value/canvas1.height
  listBox1.addrow str(value)
  canvas1.graphics.drawline i, lastValue, i, value+canvas1.height/2
  lastValue = value+canvas1.height/2
  b.position = b.position + average
next
Reply With Quote
  #5  
Old 26-07-2011
Member
 
Join Date: May 2009
Posts: 532
Re: Code for drawing Audio wav on Canvas

Legitimate wave-I ran into it before-it works well enough on the mac (separated from then open key getting the center and pressing space could reactivate the open pushbutton as opposed to playing it). It doesn't work truly well on windows whatsoever. It worked perhaps 2 out of the 40 times I ran it and it could collision regularly. In this way, its somewhat useless as a cross stage explanation for drawing a wave plan.
Reply With Quote
  #6  
Old 26-07-2011
Member
 
Join Date: Apr 2009
Posts: 567
Re: Code for drawing Audio wav on Canvas

There is no real way to change the window height and width of waves and it's all encapsulated within the class itself wave canvas.

Code:
b.littleEndian=true
value=b.readlong+b.readlong
value=value/65536.0
value=value/256*canvas1.height/2
value=value/canvas1.height
listBox1.addrow str(value)
canvas1.graphics.drawline i, canvas1.height/2, i, value+canvas1.height/2
b.position = b.position + average
Reply With Quote
  #7  
Old 27-07-2011
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: Code for drawing Audio wav on Canvas

The save and restore function in the context of an easy way to apply these cumulative effects, draw a picture or web form that has applied these effects, and then "undo" the changes. Behind the scenes of the save function pushes the current state of drawing in a pile, while the restore function appears in the latest state of the stack. Hope my information helps you and your query gets solved.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Code for drawing Audio wav on Canvas"
Thread Thread Starter Forum Replies Last Post
Canvas HD A116 vs Canvas 2 A110 vs Infinity A80 Rajminder Polls & Voting 4 29-03-2013 01:05 PM
Cannot align objects in a drawing canvas in office 2010 archer Windows Software 9 04-08-2011 10:46 AM
Code 39 Sigma Tel HD Audio Codec WBA629 Windows XP Support 1 23-04-2011 06:22 PM
Need help! Hd audio code 10 Albert Abdullayev Hardware Peripherals 2 04-01-2010 12:46 PM
code 39, no audio devices nipadweller Windows Software 4 07-07-2009 09:41 PM


All times are GMT +5.5. The time now is 04:38 PM.