* [patch] alternative peak meter for aplay
@ 2005-12-03 10:58 Dirk Jagdmann
2005-12-05 19:00 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Dirk Jagdmann @ 2005-12-03 10:58 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 339 bytes --]
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).
--
---> Dirk Jagdmann ^ doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org
[-- Attachment #2: aplay-verbose3.patch --]
[-- Type: text/plain, Size: 2473 bytes --]
Index: alsa-utils-1.0.10/aplay/aplay.c
===================================================================
--- alsa-utils-1.0.10.orig/aplay/aplay.c 2005-11-08 17:43:36.000000000 +0100
+++ alsa-utils-1.0.10/aplay/aplay.c 2005-12-03 01:05:34.000000000 +0100
@@ -1183,17 +1183,47 @@
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) {
+ 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);
+ }
+ else if(verbose==3) {
+ 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);
+ }
}
/*
Index: alsa-utils-1.0.10/aplay/aplay.1
===================================================================
--- alsa-utils-1.0.10.orig/aplay/aplay.1 2005-11-14 11:11:50.000000000 +0100
+++ alsa-utils-1.0.10/aplay/aplay.1 2005-12-03 01:06:01.000000000 +0100
@@ -111,7 +111,7 @@
\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
Index: alsa-utils-1.0.10/aplay/arecord.1
===================================================================
--- alsa-utils-1.0.10.orig/aplay/arecord.1 2005-11-14 11:11:50.000000000 +0100
+++ alsa-utils-1.0.10/aplay/arecord.1 2005-12-03 01:06:19.000000000 +0100
@@ -111,7 +111,7 @@
\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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] alternative peak meter for aplay
2005-12-03 10:58 [patch] alternative peak meter for aplay Dirk Jagdmann
@ 2005-12-05 19:00 ` Takashi Iwai
2005-12-05 23:26 ` Dirk Jagdmann
0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2005-12-05 19:00 UTC (permalink / raw)
To: Dirk Jagdmann; +Cc: alsa-devel
At Sat, 03 Dec 2005 11:58:44 +0100,
Dirk Jagdmann wrote:
>
> 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).
I like this one. I'd vote to make this one as -vv and the older one
to -vvv. -vvv would be useful to log to a file while -vv is prettier
for a terminal output.
The only problem with this patch is that a linefeed is missing even
after the playback is finished. Could you fix it?
thanks,
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] alternative peak meter for aplay
2005-12-05 19:00 ` Takashi Iwai
@ 2005-12-05 23:26 ` Dirk Jagdmann
2005-12-06 11:27 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Dirk Jagdmann @ 2005-12-05 23:26 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 489 bytes --]
> I like this one. I'd vote to make this one as -vv and the older one
> to -vvv. -vvv would be useful to log to a file while -vv is prettier
> for a terminal output.
Ok, I exchanged the appropriate blocks.
> The only problem with this patch is that a linefeed is missing even
> after the playback is finished. Could you fix it?
Yes I can fix it, although it's a very difficult request ;-)
--
---> Dirk Jagdmann ^ doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org
[-- Attachment #2: aplay-verbose3.patch --]
[-- Type: text/plain, Size: 2880 bytes --]
Index: alsa-utils-1.0.10/aplay/aplay.c
===================================================================
--- alsa-utils-1.0.10.orig/aplay/aplay.c 2005-11-08 17:43:36.000000000 +0100
+++ alsa-utils-1.0.10/aplay/aplay.c 2005-12-05 23:16:19.000000000 +0100
@@ -303,6 +303,8 @@
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 @@
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 @@
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);
+ }
}
/*
Index: alsa-utils-1.0.10/aplay/aplay.1
===================================================================
--- alsa-utils-1.0.10.orig/aplay/aplay.1 2005-11-14 11:11:50.000000000 +0100
+++ alsa-utils-1.0.10/aplay/aplay.1 2005-12-05 23:10:36.000000000 +0100
@@ -111,7 +111,7 @@
\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
Index: alsa-utils-1.0.10/aplay/arecord.1
===================================================================
--- alsa-utils-1.0.10.orig/aplay/arecord.1 2005-11-14 11:11:50.000000000 +0100
+++ alsa-utils-1.0.10/aplay/arecord.1 2005-12-05 23:10:36.000000000 +0100
@@ -111,7 +111,7 @@
\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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] alternative peak meter for aplay
2005-12-05 23:26 ` Dirk Jagdmann
@ 2005-12-06 11:27 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2005-12-06 11:27 UTC (permalink / raw)
To: Dirk Jagdmann; +Cc: alsa-devel
At Tue, 06 Dec 2005 00:26:06 +0100,
Dirk Jagdmann wrote:
>
> > I like this one. I'd vote to make this one as -vv and the older one
> > to -vvv. -vvv would be useful to log to a file while -vv is prettier
> > for a terminal output.
>
> Ok, I exchanged the appropriate blocks.
>
> > The only problem with this patch is that a linefeed is missing even
> > after the playback is finished. Could you fix it?
>
> Yes I can fix it, although it's a very difficult request ;-)
Great, now it's on CVS. Thanks.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-12-06 11:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-03 10:58 [patch] alternative peak meter for aplay Dirk Jagdmann
2005-12-05 19:00 ` Takashi Iwai
2005-12-05 23:26 ` Dirk Jagdmann
2005-12-06 11:27 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.