Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

VB.NET Wav file graphical viewer control

, 22 Mar 2005
A control to produce a graphical display of any 16bit PCM Wav file.
vbnetwaverender.zip
vbnetWaveRender_02
vbnetWaveRenderTestApp_02
bin
vbnetWaveRenderTestApp_02.exe
vbnetWaveRenderTestApp_02.exe.manifest
vbnetWaveRender_02.dll
vbnetWaveRenderTestApp_02.vbproj.user
vbnetWaveRender_02
bin
vbnetWaveRender_02.dll
vbnetWaveRender_02.vbproj.user
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents txtbFileName As System.Windows.Forms.TextBox
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    Friend WithEvents cmbZoom As System.Windows.Forms.ComboBox
    Friend WithEvents VbnetWaveRender2 As vbnetWaveRender_02.vbnetWaveRender
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Button1 = New System.Windows.Forms.Button
        Me.txtbFileName = New System.Windows.Forms.TextBox
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.TextBox4 = New System.Windows.Forms.TextBox
        Me.cmbZoom = New System.Windows.Forms.ComboBox
        Me.VbnetWaveRender2 = New vbnetWaveRender_02.vbnetWaveRender
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.Button1.Location = New System.Drawing.Point(584, 40)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Button1"
        '
        'txtbFileName
        '
        Me.txtbFileName.Location = New System.Drawing.Point(488, 96)
        Me.txtbFileName.Name = "txtbFileName"
        Me.txtbFileName.Size = New System.Drawing.Size(248, 20)
        Me.txtbFileName.TabIndex = 3
        Me.txtbFileName.Text = "TextBox1"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(488, 152)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(248, 20)
        Me.TextBox1.TabIndex = 4
        Me.TextBox1.Text = "TextBox1"
        '
        'Timer1
        '
        Me.Timer1.Enabled = True
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(488, 192)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(248, 20)
        Me.TextBox2.TabIndex = 5
        Me.TextBox2.Text = "TextBox2"
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(488, 232)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(248, 20)
        Me.TextBox3.TabIndex = 6
        Me.TextBox3.Text = "TextBox3"
        '
        'TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(488, 272)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(248, 20)
        Me.TextBox4.TabIndex = 7
        Me.TextBox4.Text = "TextBox4"
        '
        'cmbZoom
        '
        Me.cmbZoom.Items.AddRange(New Object() {"e24to1", "e16to1", "e8to1", "e6to1", "e4to1", "e3to1", "e2to1", "e1to1", "e1to2", "e1to4", "e1to8", "e1to16", "e1to32", "e1to64", "e1to128", "e1to256", "e1to512", "e1to1024", "e1to2048", "e1to4196", "e1to8192", "e1to16384"})
        Me.cmbZoom.Location = New System.Drawing.Point(488, 320)
        Me.cmbZoom.Name = "cmbZoom"
        Me.cmbZoom.Size = New System.Drawing.Size(248, 21)
        Me.cmbZoom.TabIndex = 8
        '
        'VbnetWaveRender2
        '
        Me.VbnetWaveRender2.BackColor = System.Drawing.Color.Black
        Me.VbnetWaveRender2.BoarderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.VbnetWaveRender2.HalfAmplitudeDividerColor = System.Drawing.Color.Yellow
        Me.VbnetWaveRender2.HalfAmplitudeDividerLineStyle = System.Drawing.Drawing2D.DashStyle.Dash
        Me.VbnetWaveRender2.HalfAmplitudeDividerLineThickness = CType(1, Short)
        Me.VbnetWaveRender2.Location = New System.Drawing.Point(8, 8)
        Me.VbnetWaveRender2.MidDividerColor = System.Drawing.SystemColors.InactiveCaption
        Me.VbnetWaveRender2.MidDividerLineStyle = System.Drawing.Drawing2D.DashStyle.Solid
        Me.VbnetWaveRender2.MidDividerLineThickness = CType(1, Short)
        Me.VbnetWaveRender2.Name = "VbnetWaveRender2"
        Me.VbnetWaveRender2.NoWaveBackColor = System.Drawing.SystemColors.ControlDark
        Me.VbnetWaveRender2.Size = New System.Drawing.Size(472, 480)
        Me.VbnetWaveRender2.StereoDividerColor = System.Drawing.Color.White
        Me.VbnetWaveRender2.StereoDividerLineStyle = System.Drawing.Drawing2D.DashStyle.Solid
        Me.VbnetWaveRender2.StereoDividerLineThickness = CType(2, Short)
        Me.VbnetWaveRender2.TabIndex = 9
        Me.VbnetWaveRender2.ThreadUse = True
        Me.VbnetWaveRender2.WaveFile = ""
        Me.VbnetWaveRender2.WaveForeColor = System.Drawing.Color.Lime
        Me.VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to1
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(760, 526)
        Me.Controls.Add(Me.VbnetWaveRender2)
        Me.Controls.Add(Me.cmbZoom)
        Me.Controls.Add(Me.TextBox4)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.txtbFileName)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim frmWait As New frmWait

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cmbZoom.SelectedText = "e1to1"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim OFDA As New OpenFileDialog
        OFDA.InitialDirectory = "C:\"
        OFDA.RestoreDirectory = True
        OFDA.Filter = "Audio Files(*.wav)|*.wav|All files (*.*)|*.*"
        OFDA.Title = "Please Select An Audio File"
        If OFDA.ShowDialog() = DialogResult.OK Then
            txtbFileName.Text = OFDA.FileName

            VbnetWaveRender2.WaveFile = OFDA.FileName

        End If
        OFDA.Dispose()

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        TextBox1.Text = VbnetWaveRender2.WaveOpen.ToString
        TextBox2.Text = VbnetWaveRender2.WaveChannels.ToString
        TextBox3.Text = VbnetWaveRender2.WaveSamplingFreq.ToString
        TextBox4.Text = VbnetWaveRender2.WaveBitsPerSample.ToString
    End Sub


    Private Sub cmbZoom_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbZoom.SelectedIndexChanged

        Select Case cmbZoom.SelectedIndex
            Case 0
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e24to1
            Case 1
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e16to1
            Case 2
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e8to1
            Case 3
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e6to1
            Case 4
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e4to1
            Case 5
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e3to1
            Case 6
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e2to1
            Case 7
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to1
            Case 8
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to2
            Case 9
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to4
            Case 10
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to8
            Case 11
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to16
            Case 12
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to32
            Case 13
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to64
            Case 14
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to128
            Case 15
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to256
            Case 16
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to512
            Case 17
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to1024
            Case 18
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to2048
            Case 19
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to4196
            Case 20
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to8192
            Case 21
                VbnetWaveRender2.Zoom = vbnetWaveRender_02.vbnetWaveRender.EWaveViewerZoom.e1to16384
        End Select
    End Sub


    Private Sub form_wm(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseWheel
        If (e.X > VbnetWaveRender2.Left) And (e.X < VbnetWaveRender2.Left + VbnetWaveRender2.Width) Then
            If (e.Y > VbnetWaveRender2.Top) And (e.Y < VbnetWaveRender2.Top + VbnetWaveRender2.Height) Then
                VbnetWaveRender2.cont_MouseWheel(sender, e)
            End If
        End If
    End Sub

    Private Sub render_start() Handles VbnetWaveRender2.RenderStarted
        frmWait.Show()
    End Sub

    Private Sub render_finished() Handles VbnetWaveRender2.RenderFinished
        frmWait.Hide()
    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Quenchmaster
Web Developer
United Kingdom United Kingdom
Having done a four year Electronic Engineering Undergraduate course at the University of Warwick, I have now moved on to doing a PhD at the same place.
 
I am currently envolved in the use of signal processing in watermarking for copyright control.
 
I have always had a knack of picking up different programming languages quite easily but have not done much serious programming untill now.

| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 22 Mar 2005
Article Copyright 2005 by Quenchmaster
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid