-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon_utils.py
More file actions
executable file
·67 lines (59 loc) · 1.54 KB
/
Copy pathcommon_utils.py
File metadata and controls
executable file
·67 lines (59 loc) · 1.54 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import argparse
import numpy as np
def print_c_array(l):
carr = ""
for i in range(len(l)):
if i == len(l) - 1:
carr += str(l[i])
else:
carr += str(l[i]) + ", "
return carr
# Instantiate the parser
parser = argparse.ArgumentParser(description="Optional app description")
parser.add_argument(
"--sample_size",
type=int,
default=16,
help="The amount of sample in the waveform look-up table (default = 16)",
)
parser.add_argument(
"--max_top", type=int, default=127, help="The maximum top value (default = 127)"
)
parser.add_argument(
"--skip", type=int, default=4, help="The number of skipped overflows (default = 4)"
)
parser.add_argument(
"--voices", type=int, default=1, help="The number of voices (default = 1)"
)
parser.add_argument(
"--base_freq",
type=int,
default=55,
help="The frequency from which the signal is generated (default is A1, 55Hz)",
)
parser.add_argument(
"--phase",
type=float,
default=0.0,
help="The phase at origin of the signal (default is 0)",
)
parser.add_argument(
"--show_graph", action="store_true", help="Show the graph of the generated signal"
)
parser.add_argument(
"--word_bit",
type=int,
default=16,
help="The number of bits encoding the tuning word (default is 16)",
)
args = parser.parse_args()
m = args.sample_size
N = args.word_bit
VOICES = args.voices
880
MAX = args.max_top
TOP = int(np.floor(MAX / VOICES))
SKIP = args.skip
f = args.base_freq
f_cpu = 16000000 / (MAX + 1) / SKIP
phase = args.phase