nausea

curses audio visualizer
git clone git://git.2f30.org/nausea
Log | Files | Refs | README | LICENSE

commit ba1ca8d8c3496aecc297d90c97cf02f252376532
parent 49da46e89a0f47715cb08e9f1f7e5a7f3c603016
Author: lostd <lostd@2f30.org>
Date:   Mon, 25 Nov 2013 03:14:33 +0200

Simplify the bar height computations

Diffstat:
Mspectrum.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/spectrum.c b/spectrum.c @@ -203,12 +203,15 @@ draw(struct frame *fr) size_t bar_height = 0; size_t ybegin, yend; -#define MIN(x, y) ((x) < (y) ? (x) : (y)) + /* compute bar height */ for (j = 0; j < freqs_per_col; j++) bar_height += fr->res[i * freqs_per_col + j]; - bar_height = MIN(bar_height / freqs_per_col, fr->height); - ybegin = fr->height - bar_height; - yend = MIN(bar_height + ybegin, fr->height); + bar_height /= freqs_per_col; + + /* we draw from top to bottom */ +#define MIN(x, y) ((x) < (y) ? (x) : (y)) + ybegin = fr->height - MIN(bar_height, fr->height); + yend = fr->height; #undef MIN /* If the current freq reaches the peak, the peak is