📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4980
ClientLeft = 60
ClientTop = 345
ClientWidth = 6975
LinkTopic = "Form1"
ScaleHeight = 4980
ScaleWidth = 6975
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin VB.Frame Frame9
Caption = "剔除微小数据"
Height = 1335
Left = 120
TabIndex = 20
Top = 3720
Width = 7455
Begin VB.Frame frame11
Caption = "频率合并"
Height = 615
Left = 4800
TabIndex = 28
Top = 360
Width = 1335
Begin VB.TextBox Text10
Height = 270
Left = 120
TabIndex = 29
Text = "1"
Top = 240
Width = 1095
End
End
Begin VB.CommandButton Command4
Caption = "重新显示"
Height = 495
Left = 6240
TabIndex = 27
Top = 480
Width = 1095
End
Begin VB.Frame Frame10
Caption = "忽略阈值"
Height = 615
Left = 3480
TabIndex = 25
Top = 360
Width = 1215
Begin VB.TextBox Text9
Height = 270
Left = 120
TabIndex = 26
Text = "1"
Top = 240
Width = 975
End
End
Begin VB.Frame Frame8
Caption = "忽略倍数"
Enabled = 0 'False
Height = 615
Left = 2160
TabIndex = 23
Top = 360
Width = 1215
Begin VB.TextBox Text8
Height = 270
Left = 120
TabIndex = 24
Text = "10"
Top = 240
Width = 975
End
End
Begin VB.OptionButton Option2
Caption = "按阈值"
Height = 615
Left = 1200
TabIndex = 22
Top = 360
Value = -1 'True
Width = 1095
End
Begin VB.OptionButton Option1
Caption = "按倍数"
Height = 375
Left = 120
TabIndex = 21
Top = 480
Width = 975
End
End
Begin VB.CommandButton Command5
Caption = "装入结果"
Height = 495
Left = 2640
TabIndex = 19
Top = 3000
Width = 1095
End
Begin VB.Frame Frame7
Caption = "衰减"
Height = 615
Left = 120
TabIndex = 17
Top = 2880
Width = 1095
Begin VB.TextBox Text7
Height = 270
Left = 120
TabIndex = 18
Text = "100"
Top = 240
Width = 855
End
End
Begin VB.CommandButton Command3
Caption = "停止"
Height = 615
Left = 2280
TabIndex = 16
Top = 1920
Width = 1215
End
Begin VB.Frame Frame6
Caption = "采样时间"
Height = 615
Left = 120
TabIndex = 14
Top = 1920
Width = 1095
Begin VB.TextBox Text6
Height = 270
Left = 120
TabIndex = 15
Text = "1"
Top = 240
Width = 855
End
End
Begin VB.ListBox List1
Height = 5460
Left = 7920
TabIndex = 13
Top = 720
Width = 3135
End
Begin MSComctlLib.ProgressBar p
Height = 375
Left = 0
TabIndex = 12
Top = 0
Width = 11655
_ExtentX = 20558
_ExtentY = 661
_Version = 393216
BorderStyle = 1
Appearance = 1
Scrolling = 1
End
Begin VB.CommandButton Command2
Caption = "开始计算"
Height = 615
Left = 1200
TabIndex = 11
Top = 1920
Width = 1095
End
Begin VB.Frame Frame5
Caption = "音频数据长度"
Height = 615
Left = 4440
TabIndex = 8
Top = 1200
Width = 1575
Begin VB.TextBox Text5
Height = 270
Left = 120
TabIndex = 9
Top = 240
Width = 1335
End
End
Begin VB.Frame Frame4
Caption = "文件"
Height = 615
Left = 1560
TabIndex = 6
Top = 480
Width = 4455
Begin VB.TextBox Text4
Height = 270
Left = 120
TabIndex = 7
Text = "Text4"
Top = 240
Width = 4215
End
End
Begin VB.Frame Frame3
Caption = "量化位数"
Height = 615
Left = 3000
TabIndex = 3
Top = 1200
Width = 1575
Begin VB.TextBox Text3
Height = 270
Left = 120
TabIndex = 5
Top = 240
Width = 1335
End
End
Begin VB.Frame Frame2
Caption = "采样频率"
Height = 615
Left = 1560
TabIndex = 2
Top = 1200
Width = 1575
Begin VB.TextBox Text2
Height = 270
Left = 120
TabIndex = 10
Top = 240
Width = 1335
End
End
Begin VB.Frame Frame1
Caption = "频道"
Height = 615
Left = 120
TabIndex = 1
Top = 1200
Width = 1575
Begin VB.TextBox Text1
Height = 270
Left = 120
TabIndex = 4
Top = 240
Width = 1215
End
End
Begin VB.CommandButton Command1
Caption = "音频文件打开"
Height = 495
Left = 120
TabIndex = 0
Top = 600
Width = 1335
End
Begin MSComDlg.CommonDialog cd1
Left = 240
Top = 1440
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim inputs() As Byte
Dim inputi() As Integer
Dim outputs() As Single
Dim ch() As New f
Dim flag As Boolean
Private Sub Command1_Click()
Dim b As Byte
Dim w(1) As Byte
Dim dw(3) As Byte
cd1.ShowOpen
Text4.Text = cd1.FileName
Open cd1.FileName For Binary As #1
Dim t As Integer
t = 0
Do While EOF(1) = False
Get #1, , b
If b = Asc("f") Then
t = 1
ElseIf b = Asc("m") And t = 1 Then
t = 2
ElseIf b = Asc("t") And t = 2 Then
t = 3
ElseIf b = 32 And t = 3 Then
t = 4
Else
t = 0
End If
If t = 4 Then Exit Do
Loop
If t = 4 Then
Seek #1, Seek(1) + 6
Get #1, , w
Text1.Text = conhtoi(w, 2)
Get #1, , dw
Text2.Text = conhtoi(dw, 4)
Seek #1, Seek(1) + 6
Get #1, , w
Text3.Text = conhtoi(w, 2)
End If
Do While EOF(1) = False
Get #1, , b
If b = Asc("d") Then
t = 1
ElseIf b = Asc("a") And t = 1 Then
t = 2
ElseIf b = Asc("t") And t = 2 Then
t = 3
ElseIf b = Asc("a") And t = 3 Then
t = 4
Else
t = 0
End If
If t = 4 Then Exit Do
Loop
Get #1, , dw
Text5.Text = conhtoi(dw, 4)
Close #1
End Sub
Function conhtoi(bb() As Byte, num As Integer)
conhtoi = 0
For i = 0 To num - 1
temp = 1
For j = 1 To i
temp = temp * 256
Next j
conhtoi = conhtoi + bb(i) * temp
Next i
End Function
Private Sub Command2_Click()
Dim temp As New f
thetime = Text6.Text
ReDim inputi(Text2.Text * thetime - 1)
ReDim inputs(Text2.Text * thetime - 1)
ReDim outputs(Text2.Text * thetime - 1)
Open cd1.FileName For Binary As #1
Seek #1, 60
Get #1, , inputs
Close #1
For i = 0 To Text2.Text * thetime - 1
inputi(i) = inputs(i) - 128
Next i
'Dim aaaa As Double, bbbb As Double
'For i = 0 To 15900
' aaaa = (1 / 8000) * (i + 1) * 2 * 3.14
' bbbb = (1 / 8000) * (i + 1) * 3.14 * 4
' inputi(i) = Fix((Sin(aaaa) + Sin(bbbb)) * 64)
'Next i
ReDim ch(Text2.Text * thetime)
List1.Clear
p.Min = 0
p.max = Text2.Text * thetime - 1
For i = 0 To Text2.Text * thetime - 1
Set ch(i) = New f
Next i
For i = 0 To Text2.Text * thetime - 1
For j = 0 To Text2.Text * thetime - 1
ch(j).s = (-6.28 * i * j) / (Text2.Text * thetime)
Next j
temp.x = 0
temp.y = 0
For k = 0 To Text2.Text * thetime - 1
temp.x = temp.x + ch(k).x * inputi(k)
temp.y = temp.y + ch(k).y * inputi(k)
Next k
outputs(i) = temp.m
p.Value = i
DoEvents
If flag = True Then
flag = False
Exit For
End If
Next i
cd1.ShowSave
If cd1.CancelError = False Then
Open cd1.FileName For Output As #2
Print #2, Text1.Text
Print #2, Text2.Text
Print #2, Text3.Text
Print #2, Text4.Text
Print #2, Text5.Text
Print #2, Text6.Text
For i = 0 To Text2.Text * thetime - 1
Print #2, outputs(i)
Next i
Close #2
End If
display
End Sub
Private Sub display()
Dim max As Double, oldp As Double, oldv As Double
thetime = Text6.Text
If Option1.Value = True Then
For i = 0 To Text2.Text * thetime - 1
If max < outputs(i) Then max = outputs(i)
Next i
max = max / Val(Text8.Text) / Val(Text7.Text)
Else
max = Text9.Text
End If
List1.Clear
oldp = 0: oldv = 0
For i = 0 To Text2.Text * thetime - 1
temp = Fix(outputs(i) / Text7.Text)
If i / thetime - oldp < 1 Then
oldv = oldv + temp
Else
If oldv > max Then
If oldp <> 0 Then
List1.AddItem "频率:" & oldp & " 幅度:" & oldv
Else
List1.AddItem "直流分量:" & oldp & " 幅度:" & oldv
End If
End If
oldp = i / thetime
oldv = temp
End If
Next i
End Sub
Private Sub Command3_Click()
flag = True
End Sub
Private Sub Command4_Click()
display
End Sub
Private Sub Command5_Click()
cd1.ShowOpen
If cd1.CancelError = False Then
Open cd1.FileName For Input As #2
Input #2, temp: Text1.Text = temp
Input #2, temp: Text2.Text = temp
Input #2, temp: Text3.Text = temp
Input #2, temp: Text4.Text = temp
Input #2, temp: Text5.Text = temp
Input #2, temp: Text6.Text = temp
thetime = Text6.Text
ReDim outputs(Text2.Text * thetime - 1)
i = 0
Do While EOF(2) = False
Input #2, outputs(i)
i = i + 1
Loop
Close #2
display
End If
End Sub
Private Sub Option1_Click()
Frame10.Enabled = False
Frame8.Enabled = True
End Sub
Private Sub Option2_Click()
Frame10.Enabled = True
Frame8.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -