mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 21:56:31 +01:00
alternative peak meter for aplay
From: Dirk Jagdmann <doj@cubic.org> This patch adds an alternative peak meter for aplay/arecord which is enabled via three "-v" command line arguments. This new mode differs from the old in a larger meter, no linefeeds for every meter update and a static maximum peak (for 1s).
This commit is contained in:
parent
0195ba441a
commit
504131b582
2 changed files with 42 additions and 8 deletions
|
@ -111,7 +111,7 @@ Delay for automatic PCM stop is # microseconds from xrun
|
|||
\fI\-v, \-\-verbose\fP
|
||||
Show PCM structure and setup.
|
||||
This option is accumulative. The VU meter is displayed when this
|
||||
is given twice.
|
||||
is given twice or three times.
|
||||
.TP
|
||||
\fI\-I, \-\-separate\-channels\fP
|
||||
One file for each channel
|
||||
|
|
|
@ -303,6 +303,8 @@ static void version(void)
|
|||
|
||||
static void signal_handler(int sig)
|
||||
{
|
||||
if (verbose==2)
|
||||
putchar('\n');
|
||||
if (!quiet_mode)
|
||||
fprintf(stderr, _("Aborted by signal %s...\n"), strsignal(sig));
|
||||
if (stream == SND_PCM_STREAM_CAPTURE) {
|
||||
|
@ -603,6 +605,8 @@ int main(int argc, char *argv[])
|
|||
else
|
||||
capturev(&argv[optind], argc - optind);
|
||||
}
|
||||
if (verbose==2)
|
||||
putchar('\n');
|
||||
snd_pcm_close(handle);
|
||||
free(audiobuf);
|
||||
snd_output_close(log);
|
||||
|
@ -1183,17 +1187,47 @@ 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): 0x%08x "), (long)ocount, max_peak);
|
||||
|
||||
if (bits_per_sample > 16)
|
||||
perc = max_peak / (max / 100);
|
||||
else
|
||||
perc = max_peak * 100 / max;
|
||||
for (val = 0; val < 20; val++)
|
||||
if (val <= perc / 5)
|
||||
putc('#', stdout);
|
||||
else
|
||||
putc(' ', stdout);
|
||||
printf(" %i%%\n", perc);
|
||||
|
||||
if(verbose<=2) {
|
||||
static int maxperc=0;
|
||||
static time_t t=0;
|
||||
const time_t tt=time(NULL);
|
||||
if(tt>t) {
|
||||
t=tt;
|
||||
maxperc=0;
|
||||
}
|
||||
if(perc>maxperc)
|
||||
maxperc=perc;
|
||||
|
||||
putchar('\r');
|
||||
for (val = 0; val <= perc / 2 && val < 50; val++)
|
||||
putchar('#');
|
||||
for (; val < maxperc / 2 && val < 50; val++)
|
||||
putchar(' ');
|
||||
putchar('+');
|
||||
for (++val; val < 50; val++)
|
||||
putchar(' ');
|
||||
|
||||
printf("| %02i%%", maxperc);
|
||||
if (perc>99)
|
||||
printf(_(" !clip "));
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
else if(verbose==3) {
|
||||
printf(_("Max peak (%li samples): 0x%08x "), (long)ocount, max_peak);
|
||||
for (val = 0; val < 20; val++)
|
||||
if (val <= perc / 5)
|
||||
putchar('#');
|
||||
else
|
||||
putchar(' ');
|
||||
printf(" %i%%\n", perc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue