📄 frmfft.frm
字号:
VERSION 5.00
Begin VB.Form frmFFT
AutoRedraw = -1 'True
Caption = "FFT"
ClientHeight = 9315
ClientLeft = 60
ClientTop = 435
ClientWidth = 9375
LinkTopic = "Form1"
ScaleHeight = 9315
ScaleWidth = 9375
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox picIFFT
AutoRedraw = -1 'True
Height = 2175
Left = 120
ScaleHeight = 2115
ScaleWidth = 9075
TabIndex = 6
Top = 7080
Width = 9135
End
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 495
Left = 4320
TabIndex = 5
Top = 120
Width = 1215
End
Begin VB.PictureBox picFreDomain
AutoRedraw = -1 'True
Height = 2295
Left = 120
ScaleHeight = 2235
ScaleWidth = 9075
TabIndex = 4
Top = 4560
Width = 9135
End
Begin VB.PictureBox picTimeDomain
AutoRedraw = -1 'True
Height = 3375
Left = 120
ScaleHeight = 3315
ScaleWidth = 9075
TabIndex = 3
Top = 1080
Width = 9135
End
Begin VB.CommandButton Command2
Caption = "FFT"
Height = 495
Left = 2280
TabIndex = 2
Top = 120
Width = 1815
End
Begin VB.TextBox Text1
Height = 495
Left = 5640
TabIndex = 1
Text = "Text1"
Top = 120
Width = 3015
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 240
TabIndex = 0
Top = 120
Width = 1695
End
End
Attribute VB_Name = "frmFFT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim MyFile As String
Dim str As String
Dim sFile As String
str = "Pn1_#4_16k.wav"
sFile = App.Path & "\OkFile\" & str
MyFile = Dir(sFile)
If Dir(sFile) <> str Then
Text1.Text = MyFile
Else
Text1.Text = 1
End If
End Sub
Private Sub Command2_Click()
Call Test
Call Show_Pic
End Sub
Private Sub Command3_Click()
Dim i As Integer
Dim Y() As Double
Dim LenDataNov As Long
Dim Freq As Long
Freq = 8000
LenDataNov = 1024
ReDim Y(1 To LenDataNov) As Double
For i = 0 To 1023
Y(i + 1) = 5 * Sin(2 * PI * i / 128) + 4 * Sin(2 * PI * i / 64) + 2 * Sin(2 * PI * i / 32)
Next
PlotFreq.FFTWave Y(), LenDataNov, Freq, "5 Seconds"
End Sub
Private Sub Form_Load()
Dim i As Integer
picTimeDomain.Scale (-50, 10)-(1050, -10)
picTimeDomain.Line (-50, 0)-(1050, 0)
picTimeDomain.Line (0, -10)-(0, 10)
For i = 1 To 16
picTimeDomain.Line (64 * i, 0.5)-(64 * i, 0)
picTimeDomain.PSet (64 * i, -0.5)
picTimeDomain.Print CStr(i)
Next
picFreDomain.Scale (-10, 10)-(100, 0)
picIFFT.Scale (-50, 10)-(1050, -10)
picIFFT.Line (-50, 0)-(1050, 0)
picIFFT.Line (0, -10)-(0, 10)
For i = 1 To 16
picIFFT.Line (64 * i, 0.5)-(64 * i, 0)
picIFFT.PSet (64 * i, -0.5)
picIFFT.Print CStr(i)
Next
End Sub
Private Sub Show_Pic()
Dim i As Integer
picTimeDomain.CurrentX = 0
picTimeDomain.CurrentY = 0
For i = 1 To 1023
picTimeDomain.Line (i - 1, TD(i - 1).re)-(i, TD(i).re)
Next
For i = 0 To 511
picFreDomain.Line (i, Sqr(FD(i).re * FD(i).re + FD(i).im * FD(i).im) / 500)-(i, 0)
Next
picIFFT.CurrentX = 0
picIFFT.CurrentY = X1(0).re
For i = 1 To 1023
picIFFT.Line (i - 1, X1(i - 1).re)-(i, X1(i).re)
Next
End Sub
Private Sub picFreDomain_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim sX As Integer
Dim sY As Integer
sX = X
sY = Y
Text1.Text = "x = " & CStr(sX) & ",y = " & CStr(sY) & ",freq = " & CStr(sX * Fs)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -