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 a4de44f08c
commit d448357608
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

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