audio/wavdec: add -s option
This commit is contained in:
parent
a4c6dc1d3d
commit
f4d2067373
2 changed files with 27 additions and 2 deletions
|
@ -23,6 +23,10 @@ mp3dec, mp3enc, oggdec, oggenc, flacdec, sundec, wavdec, pcmconv, mixfs \- decod
|
|||
]
|
||||
.br
|
||||
.B audio/wavdec
|
||||
[
|
||||
.B -s
|
||||
.I seconds
|
||||
]
|
||||
.br
|
||||
.B audio/sundec
|
||||
.PP
|
||||
|
|
|
@ -40,13 +40,29 @@ getcc(char tag[4])
|
|||
}
|
||||
|
||||
void
|
||||
main(int, char *argv[])
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: %s [ -s SECONDS ]\n", argv0);
|
||||
exits("usage");
|
||||
}
|
||||
|
||||
void
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char buf[1024], fmt[32];
|
||||
double seekto;
|
||||
ulong len, n;
|
||||
Wave wav;
|
||||
|
||||
argv0 = argv[0];
|
||||
seekto = 0.0;
|
||||
ARGBEGIN{
|
||||
case 's':
|
||||
seekto = atof(EARGF(usage()));
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}ARGEND
|
||||
|
||||
if(memcmp(getcc(buf), "RIFF", 4) != 0)
|
||||
sysfatal("no riff format");
|
||||
get4();
|
||||
|
@ -96,6 +112,11 @@ main(int, char *argv[])
|
|||
default:
|
||||
sysfatal("wave format (0x%lux) not supported", (ulong)wav.fmt);
|
||||
}
|
||||
if(seekto != 0.0){
|
||||
if(seek(0, (ulong)seekto*wav.rate*wav.framesz & ~wav.framesz, 1) < 1)
|
||||
seekto = 0.0;
|
||||
fprint(2, "time: %g\n", seekto);
|
||||
}
|
||||
snprint(buf, sizeof(buf), "%lud", len);
|
||||
execl("/bin/audio/pcmconv", "pcmconv", "-i", fmt, "-l", buf, nil);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue