-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtxgen.py
More file actions
51 lines (45 loc) · 1.36 KB
/
txgen.py
File metadata and controls
51 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from __future__ import division
import math, wave, array
from random import randint
import Constants as c
def createREF():
for j in range(c.nref):
beta = (c.fend-c.fstart) * (math.pow((c.nref/c.fs), (-1 * c.p)))
i = j / c.fs
sample = c.refAmp * math.cos(math.pi * 2 * (beta / (1+c.p) * math.pow(i , (1 + c.p)) + c.fstart * i))
#print(str(int(sample)))
f.write(str(int(sample)))
f.write("\n")
def createTX(expAmp = 0):
print ("Generate amplitude : " + str(expAmp))
for m in range (0,c.numberOfChirps):
print("chirp num :" + str(m))
for j in range(c.ns):
beta = (c.fend-c.fstart) * (math.pow((c.ns/c.fs), (-1 * c.p)))
i = j / c.fs
chirp = expAmp * math.cos(math.pi * 2 * (beta / (1+c.p) * math.pow(i , (1 + c.p)) + c.fstart * i))
sin = expAmp * math.cos(math.pi * 2 * c.fstart * i)
sample = sin if c.isSin else chirp
#print(str(int(sample)))
f.write(str(int(sample)))
f.write("\n")
# for k in range(0,c.fs-c.ns + c.extraWait):
# sample = 0
# #print(str(int(sample)))
# f.write(str(int(sample)))
# f.write("\n")
f = open('/tmp/ref','w')
print("creating /tmp/ref")
createREF()
f.close()
f = open('/tmp/tx','w')
print("Creating /tmp/tx")
createREF()
#for k in range(0,cfs-c.ns):
# sample = 0
# #print(str(int(sample)))
# f.write(str(int(sample)))
# f.write("\n")
for r in range(c.baseAmp,c.maxAmp + 1 ,c.deltaAmp):
createTX(r)
f.close()