aboutsummaryrefslogtreecommitdiffstats
path: root/gensine.py
blob: f8b51613ef7560cb1993b09d75ac420dc230b9a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np

amplitude = 0.8

dac_rate = 10000 #Hz
sample_rate = 1000 #Hz
freq = 5 #Hz
duration = 2 #seconds

num_samples = sample_rate * duration

sine_table = (amplitude * 32767 * np.sin(2.0 * np.pi * freq * np.arange(num_samples) / sample_rate)).astype("i2")

sine_table.tofile("sine.dat")

plt.plot(sine_table)
plt.show()

print("Now run:")
print(f"target/debug/fl2k_ampliphase -D -c 2000 -s {dac_rate} -i {sample_rate} -f sine.dat -w sine")
print("And then")
print("./plot.py")