By default, metronome (audio/metronome)
does scroll stdin lines to stdout in sync with the beat.
The problem is, it waits for fgetln(stdin, &len),
so the simple and expected
$ metronome
issues just one beep and waits for a line to read on stdin.
The next beep happens upon an <enter>. I think it's unexpected behaviour.
It works fine though with 'yes | metronome' or 'metronome < /dev/null'.
Also, the manpage wording is not very clear:
-F Display lines from stdin on stdout, one line each beat.
By default, 1/10th.
1/10 of what? One line per beat is one line per beat.
(Or I am missing something.)
It would IMHO be a better default to ignore stdin, and just keep the beat.
The diff bellow does that (and adds one return-value check while at it).
Jan
diff -rup ../metronome-1/metronome.6 ./metronome.6
--- ../metronome-1/metronome.6 Sun Aug 19 11:46:16 2012
+++ ./metronome.6 Mon Mar 18 20:48:25 2013
@@ -51,7 +51,7 @@ Make each audio tick a fraction of the total interval
.Ar number .
.It Fl F
Display lines from stdin on stdout, one line each beat.
-By default, 1/10th.
+By default, stdin is ignored.
.It Fl s Ar freq
Set audio output sampling frequency to
.Ar freq .
diff -rup ../metronome-1/metronome.c ./metronome.c
--- ../metronome-1/metronome.c Sun Mar 17 14:11:12 2013
+++ ./metronome.c Mon Mar 18 20:47:01 2013
@@ -123,7 +123,7 @@ main(int argc, char *argv[])
int ch;
- /* parameters, then default values */
+ d.scroll = 0;
while ((ch = getopt(argc, argv, "b:f:Fs:t:B:T:")) != -1) {
switch (ch) {
case 'b':
@@ -190,7 +190,8 @@ main(int argc, char *argv[])
d.delta = d.increment;
sio_onmove(io, cb, &d);
}
- sio_start(io);
+ if (sio_start(io) == 0)
+ bail("sio_start");
play(io, &par, bpm, frac, tone, beats, tone2);
/*NOTREACHED*/
}