1
0

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 ## Example usage
```text ```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 Compiling
:: C bytebeat generator runtime unit :: C bytebeat generator runtime unit

View File

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

View File

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