LoginSignup
0
0

More than 5 years have passed since last update.

vbsの作法 その22

Posted at

概要

vbsの作法調べてみた。
AM変調やってみた。

写真

image.png

サンプルコード

Dim PI
PI = 3.14159265
Dim SRC(300)
Dim AM(300)
Dim I(300)
Dim Q(300)
Dim I2(300)
Dim Q2(300)
Dim O(300)
Dim csv(300)

For t = 0 to 299
    SRC(t) = Sin(t / 8000 * 2 * PI * 220) * 2 - 1
Next
For t = 0 to 299
    AM(t) = (.6 * Sin(t / 8000 * 2 * PI * 220) + 1) * Sin(t / 8000 * 2 * PI * 3000) * 2 - 1
Next
For t = 0 to 299
    I(t) = AM(t) * Cos(t / 8000 * 2 * PI * 2800)
    Q(t) = AM(t) * Sin(t / 8000 * 2 * PI * 2800)
Next
Q0 = 1
OMEGA = 2 * PI * 300 / 8000
ALPHA = Sin(OMEGA) / (2 * Q0)
A0 = 1 + ALPHA
A1 = -2 * Cos(OMEGA)
A2 = 1 - ALPHA
B0 = (1 - Cos(OMEGA)) / 2
B1 = 1 - Cos(OMEGA)
B2 = (1 - Cos(OMEGA)) / 2
IN1 = 0
IN2 = 0
OUt1 = 0
OUt2 = 0
For t = 0 to 299
    I2(t) = B0 / A0 * I(t) + B1 / A0 * IN1 + B2 / A0 * IN2 - A1 / A0 * OUt1 - A2 / A0 * OUt2
    IN2 = IN1
    IN1 = I(t)
    OUt2 = OUt1
    OUt1 = I2(t)
Next
IN1 = 0
IN2 = 0
OUt1 = 0
OUt2 = 0
For t = 0 to 299
    Q2(t) = B0 / A0 * Q(t) + B1 / A0 * IN1 + B2 / A0 * IN2 - A1 / A0 * OUt1 - A2 / A0 * OUt2
    IN2 = IN1
    IN1 = Q(t)
    OUt2 = OUt1
    OUt1 = Q2(t)
Next
For t = 0 to 299
    O(t) = SQR(I2(t) * I2(t) + Q2(t) * Q2(t)) * 4 - 6
    csv(t) = Cstr(O(t))
Next

Set sh = CreateObject("WScript.Shell")
cd = sh.CurrentDirectory
name2 = cd & "\am2.csv"
msgbox name2
With CreateObject("ADODB.Stream")
    .Type = 2
    .Charset = "Shift_JIS"
    .Open
    .writeText Join(csv, vbCrLf) & vbCrLf
    .saveToFile name2, 2
    .Close
End With

msgbox "ok"



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0