diff --git a/EXAMPLE_USAGE.md b/EXAMPLE_USAGE.md index 7bf2cec..6976b9d 100644 --- a/EXAMPLE_USAGE.md +++ b/EXAMPLE_USAGE.md @@ -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 diff --git a/bytebeat_compiler.py b/bytebeat_compiler.py index 2bd56e8..3cf77f7 100644 --- a/bytebeat_compiler.py +++ b/bytebeat_compiler.py @@ -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 diff --git a/src/template.c b/src/template.c index bd922c8..a7d1cc2 100644 --- a/src/template.c +++ b/src/template.c @@ -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(