Site menu:

Latest news:

Current Time:

Relevant links:

Sub Catagory: VB
Comment: The codeproject is an excellent website for finding programming resources and articles. Although I have put it under VB as a sub-catagory, the site in fact has resources for nearly all of the main programming languages.
DATE ADDED: 2006-11-29
Sub Catagory: VB
Comment: This site was quite usefull for me two years ago when I wrote my WAV render control (the control is a development of the VB6 version found at this site) but it seems that I has not been updated recently. However it still has some good resources for VB programming.
DATE ADDED: 2006-11-29

Page Updated:

( 14-Sep-2009 )

Valid CSS! Valid XHTML 1.0 Transitional

WAV file graphical viewer control for VB.NET

As part of the work I was doing in 2004 I felt it would be usefull to be able to display the audio wave form from a WAV file. Although there were a few resources on the web, either they were not free or they were designed using Visual Basic 6. The following outlines my own control that I developed in VB.NET (version 1.1 of .Net but I assume it works ok in version 2). The code can also be found at the Codeproject site but I will be updating the information here more regularly. The control is a update from the VB6 solution from VBaccelerator and also uses an extended version of the WaveFile class writen by the KPD-Team. I will be updating this control as soon as I have time.

Download the control and test application

The operation of the control is to provide a visual representation of both channels of a 16-bit PCM wav file, with variable zoom. (Future versions will hopefully support other bit sizes as well.) The full list of features is as follows:

# It will always have a result of 2 due to limitations of this version and will be more useful in later versions that will have support for mono wav files.

The project files provided along with this article include both the control code and a test application. It should be possible for most of you to follow how the code works, but here is a small guide:

  1. The control is set to default values when first inserted into the host application.
  2. The format for background and lines is determined by using the RenderWave sub.
  3. Main_Paint sub takes the information and displays the lines. Changes to any properties causes Renderwave to be called again and in turn Main_Paint.
  4. The file name is passed to the control from the host app using <name>.WaveFile=.
  5. This is passed to the WaveFile class where the file headers are stripped out and checked, make sure that the file is a valid wav file.
  6. The class sets up a data buffer, returns to the main control code.
  7. RenderWave is again called.
  8. If thread support has been enabled, the function WaveInfo is called via thread calls, otherwise it is called as a normal function. Either method triggers the RenderStart event.
  9. WaveInfo starts to read data from the wav file in blocks equal to the buffer length (0.1s).
  10. The number of samples plotted per block depends on the zoom factor.
  11. If you are using threading, RenderWave will finish. The callback function will cause Main_Paint to update once the data has been collected. Otherwise Renderwave will continue after the WaveInfo function has finished and in turn will call Main_Paint.
  12. Changing the zoom or moving the scroll bar will start the functions again.

The project, although useful in its own right, might also be useful for people wishing to learn more about: