Results 1 to 7 of 7

Thread: Code for drawing Audio wav on Canvas

  1. #1
    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.

  2. #2
    Join Date
    May 2009
    Posts
    511

    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)

  3. #3
    Join Date
    May 2009
    Posts
    527

    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

  4. #4
    Join Date
    Apr 2009
    Posts
    488

    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

  5. #5
    Join Date
    May 2009
    Posts
    539

    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.

  6. #6
    Join Date
    Apr 2009
    Posts
    569

    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

  7. #7
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,894,542.70963 seconds with 17 queries