From 759fa6df4aaf079acabde8507e58d72e3df339fd Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Wed, 10 Apr 2024 23:08:08 +0300 Subject: [PATCH] rename variable `w` to `time` --- documentation.md | 6 +++--- src/template.c | 39 +++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/documentation.md b/documentation.md index 5537315..35b21d5 100644 --- a/documentation.md +++ b/documentation.md @@ -1,7 +1,7 @@ -# C_bytebeat_render +# C\_bytebeat\_render ## Bytebeat code **Variables:** -- `w`: a `size_t` variable casted as `long double` -- `t`: `w` casted as `uintmax_t` +- `time`: a `size_t` variable casted as `long double` +- `t`: `time` casted as `uintmax_t` diff --git a/src/template.c b/src/template.c index 5011a39..6ca6cb7 100644 --- a/src/template.c +++ b/src/template.c @@ -73,7 +73,7 @@ long double #else SAMPLE_TYPE #endif -bytebeat(long double w); +bytebeat(long double time); // function implementations #if FP_RETURN_TYPE @@ -81,18 +81,18 @@ long double #else SAMPLE_TYPE #endif -bytebeat(long double w) +bytebeat(long double time) { #if PRECALCULATED_RATIO `final_sample_rate_code` #elif ORIGINAL_SAMPLE_RATE != SAMPLE_RATE # if SAMPLE_RATE > ORIGINAL_SAMPLE_RATE - w /= ((long double) SAMPLE_RATE) / ((long double) ORIGINAL_SAMPLE_RATE); + time /= ((long double) SAMPLE_RATE) / ((long double) ORIGINAL_SAMPLE_RATE); # else - w *= ((long double) ORIGINAL_SAMPLE_RATE / ((long double) SAMPLE_RATE)); + time *= ((long double) ORIGINAL_SAMPLE_RATE / ((long double) SAMPLE_RATE)); # endif #endif - uintmax_t t = (uintmax_t) w; + uintmax_t t = (uintmax_t) time; `bytebeat_contents`; } @@ -220,10 +220,10 @@ main(void) #endif #if SEQUENTIAL_MODE - size_t w = 0; + size_t time = 0; for (size_t seq = 0; seq < MAX; seq++) { - if ((w + BLOCK_SIZE) >= PRODUCT) - calc_block_size = PRODUCT - w; + if ((time + BLOCK_SIZE) >= PRODUCT) + calc_block_size = PRODUCT - time; #endif // * bytebeat generating loop @@ -240,18 +240,21 @@ main(void) #if SEQUENTIAL_MODE size_t idx = 0; - for (; idx < BLOCK_SIZE && w < PRODUCT; idx++, w++) { + for (; idx < BLOCK_SIZE && time < PRODUCT; idx++, + time++) { #else - for (size_t w = 0; w < PRODUCT; w++) { + for (size_t time = 0; time < PRODUCT; time++) { #endif // 1. generate audio data #if FP_RETURN_TYPE - long double bytebeat_res = floor(bytebeat(floor((long double) w))); + long double bytebeat_res = + floor(bytebeat(floor((long double) time))); #elif IS_SIGNED - intmax_t bytebeat_res = (intmax_t) bytebeat(floor((long double) w)); + intmax_t bytebeat_res = + (intmax_t) bytebeat(floor((long double) time)); #else uintmax_t bytebeat_res = - (uintmax_t) bytebeat(floor((long double) w)); + (uintmax_t) bytebeat(floor((long double) time)); #endif // 2. if signed, then wrap up to unsigned @@ -277,13 +280,13 @@ main(void) #if SEQUENTIAL_MODE buffer[idx] = sample_res; #else - buffer[w] = sample_res; + buffer[time] = sample_res; #endif // 6. log #if VERBOSE_MODE - if (w % FREQUENCY_OF_STATUS_REPORTING == 0 || - w >= product_minus_1 /* or if writing last sample */) { + if (time % FREQUENCY_OF_STATUS_REPORTING == 0 || + time >= product_minus_1 /* or if writing last sample */) { printf( "%sremaining samples = %18" PRIuMAX " (%3.2Lf%% done)" #if SEQUENTIAL_MODE @@ -291,8 +294,8 @@ main(void) #endif , ANSI_CLEAR, - product_minus_1 - w, - ((long double) w * 100) / (long double) PRODUCT + product_minus_1 - time, + ((long double) time * 100) / (long double) PRODUCT #if SEQUENTIAL_MODE , (uintmax_t) seq + 1, (uintmax_t) MAX #endif