vbAccelerator - Contents of code file: frmVBLame.frmVERSION 5.00
Begin VB.Form frmVBLame
Caption = "vbAccelerator LAME MP3 Encoder sample"
ClientHeight = 5295
ClientLeft = 4875
ClientTop = 2385
ClientWidth = 6510
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmVBLame.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5295
ScaleWidth = 6510
Begin VB.PictureBox picDisable
BorderStyle = 0 'None
Height = 4815
Left = 60
ScaleHeight = 4815
ScaleWidth = 6375
TabIndex = 0
Top = 60
Width = 6375
Begin VB.CommandButton cmdEncode
Caption = "&Encode"
Enabled = 0 'False
Height = 435
Left = 1560
TabIndex = 25
Top = 3900
Width = 1335
End
Begin VB.PictureBox picVersionInfo
BorderStyle = 0 'None
Height = 1875
Left = 0
ScaleHeight = 1875
ScaleWidth = 6375
TabIndex = 11
Top = 0
Width = 6375
Begin VB.TextBox txtDLLMajorVersion
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 255
Left = 1620
Locked = -1 'True
TabIndex = 17
Text = "Text1"
Top = 360
Width = 4695
End
Begin VB.TextBox txtDLLMinorVersion
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 255
Left = 1620
Locked = -1 'True
TabIndex = 16
Text = "Text1"
Top = 600
Width = 4695
End
Begin VB.TextBox txtMajorVersion
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 255
Left = 1620
Locked = -1 'True
TabIndex = 15
Text = "Text1"
Top = 840
Width = 4695
End
Begin VB.TextBox txtMinorVersion
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 255
Left = 1620
Locked = -1 'True
TabIndex = 14
Text = "Text1"
Top = 1080
Width = 4695
End
Begin VB.TextBox txtReleaseDate
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 255
Left = 1620
Locked = -1 'True
TabIndex = 13
Text = "Text1"
Top = 1320
Width = 4695
End
Begin VB.TextBox txtHomePage
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 255
Left = 1620
Locked = -1 'True
TabIndex = 12
Text = "Text1"
Top = 1560
Width = 4695
End
Begin VB.Label lblVersionDetails
BackColor = &H80000010&
Caption = " LAME Encoder Details:"
ForeColor = &H80000014&
Height = 255
Left = 0
TabIndex = 24
Top = 0
Width = 6495
End
Begin VB.Label Label1
Caption = "DLL Major Version:"
Height = 255
Left = 60
TabIndex = 23
Top = 360
Width = 1515
End
Begin VB.Label Label2
Caption = "DLL Minor Version:"
Height = 255
Left = 60
TabIndex = 22
Top = 600
Width = 1515
End
Begin VB.Label Label3
Caption = "Major Version:"
Height = 255
Left = 60
TabIndex = 21
Top = 840
Width = 1515
End
Begin VB.Label Label4
Caption = "Minor Version:"
Height = 255
Left = 60
TabIndex = 20
Top = 1080
Width = 1515
End
Begin VB.Label Label5
Caption = "Release Date:"
Height = 255
Left = 60
TabIndex = 19
Top = 1320
Width = 1515
End
Begin VB.Label Label6
Caption = "Home Page:"
Height = 255
Left = 60
TabIndex = 18
Top = 1560
Width = 1515
End
End
Begin VB.PictureBox picEncode
BorderStyle = 0 'None
Height = 1695
Left = 0
ScaleHeight = 1695
ScaleWidth = 6375
TabIndex = 1
Top = 2100
Width = 6375
Begin VB.TextBox txtSourceFile
Height = 315
Left = 1620
TabIndex = 6
Top = 300
Width = 4395
End
Begin VB.CommandButton cmdPickSource
Caption = "..."
Height = 315
Left = 6060
TabIndex = 5
Top = 300
Width = 315
End
Begin VB.TextBox txtOutputMp3File
Height = 315
Left = 1620
TabIndex = 4
Top = 660
Width = 4395
End
Begin VB.CommandButton cmdPickMp3File
Caption = "..."
Height = 315
Left = 6060
TabIndex = 3
Top = 660
Width = 315
End
Begin VB.ComboBox cboOption
Height = 315
Left = 1620
Style = 2 'Dropdown List
TabIndex = 2
Top = 1260
Width = 4755
End
Begin VB.Label lblEncode
BackColor = &H80000010&
Caption = " Encode:"
ForeColor = &H80000014&
Height = 255
Left = 0
TabIndex = 10
Top = 0
Width = 6495
End
Begin VB.Label lblSourceFile
Caption = "Source Wave File:"
Height = 255
Left = 60
TabIndex = 9
Top = 360
Width = 1515
End
Begin VB.Label lblMp3File
Caption = "Output Mp3 File:"
Height = 255
Left = 60
TabIndex = 8
Top = 720
Width = 1515
End
Begin VB.Label lblPreset
Caption = "Encoding Option:"
Height = 255
Left = 60
TabIndex = 7
Top = 1320
Width = 1515
End
End
End
End
Attribute VB_Name = "frmVBLame"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private WithEvents m_cEncoder As cLameEncoder
Attribute m_cEncoder.VB_VarHelpID = -1
Private m_cProgress As cProgressBar
Private m_bCancel As Boolean
Private Function FileExists(ByVal sFile As String) As Boolean
Dim sDir As String
On Error Resume Next
sDir = Dir(sFile)
FileExists = ((Err.Number = 0) And Len(sDir) > 0)
End Function
Private Function ValidMissingFile(ByVal sFile As String) As Boolean
Dim i As Long
Dim sDir As String
Dim sTest As String
If Not FileExists(sFile) Then
i = Len(sFile)
For i = Len(sFile) To 1 Step -1
If (Mid(sFile, i, 1) = "\") Then
sDir = Left(sFile, i - 1)
Exit For
End If
Next i
If (Len(sDir) > 0) Then
On Error Resume Next
sTest = Dir(sDir, vbDirectory)
If (Err.Number = 0) And Len(sTest) > 0 Then
' Valid file if file name ok.. for now just assume
If (Len(sFile) > i + 2) Then
ValidMissingFile = True
End If
End If
End If
End If
End Function
Private Sub KillFileIfExists(ByVal sFile As String)
On Error Resume Next
Kill sFile
End Sub
Private Sub cmdEncode_Click()
If (cmdEncode.Caption = "Cancel") Then
m_bCancel = True
Else
m_bCancel = False
cmdEncode.Caption = "Cancel"
KillFileIfExists m_cEncoder.Mp3File
m_cEncoder.Encode
cmdEncode.Caption = "&Encode"
End If
End Sub
Private Sub cboOption_Click()
m_cEncoder.EncodingPreset = cboOption.ListIndex - 1
End Sub
Private Sub enableEncodeButton()
Dim bOk As Boolean
bOk = (FileExists(txtSourceFile.Text) And _
ValidMissingFile(txtOutputMp3File.Text))
If (bOk) Then
m_cEncoder.WavFile = txtSourceFile.Text
m_cEncoder.Mp3File = txtOutputMp3File.Text
End If
cmdEncode.Enabled = bOk
End Sub
Private Sub cmdPickMp3File_Click()
Dim cC As New cCommonDialog
Dim sFile As String
If (cC.VBGetSaveFileName(sFile, Filter:="MP3 Files (*.Mp3)|*.MP3|All Files
(*.*)|*.*", _
DefaultExt:="MP3", Owner:=Me.hWnd)) Then
KillFileIfExists sFile
txtOutputMp3File.Text = sFile
enableEncodeButton
End If
End Sub
Private Sub cmdPickSource_Click()
Dim cC As New cCommonDialog
Dim sFile As String
If (cC.VBGetOpenFileName(sFile, Filter:="Wave Files (*.WAV)|*.WAV|All Files
(*.*)|*.*", _
DefaultExt:="WAV", Owner:=Me.hWnd)) Then
txtSourceFile.Text = sFile
enableEncodeButton
End If
End Sub
Private Sub Form_Load()
Me.Show
Me.Refresh
Set m_cEncoder = New cLameEncoder
displayVersion m_cEncoder.Version
Set m_cProgress = New cProgressBar
m_cProgress.ShowText = True
m_cProgress.BackColor = vbWindowBackground
m_cProgress.ForeColor = vbWindowText
m_cProgress.BarColor = vbHighlight
m_cProgress.BarForeColor = vbHighlightText
displayOptions
End Sub
Private Sub displayVersion(cVer As cLameEncoderVersion)
txtDLLMajorVersion.Text = cVer.DllMajorVersion
txtDLLMinorVersion.Text = cVer.DllMinorVersion
txtMajorVersion.Text = cVer.MajorVersion
txtMinorVersion.Text = cVer.MinorVersion
txtReleaseDate.Text = format(cVer.ReleaseDate, "long date")
txtHomePage.Text = cVer.HomePage
End Sub
Private Sub displayOptions()
cboOption.AddItem "(Defaults)"
cboOption.ItemData(cboOption.NewIndex) = LQP_NOPRESET
cboOption.AddItem "Voice Quality (VBR 32kHz, 100-140kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_VOICE_QUALITY
cboOption.AddItem "R3 Mix Quality (VBR 44.1kHz, 190-200kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_R3MIX
cboOption.AddItem "Standard (VBR 44.1kHz, 170-210kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_STANDARD
cboOption.AddItem "Standard Fast (VBR 44.1kHz, 170-210kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_FAST_STANDARD
cboOption.AddItem "Extreme (VBR 44.1kHz 200-240kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_EXTREME
cboOption.AddItem "Extreme Fast (VBR 44.1kHz 200-240kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_FAST_EXTREME
cboOption.AddItem "Insane (CBR 44.1kHz 320kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_INSANE
cboOption.AddItem "Normal Quality (CBR 44.1kHz, 128kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_NORMAL_QUALITY
cboOption.AddItem "Low Quality (CBR 44.1kHz, 128kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_LOW_QUALITY
cboOption.AddItem "Medium Quality (CBR 44.1kHz, 128kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_MEDIUM
cboOption.AddItem "Medium Fast (CBR 44.1kHz, 128kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_FAST_MEDIUM
cboOption.AddItem "High Quality (CBR 44.1kHz, 128kbps)"
cboOption.ItemData(cboOption.NewIndex) = LQP_HIGH_QUALITY
cboOption.AddItem "Very High Quality (CBR 44.1kHz, 128kbps, very slow)"
cboOption.ItemData(cboOption.NewIndex) = LQP_VERYHIGH_QUALITY
cboOption.AddItem "ABR (Must set bit rate)"
cboOption.ItemData(cboOption.NewIndex) = LQP_ABR
cboOption.AddItem "CBR (Must set bit rate)"
cboOption.ItemData(cboOption.NewIndex) = LQP_CBR
cboOption.ListIndex = 3
End Sub
Private Sub m_cEncoder_Progress(ByVal samplesDone As Long, ByVal totalSamples
As Long, cancel As Boolean)
'
cancel = m_bCancel
If (cancel) Then
m_cProgress.Text = "Encoding Cancelled"
m_cProgress.Max = totalSamples
m_cProgress.Value = totalSamples
Else
m_cProgress.Max = totalSamples
m_cProgress.Value = samplesDone
picEncode.Enabled = False
DoEvents
picEncode.Enabled = True
m_cProgress.Text = "Encoding " & format(m_cProgress.Percent, "##0.0") &
"%"
End If
m_cProgress.DrawToDC Me.hWnd, Me.hdc, _
2, Me.ScaleHeight \ Screen.TwipsPerPixelY - 22, _
Me.ScaleWidth \ Screen.TwipsPerPixelX - 2, Me.ScaleHeight \
Screen.TwipsPerPixelY - 2
'
End Sub
Private Sub txtOutputMp3File_Change()
enableEncodeButton
End Sub
Private Sub txtSourceFile_Change()
enableEncodeButton
End Sub
|
|