template.c: add verbose mode and update usage

src/template.c: Add verbose mode
EXAMPLE_USAGE.md: Update example usage
This commit is contained in:
Intel A80486DX2-66 2023-11-25 21:03:27 +03:00
parent 976b7468cc
commit 5eb82bc133
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B
3 changed files with 15 additions and 3 deletions

View File

@ -1,7 +1,7 @@
## Example usage
```text
$ echo 't&((t>>7)-t)&t>>8' | python ./bytebeat_compiler.py - -p 44100 && ./build/render_bytebeat
$ echo 't&((t>>7)-t)&t>>8' | python ./bytebeat_compiler.py - -p 44100 -v && ./build/render_bytebeat
Compiling
:: C bytebeat generator runtime unit

View File

@ -80,6 +80,8 @@ if __name__ == "__main__":
help="do not insert return statement before the code")
parser.add_argument("-q", "--silent", default=False, action="store_true",
help="do not output anything during generation")
parser.add_argument("-v", "--verbose", default=False, action="store_true",
help="output generation progress during generation")
args = parser.parse_args()
bytebeat_contents = read_from_file_or_stdin(args.file).strip()
@ -117,6 +119,8 @@ if __name__ == "__main__":
args.seconds, substitute)
substitute = substitute_var("silent_mode",
"true" if args.silent else "false", substitute)
substitute = substitute_var("verbose_mode",
"true" if args.verbose and not args.silent else "false", substitute)
rewrite_file(PATHS["substitute"], substitute)
# Compile by invoking the shell script

View File

@ -50,6 +50,7 @@ const char* dbgpnt_labels[3] = { "memory allocation",
// global variables
#define SILENT_MODE `silent_mode`
#define VERBOSE_MODE `verbose_mode`
// function prototypes
SAMPLE_TYPE
@ -97,7 +98,14 @@ main(void)
else
printf("%d seconds", SECONDS);
printf("\n\n");
printf(
#if VERBOSE_MODE
"\n\n"
#else
"\n"
#endif
);
fflush(stdout);
#endif
@ -132,7 +140,7 @@ main(void)
buffer[w] = sample_res;
// 6. log
#if !SILENT_MODE
#if VERBOSE_MODE
if (w % FREQUENCY_OF_STATUS_REPORTING == 0 ||
w >= PRODUCT - 1 /* writing last sample */) {
printf(