bytebeat_compiler.py: support fractional seconds
This commit is contained in:
parent
16f5272df1
commit
178f98ba9c
@ -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
|
||||||
@ -168,7 +170,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=1, type=int,
|
parser.add_argument("-c", "--channels", default=1, 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,
|
||||||
@ -247,6 +249,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}'")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user