separate WAVE product value and generation length
This commit is contained in:
parent
e4a64e1ac6
commit
c76c809d2a
@ -201,6 +201,8 @@ if __name__ == "__main__":
|
|||||||
print("Invalid mode '%s'" % args.mode)
|
print("Invalid mode '%s'" % args.mode)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
gen_length = args.channels * samples
|
||||||
|
|
||||||
rewrite_file(PATHS["substitute"], substitute_vars({
|
rewrite_file(PATHS["substitute"], substitute_vars({
|
||||||
"bytebeat_contents": bytebeat_contents,
|
"bytebeat_contents": bytebeat_contents,
|
||||||
"output_file": C_str_repr(args.output),
|
"output_file": C_str_repr(args.output),
|
||||||
@ -215,7 +217,8 @@ if __name__ == "__main__":
|
|||||||
"fp_return_type": args.floating_point,
|
"fp_return_type": args.floating_point,
|
||||||
"channels": args.channels,
|
"channels": args.channels,
|
||||||
"length": samples,
|
"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",
|
"sequential_mode": args.mode == "sequential",
|
||||||
"block_size": args.block_size,
|
"block_size": args.block_size,
|
||||||
"silent_mode": args.silent,
|
"silent_mode": args.silent,
|
||||||
|
@ -39,6 +39,7 @@ const char* ANSI_CLEAR = __ANSI_CLEAR_STRING;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PRODUCT `wav_product`
|
#define PRODUCT `wav_product`
|
||||||
|
#define GEN_LENGTH `gen_length`
|
||||||
#define FREQUENCY_OF_STATUS_REPORTING 5000
|
#define FREQUENCY_OF_STATUS_REPORTING 5000
|
||||||
|
|
||||||
#define SEQUENTIAL_MODE `sequential_mode`
|
#define SEQUENTIAL_MODE `sequential_mode`
|
||||||
@ -224,12 +225,12 @@ main(void)
|
|||||||
#if SEQUENTIAL_MODE
|
#if SEQUENTIAL_MODE
|
||||||
size_t time = 0;
|
size_t time = 0;
|
||||||
for (size_t seq = 0; seq < MAX; seq++) {
|
for (size_t seq = 0; seq < MAX; seq++) {
|
||||||
if ((time + BLOCK_SIZE) >= PRODUCT)
|
if ((time + BLOCK_SIZE) >= GEN_LENGTH)
|
||||||
calc_block_size = PRODUCT - time;
|
calc_block_size = GEN_LENGTH - time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * bytebeat generating loop
|
// * 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
|
bit_depth_limiter = BIT_DEPTH_LIMITER
|
||||||
#if FP_RETURN_TYPE
|
#if FP_RETURN_TYPE
|
||||||
+ 1
|
+ 1
|
||||||
@ -241,10 +242,10 @@ main(void)
|
|||||||
;
|
;
|
||||||
|
|
||||||
#if SEQUENTIAL_MODE
|
#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++) {
|
time++) {
|
||||||
#else
|
#else
|
||||||
for (size_t time = 0; time < PRODUCT; time++) {
|
for (size_t time = 0; time < GEN_LENGTH; time++) {
|
||||||
#endif
|
#endif
|
||||||
// 1. generate audio data
|
// 1. generate audio data
|
||||||
#if FP_RETURN_TYPE
|
#if FP_RETURN_TYPE
|
||||||
@ -287,7 +288,7 @@ main(void)
|
|||||||
// 6. log
|
// 6. log
|
||||||
#if VERBOSE_MODE
|
#if VERBOSE_MODE
|
||||||
if (time % FREQUENCY_OF_STATUS_REPORTING == 0 ||
|
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(
|
printf(
|
||||||
"%sremaining samples = %18" PRIuMAX " (%3.2Lf%% done)"
|
"%sremaining samples = %18" PRIuMAX " (%3.2Lf%% done)"
|
||||||
#if SEQUENTIAL_MODE
|
#if SEQUENTIAL_MODE
|
||||||
@ -295,8 +296,8 @@ main(void)
|
|||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
ANSI_CLEAR,
|
ANSI_CLEAR,
|
||||||
product_minus_1 - time,
|
gen_length_minus_1 - time,
|
||||||
((long double) time * 100) / (long double) PRODUCT
|
((long double) time * 100) / (long double) GEN_LENGTH
|
||||||
#if SEQUENTIAL_MODE
|
#if SEQUENTIAL_MODE
|
||||||
, (uintmax_t) seq + 1, (uintmax_t) MAX
|
, (uintmax_t) seq + 1, (uintmax_t) MAX
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user