1
0

bytebeat_compiler.py: support fractional seconds

This commit is contained in:
Intel A80486DX2-66 2024-09-23 00:43:25 +03:00
parent 16f5272df1
commit 178f98ba9c
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -4,6 +4,8 @@ if __name__ == "__main__":
print(":: C bytebeat generator: compiler unit")
from argparse import ArgumentParser
from decimal import Decimal
from math import ceil
from os import getcwd, environ, makedirs, name as os_name, rename
from os.path import exists, join as path_join
from shlex import join as command_line_join, split as command_line_split
@ -168,7 +170,7 @@ if __name__ == "__main__":
action="store_true", help="use floating point as the return type")
parser.add_argument("-c", "--channels", default=1, type=int,
help="amount of channels")
parser.add_argument("-t", "--seconds", default=None, type=int,
parser.add_argument("-t", "--seconds", default=None, type=Decimal,
help="length in seconds (samples = sample rate * seconds) : "
"default = 30 seconds")
parser.add_argument("-l", "--samples", default=None, type=int,
@ -247,6 +249,9 @@ if __name__ == "__main__":
if samples <= 0:
raise SystemExit("CLI: Count of samples should be greater than zero.")
# round the number of samples
samples = ceil(samples)
if args.mode != "sequential" and args.mode != "instant":
raise SystemExit(f"Invalid mode '{args.mode}'")