From 178f98ba9c536cfb80b364fe0be2485730356d98 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Mon, 23 Sep 2024 00:43:25 +0300 Subject: [PATCH] bytebeat_compiler.py: support fractional seconds --- bytebeat_compiler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bytebeat_compiler.py b/bytebeat_compiler.py index baafcf1..b752e59 100644 --- a/bytebeat_compiler.py +++ b/bytebeat_compiler.py @@ -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}'")