From 5524873f8d463d04e00c31f8ff5123b5759a8044 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 22 Feb 2002 08:30:04 +0000 Subject: [PATCH] Improved peak printed results --- aplay/aplay.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/aplay/aplay.c b/aplay/aplay.c index 1d84ebb..c04b477 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -895,7 +895,7 @@ static void suspend(void) /* peak handler */ static void compute_max_peak(u_char *data, size_t count) { - signed int val, max, max_peak = 0; + signed int val, max, max_peak = 0, perc; size_t step, ocount = count; while (count-- > 0) { @@ -912,7 +912,14 @@ static void compute_max_peak(u_char *data, size_t count) max = 1 << (bits_per_sample-1); if (max == 0) max = 0x7fffffff; - printf("Max peak (%li samples): %i (0x%x) %i%%\n", (long)ocount, max_peak, max_peak, max_peak / (max / 100)); + printf("Max peak (%li samples): %05i (0x%04x) ", (long)ocount, max_peak, max_peak); + perc = max_peak / (max / 100); + for (val = 0; val < 20; val++) + if (val <= perc / 5) + putc('#', stdout); + else + putc(' ', stdout); + printf(" %i%%\n", perc); } /*