📄 master.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 6375
ClientLeft = 150
ClientTop = 720
ClientWidth = 9510
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6375
ScaleWidth = 9510
StartUpPosition = 3 'Windows Default
WindowState = 2 'Maximized
Begin VB.TextBox Text3
Height = 2415
Left = 600
TabIndex = 3
Text = "Text3"
Top = 600
Visible = 0 'False
Width = 3375
End
Begin VB.TextBox Text2
BackColor = &H80000004&
Height = 855
Left = 1080
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 5280
Width = 6975
End
Begin VB.TextBox Text1
BackColor = &H80000004&
Height = 855
Left = 1080
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 4440
Width = 6975
End
Begin VB.Label Label1
BorderStyle = 1 'Fixed Single
Caption = "OUTPUT"
Height = 255
Left = 120
TabIndex = 0
Top = 5160
Width = 735
End
Begin VB.Menu signal
Caption = "&Signal"
NegotiatePosition= 2 'Middle
Begin VB.Menu signalType
Caption = "Signal Type"
Begin VB.Menu rectfunction
Caption = "Rect Function"
Checked = -1 'True
End
Begin VB.Menu linearfunction
Caption = "Linear Function"
End
Begin VB.Menu user
Caption = "User Define"
End
End
Begin VB.Menu signaln
Caption = "N points"
Begin VB.Menu eightpoints
Caption = "8 points"
Checked = -1 'True
End
Begin VB.Menu sixteenpoints
Caption = "16 points"
End
End
Begin VB.Menu output
Caption = "Output"
End
Begin VB.Menu EXIT
Caption = "E&XIT"
Shortcut = ^Z
End
End
Begin VB.Menu Transforms
Caption = "&Transforms"
Begin VB.Menu fourier
Caption = "Fourier"
Begin VB.Menu DFT
Caption = "DFT"
End
Begin VB.Menu FFT
Caption = "FFT"
End
Begin VB.Menu IFFT
Caption = "IFFT"
End
End
Begin VB.Menu Walch
Caption = "Walch Transform"
Begin VB.Menu FWT
Caption = "FWT"
End
Begin VB.Menu hadamart
Caption = "Hadamart"
End
Begin VB.Menu paley
Caption = "Paley"
End
End
Begin VB.Menu codeconversion
Caption = "Code Conversion"
Begin VB.Menu BTG
Caption = "Binary to Gray"
End
Begin VB.Menu bitreversal
Caption = "Bit reversal"
End
End
End
Begin VB.Menu filters
Caption = "&Filters"
Begin VB.Menu filterType
Caption = "Type"
Begin VB.Menu LPF
Caption = "LPF"
End
Begin VB.Menu BPF
Caption = "BPF"
End
Begin VB.Menu HPF
Caption = "HPF"
End
End
Begin VB.Menu design
Caption = "Design"
Begin VB.Menu butterworth
Caption = "Butterworth"
End
Begin VB.Menu chebychev
Caption = "Chebychev"
End
End
End
Begin VB.Menu about
Caption = "&About"
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim funct(32)
Dim functI(32)
Dim n
Private Sub about_Click()
msg$ = "This tutorial is programmed by ENGINEER SHERIF OMRAN "
msg$ = msg$ + "in the first term of master degree of biomedical"
msg$ = msg$ + " electronis, It is presented to everyone who studies "
msg$ = msg$ + "introduction and fast algorithms to Digital Signal Processing" + Chr$(13)
msg$ = msg$ + "Please email me for details: omran@mail.com or call +2035444999 EGYPT-Alexandria UNI- Faculty of engineering-2000"
Title$ = "Author"
a = MsgBox(msg$)
End Sub
Private Sub bitreversal_Click()
a: binarycode = InputBox$("Please enter the value in decimal form <64 ", "Converter from binary to gray")
Dim r(6)
b = Val(binarycode)
If b > 64 Then GoTo a
e = b
hj = (Log(b) / Log(2))
hu = Int(hj) - hj
If hu = 0 Then n1 = 2 ^ (hj + 1) Else n1 = 2 ^ (hj + 1)
hh = Log(n1) / Log(2) - 1:
For i = hh To 0 Step -1
u = 2 ^ i:
If e >= u Then r(i) = 1: e = e - u Else r(i) = 0
Next
Dim xb(6), db(6)
'producing the gray code for the binary code
For i = hh To 0 Step -1: db(i) = r(hh - i)
Next:
Text1.Text = "the binary form of this no is"
Text2.Text = "the bit reversed no is"
For ii = hh To 0 Step -1
Text1.Text = Text1.Text + Str$(r(ii)) + " "
Text2.Text = Text2.Text + Str$(db(ii)) + " "
Next ii
'reply = MsgBox(mss$ + msg2$, vbInformation, "code converted")
End Sub
Private Sub BTG_Click()
a: binarycode = InputBox$("Please enter the value in decimal form <64 ", "Converter from binary to gray")
Dim r(6)
b = Val(binarycode)
If b > 64 Then GoTo a
e = b
hj = (Log(b) / Log(2))
hu = Int(hj) - hj
If hu = 0 Then n1 = 2 ^ (hj + 1) Else n1 = 2 ^ (hj + 1)
hh = Log(n1) / Log(2) - 1:
For i = hh To 0 Step -1
u = 2 ^ i:
If e >= u Then r(i) = 1: e = e - u Else r(i) = 0
Next
Dim xb(6)
'producing the gray code for the binary code
For i = hh To 0 Step -1: xb(i) = r(i + 1) Xor r(i)
If i = hh Then xb(i) = r(i)
'PRINT B(I);
'Form1.Print r(i)
Next:
Text1.Text = "the binary form of this no is"
Text2.Text = "the gray code of this no is "
For ii = hh To 0 Step -1
Text1.Text = Text1.Text + Str$(r(ii)) + " "
Text2.Text = Text2.Text + Str$(xb(ii)) + " "
Next ii
'reply = MsgBox(mss$ + msg2$, vbInformation, "code converted")
'PRINT :
End Sub
Private Sub DFT_Click()
'n1 is the number of readings
n1 = 30
w = 2 * 3.14 / n1
'readings in f(k)
Dim f(200), d(256)
For i = 1 To n - 1: f(i) = funct(i): Next
p = 1
For p = 1 To n
For i = 0 To n - 1
Real = Cos(w * i * p)
imaginary = Sin(-1 * w * p * i)
modulus = (Real ^ 2 + imaginary ^ 2) ^ 0.5
Value = f(i) * modulus
outputd = outputd + Value
Next i
d(p) = outputd ' where d(p) is the discrete fourier transform
Next p
Text1.Text = ""
Text2.Text = ""
Text1.Text = "DATA OUTPUT ---- The wave Signal present in memory" + String$(55, " ")
Text1.Text = Text1.Text + "X(n) REAL" + String$(126, " ")
For i = 0 To n - 1: Text1.Text = Text1.Text + Str$(funct(i)) + " "
Next:
End Sub
Private Sub eightpoints_Click()
eightpoints.Checked = True
sixteenpoints.Checked = False
n = 8
End Sub
Private Sub EXIT_Click()
End
End Sub
Private Sub FFT_Click()
Text1.Text = "": Text2.Text = ""
c = Log(n) / Log(2):
Dim inputR(16), inputI(16), outputR(16), outputI(16), bitrevinputR(16 * 2), bitrevinputI(2 * 16)
Dim a(2 * 16): Dim ax(2 * 16): Dim taken(2 * 16): Dim aI(2 * 16)
Dim r(5), b(5), expon(8, 8), m(4), erf(4), noftwf(4), twfexp(8, 8)
'detect twiddle factor
GoSub 200
'input
Text3.Text = ""
For i = 0 To n - 1: inputR(i) = funct(i):
inputI(i) = functI(i):
Text3.Text = Text3.Text + Str$(inputR(i))
Next
'Bit reversal arrangment
For t = 0 To n - 1
e = t
hh = Log(n) / Log(2) - 1
For i = hh To 0 Step -1
u = 2 ^ i
If e >= u Then r(i) = 1: e = e - u Else r(i) = 0
'bitreversing the binary sequence
b(hh - i) = r(i)
Next
ax1 = 0
For isf = hh To 0 Step -1
ax1 = ax1 + b(isf) * 2 ^ (isf)
Next
ax(t) = ax1
Next t
stages = Log(n) / Log(2)
'arranging the output values into bitreversal sort
For dd = 0 To n - 1
bitrevinputR(dd) = inputR(ax(dd)): bitrevinputI(ax(dd)) = inputI(dd)
Next dd
'the input is bit reversed and found in bitrevinputR(x)
For y = 0 To n - 1: taken(y) = 0:
Next: x = 0: t = 0: y = 0: i = 0
c = Log(n) / Log(2)
'CLS: Print "stage 0"
'imaginary input data=0
For xx = 0 To n - 1: bitrevinputI(xx) = 0: Next
For i = 0 To n - 1
'Print bitrevinputr(i)
Next: ' CLS
jump = 1: half = n / 2
'CLS:
st = 0
bitrevinputR(n) = 0: bitrevinputR(n + 1) = 0
bitrevinputI(n) = 0: bitrevinputI(n + 1) = 0
For u = 1 To Log(n) / Log(2): st = 0
For i = 0 To n - 1
10
For t = 0 To x - 1
If i = taken(t) Then t = x - 1: GoTo 12
Next t
st = st + 1
twfr = Cos(-1 * 2 * 3.14 * expon(st, u) / n):
twfi = Sin(-1 * 2 * 3.14 * expon(st, u) / n):
a(i) = bitrevinputR(i) + bitrevinputR(i + jump) * (twfr) - bitrevinputI(i + jump) * twfi
aI(i) = bitrevinputI(i) + bitrevinputR(i + jump) * (twfi) + bitrevinputI(i + jump) * (twfr)
a(i + jump) = bitrevinputR(i) - bitrevinputR(i + jump) * (twfr) + bitrevinputI(i + jump) * twfi
aI(i + jump) = bitrevinputI(i) - bitrevinputR(i + jump) * (twfi) - bitrevinputI(i + jump) * (twfr)
'PRINT a(i + jump); aI(i + jump)
taken(x) = i + jump: x = x + 1
12
Next
'For d = 0 To n - 1: Print a(d); aI(d): Next
jump = 2 ^ (u)
For y = 0 To n - 1: taken(y) = 0:
bitrevinputR(y) = a(y): bitrevinputI(y) = aI(y)
'Print a(y)
Next: x = 0: t = 0
'CLS:
i = 0
Next u
For y = 0 To n - 1
'Print bitrevinputr(y)
funct(y) = bitrevinputR(y)
functI(y) = bitrevinputI(y)
'Form1.Print bitrevinputr(y); bitrevinputI(y)
Next
'Text1.CLS
Text1.Text = "DATA OUTPUT ---- The wave Signal present in memory" + String$(55, " ")
Text1.Text = Text1.Text + "X(n) REAL" + String$(128, " ")
For i = 0 To n - 1: Text1.Text = Text1.Text + Str$(funct(i)) + " "
Next:
Text1.Text = Text1.Text
Text2.Text = Text2.Text + "X(n) Imaginary" + String$(122, " ") + kbkeyreturn
For i = 0 To n - 1
Text2.Text = Text2.Text + Str$(functI(i)) + " "
Next
GoTo 300
200
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'twiddle factor exponent generation part
'c represents the number of states
For i = 1 To c: m(i) = i: erf(i) = 2 ^ ((c) - i)
noftwf(i) = 2 ^ (m(i) - 1)
'PRINT i; erf(i)'noftwf(i)
Next
'rem defining the twf exponent in a square array of
'inputs equal to the last no of twfs which is noftwf(c) will be in sq
sq = noftwf(c)
'Dim twfexp(sq, c):
twfexp(0, 0) = 0
'initializing the square matrix by equaling it to zero
For t = 1 To c: For x = 1 To sq: twfexp(x, t) = 0: Next: Next
'finished initializing the matrix
For t = 1 To c
For x = 1 To noftwf(t)
If x = 1 Then twfexp(x, t) = 0: GoTo nn
twfexp(x, t) = twfexp(x - 1, t) + erf(t)
nn:
'PRINT twfexp(x, t);
Next: Next
'now we are going to define a new matrix representing the exponent
'value of the Twf which will be used in the multiplication of two
'terms
Height1 = noftwf(t - 1) 'this is the height of the matrix
wide = c 'this is the width of the matrix
'DIM expon(height, wide)
For stage = 1 To Log(n) / Log(2)
Item = 1
For y = 1 To Height1
x = twfexp(Item, stage)
expon(y, stage) = x
'? x
Item = Item + 1
If Item = noftwf(stage) + 1 Then Item = 1
Next: Next
'PRINT expon(0, 0); expon(0, 1)
'the twiddle factors exponent is in expon(height,width)
''''''''''''''''''''''''''''''''''''''''
Return
300
End Sub
Private Sub Form_Load()
n = 8
For i = 0 To 16: functI(i) = 0: Next
For i = 0 To n / 2: funct(i) = 1: Next
For i = n / 2 To n - 1: funct(i) = 0: Next
End Sub
Private Sub FWT_Click()
c = Log(n) / Log(2): Dim outbit(16)
Dim inputR(16), outputR(16), bitrevinputR(16 * 2)
Dim a(2 * 16): Dim ax(2 * 16): Dim taken(2 * 16):
Dim had(16), wal(16): Dim r(8), b(8)
For i = 0 To n - 1: inputR(i) = funct(i): Next
For t = 0 To n - 1
e = t
hh = Log(n) / Log(2) - 1
For i = hh To 0 Step -1: u = 2 ^ i
If e >= u Then r(i) = 1: e = e - u Else r(i) = 0
'bitreversing the binary sequence
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -