implement final simple rate conversion during generation (#3)
This commit is contained in:
parent
8d33c88e35
commit
1183fdb696
@ -64,6 +64,10 @@ if __name__ == "__main__":
|
|||||||
help="bytebeat formula file")
|
help="bytebeat formula file")
|
||||||
parser.add_argument("-r", "--sample-rate", default=8000, type=int,
|
parser.add_argument("-r", "--sample-rate", default=8000, type=int,
|
||||||
help="sample rate (Hz)")
|
help="sample rate (Hz)")
|
||||||
|
parser.add_argument("-p", "--final-sample-rate", default=None, type=int,
|
||||||
|
help="convert the output to a different sample rate (usually one that "
|
||||||
|
"is set in the system, to improve sound quality) during generation "
|
||||||
|
"(not just reinterpretation)")
|
||||||
parser.add_argument("-b", "--bit-depth", default=8, type=int,
|
parser.add_argument("-b", "--bit-depth", default=8, type=int,
|
||||||
help="bit depth")
|
help="bit depth")
|
||||||
parser.add_argument("-s", "--signed", default=False, action="store_true",
|
parser.add_argument("-s", "--signed", default=False, action="store_true",
|
||||||
@ -88,11 +92,19 @@ if __name__ == "__main__":
|
|||||||
if not args.no_return: # Insert return statement
|
if not args.no_return: # Insert return statement
|
||||||
bytebeat_contents = f"\treturn\n\n{bytebeat_contents}"
|
bytebeat_contents = f"\treturn\n\n{bytebeat_contents}"
|
||||||
|
|
||||||
|
final_sample_rate_code = ""
|
||||||
|
if not args.final_sample_rate is None:
|
||||||
|
sample_rate_ratio = args.sample_rate / args.final_sample_rate
|
||||||
|
final_sample_rate_code = f"w *= {sample_rate_ratio}L;"
|
||||||
|
args.sample_rate = args.final_sample_rate
|
||||||
|
|
||||||
substitute = read_file(PATHS["template"])
|
substitute = read_file(PATHS["template"])
|
||||||
substitute = substitute_value("bytebeat_contents",
|
substitute = substitute_value("bytebeat_contents",
|
||||||
bytebeat_contents, substitute)
|
bytebeat_contents, substitute)
|
||||||
substitute = substitute_value("sample_rate",
|
substitute = substitute_value("sample_rate",
|
||||||
args.sample_rate, substitute)
|
args.sample_rate, substitute)
|
||||||
|
substitute = substitute_value("final_sample_rate_code",
|
||||||
|
final_sample_rate_code, substitute)
|
||||||
substitute = substitute_value("bit_depth",
|
substitute = substitute_value("bit_depth",
|
||||||
args.bit_depth, substitute)
|
args.bit_depth, substitute)
|
||||||
substitute = substitute_value("is_signed",
|
substitute = substitute_value("is_signed",
|
||||||
|
@ -95,6 +95,7 @@ random(void)
|
|||||||
SAMPLE_TYPE
|
SAMPLE_TYPE
|
||||||
bytebeat(long double w)
|
bytebeat(long double w)
|
||||||
{
|
{
|
||||||
|
`final_sample_rate_code`
|
||||||
uintmax_t t = (uintmax_t)w;
|
uintmax_t t = (uintmax_t)w;
|
||||||
|
|
||||||
`bytebeat_contents`
|
`bytebeat_contents`
|
||||||
|
Loading…
Reference in New Issue
Block a user