1
0

separate WAVE product value and generation length

This commit is contained in:
Intel A80486DX2-66 2024-05-19 11:41:51 +03:00
parent e4a64e1ac6
commit c76c809d2a
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B
2 changed files with 13 additions and 9 deletions

View File

@ -201,6 +201,8 @@ if __name__ == "__main__":
print("Invalid mode '%s'" % args.mode)
raise SystemExit
gen_length = args.channels * samples
rewrite_file(PATHS["substitute"], substitute_vars({
"bytebeat_contents": bytebeat_contents,
"output_file": C_str_repr(args.output),
@ -215,7 +217,8 @@ if __name__ == "__main__":
"fp_return_type": args.floating_point,
"channels": args.channels,
"length": samples,
"wav_product": args.channels * samples * (args.bit_depth // 8),
"wav_product": gen_length * (args.bit_depth // 8),
"gen_length": gen_length,
"sequential_mode": args.mode == "sequential",
"block_size": args.block_size,
"silent_mode": args.silent,

View File

@ -39,6 +39,7 @@ const char* ANSI_CLEAR = __ANSI_CLEAR_STRING;
#endif
#define PRODUCT `wav_product`
#define GEN_LENGTH `gen_length`
#define FREQUENCY_OF_STATUS_REPORTING 5000
#define SEQUENTIAL_MODE `sequential_mode`
@ -224,12 +225,12 @@ main(void)
#if SEQUENTIAL_MODE
size_t time = 0;
for (size_t seq = 0; seq < MAX; seq++) {
if ((time + BLOCK_SIZE) >= PRODUCT)
calc_block_size = PRODUCT - time;
if ((time + BLOCK_SIZE) >= GEN_LENGTH)
calc_block_size = GEN_LENGTH - time;
#endif
// * bytebeat generating loop
const uintmax_t product_minus_1 = PRODUCT - 1,
const uintmax_t gen_length_minus_1 = GEN_LENGTH - 1,
bit_depth_limiter = BIT_DEPTH_LIMITER
#if FP_RETURN_TYPE
+ 1
@ -241,10 +242,10 @@ main(void)
;
#if SEQUENTIAL_MODE
for (size_t idx = 0; idx < BLOCK_SIZE && time < PRODUCT; idx++,
for (size_t idx = 0; idx < BLOCK_SIZE && time < GEN_LENGTH; idx++,
time++) {
#else
for (size_t time = 0; time < PRODUCT; time++) {
for (size_t time = 0; time < GEN_LENGTH; time++) {
#endif
// 1. generate audio data
#if FP_RETURN_TYPE
@ -287,7 +288,7 @@ main(void)
// 6. log
#if VERBOSE_MODE
if (time % FREQUENCY_OF_STATUS_REPORTING == 0 ||
time >= product_minus_1 /* or if writing last sample */) {
time >= gen_length_minus_1 /* or if writing last sample */) {
printf(
"%sremaining samples = %18" PRIuMAX " (%3.2Lf%% done)"
#if SEQUENTIAL_MODE
@ -295,8 +296,8 @@ main(void)
#endif
,
ANSI_CLEAR,
product_minus_1 - time,
((long double) time * 100) / (long double) PRODUCT
gen_length_minus_1 - time,
((long double) time * 100) / (long double) GEN_LENGTH
#if SEQUENTIAL_MODE
, (uintmax_t) seq + 1, (uintmax_t) MAX
#endif